@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonb.d.ts","sources":["../jsonb.ts"],"names":[],"mappings":"AAqBA,cAAc,GAAG,2BAAgC;AACjD,cAAmB,KAAK,2BAAgC;AACxD,SAAS,KAAK,IAAI,EAAe,KAAK,KAAK,8BAAmC;AAE9E,4CAA4C,GAC5C,OAAO,YAAI,UAAW,GAAG,OAAO,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,OAAO,CAC7B;AAEvC,4EAA4E,GAC5E,OAAO,YAAI,SAAU,OAAO,OAAO,KAAG,MACQ;AAE9C,oDAAoD,GACpD,OAAO,YAAI,UAAW,GAAG,SAAO,KAAwC;AAgBxE;;+DAE+D,GAC/D,OAAO,YAAI,UAAW,UAAU,OAAO,MAAM,EAAE,OAAO,GACpD,GAAG,OACH,MAAM,MAAM,EACZ,KAAK,MACJ,EAMF;AAkBD;;;;;;gBAMgB,GAChB,OAAO,YAAI,YAAa,UAAU,OAAO,MAAM,EAAE,OAAO,GACtD,GAAG,OACH,KAAK,GACL,UAAU,QACT,EAeF"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The key/value table's name. Named `server_meta`, not `meta`, because a
3
+ * vocabulary may well declare a `meta` component and the two must never collide
4
+ * — and because that is the name the fleet's live table already carries, so
5
+ * installing over one adopts it instead of creating a second.
6
+ */ export declare let META: string;
7
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sources":["../layout.ts"],"names":[],"mappings":"AAGA;;;;;CAKC,GACD,OAAO,YAAI,aAAoB"}
@@ -0,0 +1,41 @@
1
+ import type { Driver } from "@yaks/sql";
2
+ /** A connection's ledger of archetype moves ({@link ledger}). */ export type Ledger = {
3
+ /** A monotonic token for changes to this transaction's pending shapes. */ revision: () => number;
4
+ moved: (eid: string, table: string, held: boolean) => void;
5
+ born: (eid: string) => void;
6
+ removed: (eid: string) => void;
7
+ pointed: (eid: string) => void;
8
+ owed: () => string[];
9
+ buried: () => string[];
10
+ wrote: (eid: string) => boolean;
11
+ held: (eid: string, pointed: readonly string[] | null) => string[] | undefined;
12
+ };
13
+ /**
14
+ * A connection's account of what its open transaction did to each entity's
15
+ * archetype since that entity's pointer was written, shared by every store
16
+ * over the connection (./mod.ts `storage`). `moved` hears a row come or go
17
+ * (./write.ts `patch`), `born` a spine minted, `removed` an entity removed,
18
+ * `pointed` a pointer written.
19
+ *
20
+ * `held` is the tables an entity holds now, given the ones its stored pointer
21
+ * names: the pointer's, or none for a birth (minted in the class its shape
22
+ * last finished in, which it may not hold yet), or its tombstone for a
23
+ * removal, with each row that came or went since. So a read or a removal
24
+ * inside the transaction knows what an entity holds without reading a table.
25
+ * It is undefined for an entity with no pointer that the transaction neither
26
+ * minted nor removed: nothing says what that one holds.
27
+ *
28
+ * `owed` is every entity whose rows stand other than its pointer says, or
29
+ * that was born, with no pointer written since: the ones a unit classifies as
30
+ * it closes. `buried` is every entity removed with no pointer written since:
31
+ * each holds its tombstone and nothing else, and a read passes it by as dead
32
+ * whatever its pointer says. A batch that adds a component and drops it again
33
+ * owes nothing, and neither does anything @yaks/graph wrote, since its
34
+ * tracker points every entity it moved after the rows are written. `wrote`
35
+ * is whether the transaction heard anything of an entity since its pointer.
36
+ *
37
+ * The ledger follows the connection's savepoints: what a unit wrote and then
38
+ * rolled back is taken back here too, so a unit opened inside another, kept
39
+ * or not, leaves the account exact.
40
+ */ export declare let ledger: (driver: Driver) => Ledger;
41
+ //# sourceMappingURL=ledger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger.d.ts","sources":["../ledger.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,yBAAoC;AAGxD,+DAA+D,GAC/D,YAAY;EACV,wEAAwE,GACxE,gBAAgB,MAAM;EACtB,QAAQ,KAAK,MAAM,EAAE,OAAO,MAAM,EAAE,MAAM,OAAO,KAAK,IAAI;EAC1D,OAAO,KAAK,MAAM,KAAK,IAAI;EAC3B,UAAU,KAAK,MAAM,KAAK,IAAI;EAC9B,UAAU,KAAK,MAAM,KAAK,IAAI;EAC9B,YAAY,MAAM;EAClB,cAAc,MAAM;EACpB,QAAQ,KAAK,MAAM,KAAK,OAAO;EAC/B,OAAO,KAAK,MAAM,EAAE,kBAAkB,MAAM,KAAK,IAAI,KAAK,MAAM,KAAK,SAAS;;AAkGhF;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GACD,OAAO,YAAI,SAAU,QAAQ,WAAS,OAqErC"}
@@ -0,0 +1,89 @@
1
+ import { type Driver } from "@yaks/sql/core";
2
+ /** Read, write, clear — the whole interface. Values are text; an application
3
+ * that wants a number or a timestamp formats it itself, the way it will parse
4
+ * it back. */ export type Meta = {
5
+ get: (k: string) => string | undefined;
6
+ set: (k: string, v: string) => void;
7
+ del: (k: string) => void;
8
+ };
9
+ /** Bind the key/value interface to a driver. A value read is held by the
10
+ * driver's connection until something it cannot vouch for moves the table's
11
+ * data (@yaks/sql `revision`: another statement writing it, a rollback, DDL,
12
+ * another connection's commit); a write through here keeps what is held
13
+ * current instead, so one store's bookkeeping does not send every other key
14
+ * back to SQLite. */ export declare let meta: (driver: Driver) => Meta & {
15
+ setAll: (values: Record<string, string>) => void;
16
+ };
17
+ /** One key's value as the table holds it now, read past what is held. */ export declare let read: (driver: Driver, k: string) => string | undefined;
18
+ /** Every key starting `prefix`, with its value, in key order: one range read
19
+ * of the table, held as a key's value is. */ export declare let under: (driver: Driver, prefix: string) => [string, string][];
20
+ /** The key the epoch is kept under. */ export declare let EPOCH: string;
21
+ /** The key the fingerprint of the installed schema is kept under (mod.ts
22
+ * `install`). */ export declare let SCHEMA: string;
23
+ /** What a full-analysis engine's planner statistics stand at (./ddl.ts
24
+ * `analyzed`): the stored bytes growth is measured from, the tables that held
25
+ * at most one row when last looked at (no SQLite statistics row is taken of
26
+ * them, ./ddl.ts `analyzing`), and the tables owed an analysis, in the order
27
+ * they are worked off, and how far the count of the first has got where it is
28
+ * counted (./ddl.ts `counted`). A receipt kept with a `few` list is from
29
+ * before each decision read those off the statistics, and is written anew. */ export type Statistics = {
30
+ bytes: number;
31
+ empty: string[];
32
+ owed?: string[];
33
+ counting?: Counting;
34
+ };
35
+ /** How far a table's count has got: the rows read, and the last rowid read
36
+ * (none before the first window). */ export type Counting = {
37
+ table: string;
38
+ rows: number;
39
+ after?: number;
40
+ };
41
+ /** The fingerprint of the schema this file last had installed, or undefined
42
+ * for a file no install has finished in — one that may not have this table
43
+ * yet. */ export declare let installed: (driver: Driver) => string | undefined;
44
+ /** The schema and its analysis receipt share the installation's existing
45
+ * metadata read. File stores keep their plain stamp; full analysis records
46
+ * stored bytes after a successful pass so another incarnation can skip it. */ export declare let installation: (driver: Driver) => {
47
+ schema: string;
48
+ statistics?: Statistics;
49
+ } | undefined;
50
+ /** Keep an analysis receipt without changing the public schema fingerprint. */ export declare let analyzedAt: (driver: Driver, schema: string, statistics: Statistics) => void;
51
+ /** The prefix of the key a file records each composed schema's print under
52
+ * (./follow.ts): `schema:<print>`, its value when it was recorded. */ export declare let PRINTED: string;
53
+ /** Whether this file has recorded the composed schema `print` names. */ export declare let printed: (driver: Driver, print: string) => boolean;
54
+ /** Every composed schema's print this file has recorded: one range read of
55
+ * `server_meta`. */ export declare let prints: (driver: Driver) => string[];
56
+ /** The prefix of the key a file records each survey of a store's schema under
57
+ * (./survey.ts): `surveyed:<print>`, the store's print. */ export declare let SURVEYED: string;
58
+ /** The survey this file recorded of the store schema `print` names, as it
59
+ * was recorded. */ export declare let surveyedAt: (driver: Driver, print: string) => string | undefined;
60
+ /** The prefix of the key a store records each plugin its data requires under:
61
+ * `required:<plugin>`, its value when it was recorded. A host that does not
62
+ * compose every one refuses to open the store (@yaks/host `meet`). A plugin
63
+ * removed on purpose drops its row:
64
+ * `delete from server_meta where k = 'required:@yaks/journal'`. */ export declare let REQUIRED: string;
65
+ /** The plugins this store's data requires: one range read of `server_meta`,
66
+ * and none where the table is not there yet. */ export declare let requirements: (driver: Driver) => string[];
67
+ /** Record that this store's data requires each of `plugins`, from now on. A
68
+ * plugin it already requires keeps the time it was first recorded. */ export declare let requires: (driver: Driver, plugins: readonly string[]) => void;
69
+ /** The key the component tables the file holds are kept under, as their
70
+ * names: what its install found, and each a write raised since (./raise.ts),
71
+ * so a reader knows which tables a store holds from one row rather than a
72
+ * look at its schema. */ export declare let TABLES: string;
73
+ /** The component tables the file holds, as its install and its writes
74
+ * recorded them; undefined for a file no install of this code recorded. */ export declare let tablesAt: (driver: Driver) => string[] | undefined;
75
+ /** The store's epoch where one was minted, read without minting it: what a
76
+ * read asks, where {@link epoch} writes. */ export declare let epochAt: (driver: Driver) => string | undefined;
77
+ /**
78
+ * The store's lineage identity: a string minted once and persisted, so it
79
+ * survives a restart, a deploy and a handover — a returning client whose cursor
80
+ * carries this epoch may resume where it left off, and a client holding another
81
+ * store's epoch (or none) must start over, because rows from a different
82
+ * lineage can never be replayed against it.
83
+ *
84
+ * `install()` mints it, and this is idempotent (`insert or ignore`): a store
85
+ * that already has one keeps it and reads it back. It writes, so a read-only
86
+ * path calls `meta(driver).get(EPOCH)` instead and treats an absent one as a
87
+ * store no cursor can be trusted against.
88
+ */ export declare let epoch: (driver: Driver) => string;
89
+ //# sourceMappingURL=meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.d.ts","sources":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AAS,MAAM,GACkB;AAE9D;yDACyD,GACzD,OAAO,YAAI,iBAAsB;AAEjC;iBACiB,GACjB,OAAO,YAAI,aAAc,QAAQ,QAAQ,OAAO,MAAM,KAAG,MAAM,GAAG,SAAS,CAC3C;AAEhC;;;;iEAIiE,GACjE,OAAO,YAAI,iBAAsB;AAEjC;8CAC8C,GAC9C,OAAO,YAAI,eAAgB,QAAQ,WAAS,MAAM,GAG1C;AAER;oEACoE,GACpE,OAAO,YAAI,WAAY,QAAQ,QAAQ,kBAAkB,MAAM,OAAK,IAAI,CAUvE;AAiBD;;;uBAGuB,GACvB,OAAO,YAAI,eAAiB;AAE5B;yEACyE,GACzE,OAAO,YAAI,WAAY,QAAQ,WAAS,MAAM,KAAK,SAAS,CAG3D;AAED;0CAC0C,GAC1C,OAAO,YAAI,UAAW,QAAQ,WAAS,MAAM,GAAG,SAAS,CAAuB;AAEhF;;;;;;;;;;;CAWC,GACD,OAAO,YAAI,QAAS,QAAQ,WAAS,MAAM,CAS1C"}
@@ -0,0 +1,41 @@
1
+ /** Cooperative, preannounced SQLite migrations. Not a distributed lock service. */ import { type Driver, type Stmt } from "@yaks/sql";
2
+ import { type Clock } from "@yaks/fp";
3
+ export type MigrationState = {
4
+ generation: number;
5
+ migration: string;
6
+ state: 'pending' | 'applied' | 'failed';
7
+ announced: number;
8
+ notBefore: number;
9
+ finished: number | null;
10
+ error: string | null;
11
+ };
12
+ export type MigrationControl = {
13
+ read: () => MigrationState | undefined;
14
+ ready: () => number;
15
+ announce: (migration: string, graceMs?: number) => MigrationState;
16
+ apply: (claim: MigrationState, change: (db: Driver) => void) => void;
17
+ fail: (claim: MigrationState, reason: string) => void;
18
+ acknowledge: (generation: number) => void;
19
+ run: (name: string, change: (db: Driver) => void, options?: {
20
+ intervalMs?: number;
21
+ marginMs?: number;
22
+ }) => Promise<MigrationState>;
23
+ };
24
+ export type MigrationWatch = {
25
+ check: () => void;
26
+ stop: () => void;
27
+ };
28
+ export declare class MigrationPending extends Error {
29
+ readonly migration: MigrationState;
30
+ constructor(migration: MigrationState);
31
+ }
32
+ /** The control table, as the statement a graph's composed schema carries
33
+ * (./follow.ts): a writer adds it where it is missing, a reader never does. */ export declare function migrationSchema(): Stmt[];
34
+ /** Bind migration control over a graph. A file no writer has brought to its
35
+ * schema (a reader's fresh `:memory:`, a file nothing wrote) has no control
36
+ * table, which reads as no migration ever announced. */ export declare function migrations(db: Driver): MigrationControl;
37
+ /** One polling loop per application connection, no per-operation queries. A
38
+ * generation change latches even if pending was missed. Callback runs once;
39
+ * caller owns admission/drain/close policy. Poll errors also stop the
40
+ * monitor. It polls on `clock` (default the runtime's). */ export declare function watchMigrations(control: Pick<MigrationControl, 'read' | 'ready'>, changed: (reason: Error) => void, intervalMs?: number, clock?: Clock): MigrationWatch;
41
+ //# sourceMappingURL=migration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration.d.ts","sources":["../migration.ts"],"names":[],"mappings":"AAAA,iFAAiF,GACjF,SAGE,KAAK,MAAM,EAKX,KAAK,IAAI,yBAGkB;AAC7B,SAAS,KAAK,KAAK,wBAAqC;AASxD,YAAY;EACV,YAAY,MAAM;EAClB,WAAW,MAAM;EACjB,OAAO,YAAY,YAAY;EAC/B,WAAW,MAAM;EACjB,WAAW,MAAM;EACjB,UAAU,MAAM,GAAG,IAAI;EACvB,OAAO,MAAM,GAAG,IAAI;;AAEtB,YAAY;EACV,YAAY,iBAAiB,SAAS;EACtC,aAAa,MAAM;EACnB,WAAW,WAAW,MAAM,EAAE,UAAU,MAAM,KAAK;EACnD,QAAQ,OAAO,gBAAgB,SAAS,IAAI,WAAW,IAAI,KAAK,IAAI;EACpE,OAAO,OAAO,gBAAgB,QAAQ,MAAM,KAAK,IAAI;EACrD,cAAc,YAAY,MAAM,KAAK,IAAI;EACzC,MACE,MAAM,MAAM,EACZ,SAAS,IAAI,WAAW,IAAI,EAC5B;IAAY,aAAa,MAAM;IAAE,WAAW,MAAM;QAC/C,QAAQ;;AAEf,YAAY;EAAmB,aAAa,IAAI;EAAE,YAAY,IAAI;;AAClE,OAAO,cAAM,yBAAyB;WACR,WAAW;EAAvC,YAAY,AAAgB,WAAW,cAAc;AAMvD;AAEA;6EAC6E,GAC7E,OAAO,iBAAS,mBAAmB;AAuBnC;;sDAEsD,GACtD,OAAO,iBAAS,WAAW,IAAI,MAAM,GAAG;AA4JxC;;;yDAGyD,GACzD,OAAO,iBAAS,gBACd,SAAS,KAAK,kBAAkB,SAAS,QAAQ,EACjD,UAAU,QAAQ,UAAU,IAAI,EAChC,mBAAiB,EACjB,QAAO,KAAc,GACpB"}
package/_dist/mod.d.ts ADDED
@@ -0,0 +1,201 @@
1
+ import { type Trash, type TrashPage } from "@yaks/graph/trash";
2
+ import { type Vocab } from "@yaks/vocab";
3
+ import { type BindOpts, type Driver, type Raw, type Row, type Stmt } from "@yaks/sql";
4
+ import type { Binding, Bundle, Doom, Eid, Entity, Graves, Match, Measure, ReadOpts } from "@yaks/graph";
5
+ import { type Clock } from "@yaks/fp";
6
+ import type { Query } from "./read.js";
7
+ import type { Branches } from "@yaks/graph/storage";
8
+ import { type Sizes } from "./owe.js";
9
+ import { type Names, type Numbering } from "./write.js";
10
+ export { bindStorage, identified, layoutOf, wordColumns } from "./shape.js";
11
+ import { type History, type Mode } from "./history.js";
12
+ export { beside, BRANCH, BRANCHES, FROM, type History, historySchema, keeps, type Mode, SEEDING, ticked, TO } from "./history.js";
13
+ export { type Backfill, backfill, componentTables, type Drift, drift, entomb, heldBy, type Ledger, ledger, mend, reclassify, reclassifyAll } from "./archetype.js";
14
+ export { statements } from "./statements.js";
15
+ import { checks as diagnostics } from "./check.js";
16
+ import type { Statements } from "@yaks/sql";
17
+ import { type MigrationControl } from "./migration.js";
18
+ export { catalog } from "./catalog.js";
19
+ export { pointSql } from "./point.js";
20
+ export { type Deletions, deletions, type DeletionWindow, type Identity, identity, inspect, type StoreSize, type TableSize } from "./inspect.js";
21
+ export { asked, checks, columns, defined, heard, objects, pinned, sole, type Stood } from "./physical.js";
22
+ export { GONE, OVER, type Overlay, overlay } from "./overlay.js";
23
+ export { bindings, matched } from "./rules.js";
24
+ export * from "./bundle.js";
25
+ export { holds, lazy, raise, RAISED, recorded, rests, stood, unraised } from "./raise.js";
26
+ export { analyzed, built, FIT, fit, fitting, grown, indexed, logged, META, type Orphan, orphaned, refit, respine, respined, retabled, retired, schema, type Standing, standing, tabled, unfit, unresolved } from "./ddl.js";
27
+ export { EPOCH, epoch, epochAt, installed, type Meta, meta, printed, REQUIRED, requirements, requires } from "./meta.js";
28
+ export { decoded, isJsonb, jsonIn, jsonOut, projected } from "./jsonb.js";
29
+ export { compSql, get, OWNER, type Query, read, rows, setSql, spine, tagOf } from "./read.js";
30
+ export { buried, dropSql, erase, eraseSql, minted, mintSql, type Names, type Numbering, numberSql, patch, patchSql, prune, pruneSql, remove, removeSql, revive, type Spine, spines, touched, unburySql, upsertSql } from "./write.js";
31
+ export type { Storage } from "@yaks/graph";
32
+ /**
33
+ * A transaction over an embedded database: the same shape @yaks/graph's `Tx`
34
+ * has, with every method returning immediately rather than a promise. Naming
35
+ * the synchronous form is what lets `apply()` stay synchronous over SQLite —
36
+ * and lets a caller of this package read a bundle without awaiting one.
37
+ */ export type Tx = {
38
+ /** the id of the transaction this unit's versions name, where the store
39
+ * keeps history (./history.ts) */ clock?: () => number;
40
+ /** a query → whole bundles, or only `comps` when named */ read: (query: Query, opts?: ReadOpts, comps?: string[]) => Bundle[];
41
+ /** identity, not search: these entities as they stand, carrying the
42
+ * components `comps` names or every one */ get: (eids: string[], comps?: string[]) => Bundle[];
43
+ /** which entities are deleted along with these, and what has to release
44
+ * them — the death cascade computed by one recursive statement rather than a
45
+ * read per level */ doom: (eids: string[]) => Doom;
46
+ /** what declared rules are evaluated through: every match run against this
47
+ * graph with `bundles` folded in, through one batch overlay (./overlay.ts) */ bindings: (matches: Match[], bundles: Bundle[], covers: string[]) => Binding[][];
48
+ /** patch the bundles in → the entities this patch minted */ patch: (bundles: Bundle[]) => Entity[];
49
+ /** remove these entities: rows gone, identity tombstoned */ remove: (entities: Entity[]) => void;
50
+ /** erase these entities, a writer's own bookkeeping: rows and identity
51
+ * gone, no tombstone */ discard: (entities: Entity[]) => void;
52
+ /** Erase identities checked by an explicit orphan repair request. */ prune: (eids: string[]) => void;
53
+ /** bring these tombstoned entities back: tombstone gone, identity kept */ revive: (eids: string[]) => void;
54
+ /** the graves a retention sweep may prune (./buried.ts) */ buried: (before: string, page: {
55
+ after?: string;
56
+ limit: number;
57
+ referenced?: boolean;
58
+ }) => Graves;
59
+ };
60
+ /**
61
+ * A bound store: @yaks/graph's {@link Storage}, with synchronous reads. Its
62
+ * transactions stay synchronous when uncontended; an independent transaction
63
+ * waits for an asynchronous body already using its connection to finish.
64
+ */ export type Store = {
65
+ /** Destructive transactions retained for recovery. */ trash: (eids?: Eid[], page?: TrashPage) => Trash[];
66
+ /** Purge one retained transaction after a person explicitly chooses it. */ purgeTrash: (id: string | string[]) => void;
67
+ purgeHistory: (eids: Eid[]) => Bundle[];
68
+ retained: (values: string[]) => string[];
69
+ /** its branches, where it keeps history (./branches.ts) */ branches?: Branches;
70
+ /** Matches evaluated against committed rows without a write transaction. */ bindings?: Tx['bindings'];
71
+ /** Current committed-data invalidation token, including external WAL writes. */ revision?: () => unknown;
72
+ /** The newest row of `comp`, which moves only when a row is added
73
+ * (./watch.ts `newest`). */ newest: (comp: string) => number;
74
+ /** Call `heard` soon after another connection commits a new row of
75
+ * `comp` (./watch.ts). Only a store over a file has one. Answers a stop. */ watch?: (comp: string, heard: () => void) => () => void;
76
+ statements: Statements;
77
+ migrations: MigrationControl;
78
+ checks: ReturnType<typeof diagnostics>;
79
+ /** Whether a value this store reads for the property means its entity
80
+ * wears the component (@yaks/sql `worn`). */ worn: (comp: string, prop: string) => boolean;
81
+ /** the schema statements the bound vocabulary implies */ ddl: () => Stmt[];
82
+ /**
83
+ * the `add column` statements the live tables are missing — what `ddl()`
84
+ * cannot emit, since `create table if not exists` does nothing to a table
85
+ * that already exists (ddl.ts `grown`). Read after `ddl()` has run.
86
+ */ grown: () => Stmt[];
87
+ /** the print of the statements {@link install} runs, the store's part of a
88
+ * composed schema's print (./follow.ts) */ print: () => string;
89
+ /** run them — create the tables and indexes the vocabulary needs, and
90
+ * classify what the archetype backfill finds unclassified; nothing, where
91
+ * the file's schema is as this vocabulary last installed it. `beside` is
92
+ * the rest of the composed schema (./follow.ts): a table too big to rebuild
93
+ * at once is rebuilt later (./owe.ts), and its indexes and triggers there
94
+ * are raised again on the rebuilt one. Answers what it left undone, each
95
+ * also reported: a table whose rows do not fit its new shape, and a unique
96
+ * index those rows break (./owe.ts `build`) */ install: (beside?: Stmt[]) => Error[];
97
+ /** Advance one deferred schema window admitted by its estimated writes. */ maintain: (admit: (written: number) => boolean, seedRows?: number) => boolean;
98
+ /** make the tables of `comps` (every component of the vocabulary, left
99
+ * out), with all that rests on them, as a first write naming them would
100
+ * (./raise.ts): for a writer that fills a table in raw SQL rather than
101
+ * through a patch. Answers the components it made a table for. */ raise: (comps?: readonly string[]) => string[];
102
+ /** analyze up to `tables` of the tables whose planner statistics
103
+ * {@link install} owes (./ddl.ts `analyzed`), each in its own unit, and
104
+ * answer how many stay owed: a full-analysis engine's install decides what
105
+ * is owed and leaves the reading to whoever calls this, off the request
106
+ * that installed. The decision is also taken again here once a day
107
+ * (./owe.ts `statistics`), since an install whose schema stands decides
108
+ * nothing: a code deploy that changes how statistics are decided reaches
109
+ * a Durable Object only this way (bug b5285b5d). Nothing is ever owed on
110
+ * any other driver. */ analyze: (tables?: number) => number;
111
+ /** a query → its entities, with `comps` only where named: which entities
112
+ * match and what they carry read as one snapshot, in a unit that takes no
113
+ * write lock, so another process's commit is seen whole or not at all */ read: (query: Query, opts?: BindOpts & ReadOpts, comps?: string[]) => Bundle[];
114
+ /** a query → the compiled statement's raw rows (counts, tallies) */ rows: (query: Query, opts?: BindOpts & ReadOpts) => Row[];
115
+ /** the graves a retention sweep may prune: tombstones laid before `before`
116
+ * that nothing in the file names (./buried.ts), a page of them from `after`,
117
+ * read as one snapshot */ buried: (before: string, page: {
118
+ after?: string;
119
+ limit: number;
120
+ referenced?: boolean;
121
+ }) => Graves;
122
+ /** The host database's absolute path, absent for memory and hosted stores. */ readonly file?: string;
123
+ /** what the file keeps, measured off the caller's thread (./measure.ts) */ measure: (signal?: AbortSignal) => Promise<Measure | undefined>;
124
+ /** a query → a statement selecting the ids of the entities it admits, as
125
+ * this store compiles its reads (./read.ts `screened`); null for a query
126
+ * with nothing to narrow by */ screen: (query: Query, opts?: BindOpts & ReadOpts) => Raw | null;
127
+ /** these entities as they stand, carrying the components `comps` names or
128
+ * every one, read in a unit that takes no write lock */ get: (eids: Eid[], comps?: string[], opts?: BindOpts & ReadOpts) => Bundle[];
129
+ /** run `body` in a transaction: commit on return, roll back on throw; with
130
+ * `wait: false` a file another connection holds refuses at once,
131
+ * `retryable: true`, rather than sleeping the thread (./unit.ts) */ tx: <R>(body: (tx: Tx) => R, opts?: {
132
+ admission?: boolean;
133
+ wait?: boolean;
134
+ }) => R | Promise<Awaited<R>>;
135
+ };
136
+ /**
137
+ * What `storage()` is bound with: @yaks/sql's read options (a derived-property
138
+ * registry, a fixed `now` for time phrases). They apply to every read, and the
139
+ * registry's `text` expressions to the schema too: a property whose stored
140
+ * value is not the text itself (a blob's address, @yaks/blob `blobRead`) reads
141
+ * as text through `doc_value`.
142
+ */ export type Opts = BindOpts & {
143
+ /** Timers used while transaction entry waits for another writer. */ clock?: Clock;
144
+ /** Maintain global populations after the first unscoped aggregate (default).
145
+ * Stores that need counts immediately may seed them during installation;
146
+ * other stores never pay for upkeep until a count actually asks for it. */ counts?: 'lazy' | 'eager';
147
+ /** Leave row-dependent work for maintain(), while reads serve the standing rows. */ deferred?: boolean;
148
+ /** Where history begins, take the live rows as their first versions a page
149
+ * at a time through maintain() rather than all in the install: for a host
150
+ * whose writes are bounded by the minute (a Durable Object). Until the
151
+ * last page, the store makes no branch. */ paced?: boolean;
152
+ /** How big a table is before a file owes its schema work, and the rows a
153
+ * window does of it (./owe.ts `SIZES`): what a test shrinks. */ sizes?: Sizes;
154
+ /** A single-owner host's readiness check, called on the first operation.
155
+ * True asserts that this vocabulary and its derived schema, metadata and
156
+ * archetypes already stand; false asks this adapter to install them. The
157
+ * host must bind a new store when its schema changes. File drivers never
158
+ * install on an operation: their host brings them to its composed schema
159
+ * as it opens (./follow.ts). `install()` always validates, regardless of
160
+ * this check. */ schemaReady?: () => boolean;
161
+ /** Additive installation of a deliberately partial vocabulary. Existing
162
+ * indexes owned by declarations this installer does not carry stay intact. */ partial?: boolean;
163
+ /** Give new spines a human-readable number. Opt-IN: left out, an entity is
164
+ * its eid and nothing else, which is what a store whose entities nobody ever
165
+ * types the number of wants. A table of letters numbers each entity in the
166
+ * series of the components it is given, and `true` takes that table from
167
+ * the prefixes the vocabulary declares (./write.ts `Numbering`). Identity, and reporting which entities
168
+ * were created, still belong to storage either way. */ number?: Numbering;
169
+ /** Where an id kept as another entity's name lives (./write.ts `Names`),
170
+ * so a number given out before and kept as a name is never given again. */ names?: Names;
171
+ /** Where a failure the store outlives is told: a table that stood and could
172
+ * not be fitted to the vocabulary, left as it was (ddl.ts `fit`), or a
173
+ * write that went async inside a transaction that commits when its body
174
+ * returns (./error.ts `halfway`). One line on the console, by default
175
+ * (ddl.ts `logged`). */ report?: (error: Error) => void;
176
+ /** What each of these entities, by id, holds among `names` in the mode
177
+ * this connection reads, where no archetype pointer says (./mode.ts). */ held?: (ids: number[], names: readonly string[]) => Map<number, readonly string[]>;
178
+ /** Keep every version a write replaces (./history.ts), naming the
179
+ * transactions this statement takes, one per unit that writes a component
180
+ * with history. From the history plugin (@yaks/journal). */ history?: History;
181
+ /** Read main as of a transaction, or a branch, and write only to the branch:
182
+ * what a connection opened for a mode is bound with (./mode.ts). */ mode?: Mode;
183
+ /** How many bytes of the entities it read the store keeps in memory
184
+ * (./memo.ts): 4 MiB unless its opener can spare more. */ memory?: number;
185
+ /** The statements a host keeps beside the store's own over its component
186
+ * tables (search indexes and their triggers, an embedding queue's): each is
187
+ * made with the last table it rests on, by the write that first names that
188
+ * component (./raise.ts). Asked when a write first names one, so a host
189
+ * that composes them after binding the store can still give them. */ over?: (layout: Vocab) => readonly Stmt[];
190
+ };
191
+ /**
192
+ * Bind a store to a driver and a vocabulary — a {@link Storage} @yaks/graph
193
+ * can apply bundles to. `base` options (a derived-property registry, a fixed
194
+ * `now` for time phrases) ride every read; a per-call `opts` merges over them.
195
+ */ export declare let storage: (driver: Driver, vocab: Vocab, base?: Opts) => Store;
196
+ export * from "./migration.js";
197
+ export { add, follow, forget, grow, lacking, type Named, printFor, printOf, type Seat, shed, unseat } from "./follow.js";
198
+ export { doom } from "./doom.js";
199
+ export { branch, branching, branchOf, seeding, Unseeded } from "./branches.js";
200
+ export { moded } from "./mode.js";
201
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AACA,SAAqB,KAAK,KAAK,EAAE,KAAK,SAAS,iCAAsC;AA4CrF,SAAwB,KAAK,KAAK,2BAAgC;AAIlE,SACE,KAAK,QAAQ,EACb,KAAK,MAAM,EAIX,KAAK,GAAG,EACR,KAAK,GAAG,EAER,KAAK,IAAI,yBAEkB;AAC7B,cACE,OAAO,EACP,MAAM,EACN,IAAI,EACJ,GAAG,EACH,MAAM,EACN,MAAM,EACN,KAAK,EACL,OAAO,EACP,QAAQ,2BACqB;AAC/B,SAAgB,KAAK,KAAK,wBAAoC;AAE9D,cAAc,KAAK,oBAAmB;AAuCtC,cAAc,QAAQ,mCAAwC;AAe9D,SAKE,KAAK,KAAK,mBAGK;AAGjB,SAGE,KAAK,KAAK,EACV,KAAK,SAAS,qBAMG;AAOnB,SAAS,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,qBAAoB;AAQ3E,SACE,KAAK,OAAO,EAGZ,KAAK,IAAI,uBAQU;AAGrB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 -0,0 +1,14 @@
1
+ import { type Driver } from "@yaks/sql";
2
+ import { type Vocab } from "@yaks/vocab";
3
+ import { type History, type Mode } from "./history.js";
4
+ import { type Opts, type Store } from "./mod.js";
5
+ /**
6
+ * The store over `driver` reading `mode`: main as of a transaction, or a
7
+ * branch, over a database a store with history keeps. `driver` may be the one
8
+ * its main store writes through. The first binding makes its store; binding
9
+ * the same driver again answers the same store, now reading the new mode. The
10
+ * database's schema is its main store's to keep, never a mode's.
11
+ */ export declare let moded: (driver: Driver, vocab: Vocab, base: Opts & {
12
+ history: History;
13
+ }, mode: Mode) => Store;
14
+ //# sourceMappingURL=mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode.d.ts","sources":["../mode.ts"],"names":[],"mappings":"AAyBA,SAGE,KAAK,MAAM,yBAOgB;AAC7B,SAAsB,KAAK,KAAK,2BAAgC;AAGhE,SAAkB,KAAK,OAAO,EAAQ,KAAK,IAAI,uBAA4B;AAG3E,SAAS,KAAK,IAAI,EAAW,KAAK,KAAK,mBAAkB;AAkHzD;;;;;;CAMC,GACD,OAAO,YAAI,QACT,QAAQ,QACR,OAAO,OACP,MAAM;EAAS,SAAS;GACxB,MAAM,SACL,MAsCF"}
@@ -0,0 +1,30 @@
1
+ import type { Vocab } from "@yaks/vocab";
2
+ import type { Bundle, Eid } from "@yaks/graph";
3
+ import { type Cte, type Driver, type Expr, type Query } from "@yaks/sql";
4
+ /** What an overlaid component's CTE is called. */ export declare let OVER: string;
5
+ /** What the list of entities a batch dropped a component from is called. */ export declare let GONE: string;
6
+ /**
7
+ * A batch, made readable. `with` is the common table expressions a statement
8
+ * carries, and `at` names the source each component reads from — the
9
+ * overlay's where there is one, the committed table where the batch touched
10
+ * nothing.
11
+ */ export type Overlay = {
12
+ /** the CTEs, ready to put on a select (none when the batch moved nothing
13
+ * the caller asked about) */ with: Cte[];
14
+ /** the name of the source a component reads from */ at: (comp: string) => string;
15
+ /** Read one overlay row by its owner without enumerating the batch. */ owned: (comp: string, owner: Expr) => Query | undefined;
16
+ /** Read the owner ids matching an indexed reference. */ referring: (comp: string, column: string, target: Expr) => Query | undefined;
17
+ /** the name of the list of entities this batch removed a component from —
18
+ * `null` where the batch removed none */ gone: (comp: string) => string | null;
19
+ /** the components this overlay covers */ covers: string[];
20
+ /** the integer id each eid reads as inside it */ ids: Map<Eid, number>;
21
+ };
22
+ /**
23
+ * Read a batch as tables.
24
+ *
25
+ * ```ts ignore
26
+ * let over = overlay(driver, vocab, batch, ['product'])
27
+ * driver.query({ ...statement, with: over.with })
28
+ * ```
29
+ */ export declare let overlay: (driver: Driver, vocab: Vocab, bundles: Bundle[], only?: readonly string[]) => Overlay;
30
+ //# sourceMappingURL=overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay.d.ts","sources":["../overlay.ts"],"names":[],"mappings":"AA4DA,cAAc,KAAK,2BAAgC;AACnD,cAAc,MAAM,EAAE,GAAG,2BAAgC;AAEzD,SAME,KAAK,GAAG,EACR,KAAK,MAAM,EAGX,KAAK,IAAI,EAUT,KAAK,KAAK,yBAMiB;AAK7B,gDAAgD,GAChD,OAAO,YAAI,aAAe;AAC1B,0EAA0E,GAC1E,OAAO,YAAI,aAAe;AAE1B;;;;;CAKC,GACD,YAAY;EACV;6BAC2B,GAC3B,MAAM;EACN,kDAAkD,GAClD,KAAK,MAAM,MAAM,KAAK,MAAM;EAC5B,qEAAqE,GACrE,QAAQ,MAAM,MAAM,EAAE,OAAO,SAAS,QAAQ,SAAS;EACvD,sDAAsD,GACtD,YAAY,MAAM,MAAM,EAAE,QAAQ,MAAM,EAAE,QAAQ,SAAS,QAAQ,SAAS;EAC5E;yCACuC,GACvC,OAAO,MAAM,MAAM,KAAK,MAAM,GAAG,IAAI;EACrC,uCAAuC,GACvC,QAAQ,MAAM;EACd,+CAA+C,GAC/C,KAAK,IAAI,KAAK,MAAM;;AA8EtB;;;;;;;CAOC,GACD,OAAO,YAAI,UACT,QAAQ,QACR,OAAO,OACP,SAAS,UACT,gBAAgB,MAAM,OACrB,QAgRF"}