trellis 3.1.35 → 3.2.2

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 (287) hide show
  1. package/CHANGELOG.md +23 -5
  2. package/README.md +63 -156
  3. package/bin/trellis.mjs +2 -75
  4. package/dist/{better-sqlite-backend-ahx5p0br.js → better-sqlite-backend-2P4F6AOJ.js} +91 -29
  5. package/dist/boot-middleware-MHLHFCUC.js +9 -0
  6. package/dist/browser/index.d.ts +18 -0
  7. package/dist/browser/index.d.ts.map +1 -0
  8. package/dist/browser/index.js +95 -0
  9. package/dist/{index-53f3b8p8.js → chunk-2W3MHTMG.js} +552 -213
  10. package/dist/chunk-44FFQKQX.js +142 -0
  11. package/dist/chunk-4HYPLFJD.js +150 -0
  12. package/dist/chunk-4XIVMVHC.js +361 -0
  13. package/dist/{index-yp88he8n.js → chunk-6CTA6MCE.js} +88 -64
  14. package/dist/chunk-6GEZ6DN5.js +394 -0
  15. package/dist/chunk-7ZFRVCUE.js +211 -0
  16. package/dist/chunk-CAG4FULI.js +121 -0
  17. package/dist/chunk-FF36CQHZ.js +61 -0
  18. package/dist/{index-h32txmxe.js → chunk-FKQO5A3H.js} +6 -13
  19. package/dist/{index-nq520y6k.js → chunk-FWRS4CSC.js} +46 -32
  20. package/dist/chunk-GFZCJ4EH.js +108 -0
  21. package/dist/chunk-GLM4HGN4.js +55 -0
  22. package/dist/{index-4cdr7x2x.js → chunk-GU374KWZ.js} +182 -111
  23. package/dist/chunk-H6JB3PZ3.js +45 -0
  24. package/dist/chunk-IZX2PLIB.js +1240 -0
  25. package/dist/chunk-J2TXUFCZ.js +289 -0
  26. package/dist/chunk-J3WYZO3Q.js +211 -0
  27. package/dist/{index-xzym9w0m.js → chunk-JA7AIHRK.js} +12 -7
  28. package/dist/chunk-JHHEXEDM.js +162 -0
  29. package/dist/chunk-JUEMDWLU.js +233 -0
  30. package/dist/chunk-KFQGP6VL.js +33 -0
  31. package/dist/chunk-KIJITUZB.js +419 -0
  32. package/dist/{index-4wxa8xz4.js → chunk-KQ4A2D2P.js} +162 -23
  33. package/dist/chunk-KSU2GW22.js +958 -0
  34. package/dist/{index-rv1p47gp.js → chunk-L5N5PR2S.js} +3015 -2480
  35. package/dist/{index-h9e2efx4.js → chunk-LNUIGRDZ.js} +71 -55
  36. package/dist/{index-skhn0agf.js → chunk-MLC5BUYO.js} +19 -20
  37. package/dist/chunk-MPXUVGT3.js +104 -0
  38. package/dist/chunk-N6MYZT4O.js +68 -0
  39. package/dist/chunk-O2AV5WMN.js +48 -0
  40. package/dist/chunk-PZ4XYZ4J.js +143 -0
  41. package/dist/chunk-QB5ISE47.js +419 -0
  42. package/dist/chunk-RSWUFTO2.js +857 -0
  43. package/dist/chunk-S3XLFZ27.js +1095 -0
  44. package/dist/{index-w5wccer3.js → chunk-S6GBJ2ZB.js} +28 -12
  45. package/dist/{index-7pjz3tsy.js → chunk-SGMDTWJJ.js} +57 -15
  46. package/dist/chunk-SPSPV5BC.js +390 -0
  47. package/dist/chunk-TCKXSOBP.js +123 -0
  48. package/dist/chunk-UBGUDMUV.js +59 -0
  49. package/dist/{index-wt8rz4gn.js → chunk-UQISRW6T.js} +97 -26
  50. package/dist/chunk-USEINYUL.js +12 -0
  51. package/dist/{index-bmyt7k8n.js → chunk-UZRUP7QW.js} +12 -4
  52. package/dist/{index-xhcp6xrn.js → chunk-VBYUTRXX.js} +695 -514
  53. package/dist/{index-vkpkfwhq.js → chunk-VDAKEOML.js} +234 -194
  54. package/dist/chunk-WXSWA3MV.js +0 -0
  55. package/dist/{index-n9f2qyh5.js → chunk-X5FLTRUB.js} +55 -33
  56. package/dist/{index-h7zxhhhh.js → chunk-XMQ7G77X.js} +46 -38
  57. package/dist/{index-w7ng765c.js → chunk-YCM7ZYEZ.js} +102 -49
  58. package/dist/cli/deploy-cli.d.ts +18 -0
  59. package/dist/cli/deploy-cli.d.ts.map +1 -0
  60. package/dist/cli/errors.d.ts +6 -0
  61. package/dist/cli/errors.d.ts.map +1 -0
  62. package/dist/cli/examples.d.ts +23 -0
  63. package/dist/cli/examples.d.ts.map +1 -0
  64. package/dist/cli/index.d.ts +1 -1
  65. package/dist/cli/index.d.ts.map +1 -1
  66. package/dist/cli/index.js +2426 -6225
  67. package/dist/client/index.browser.d.ts +29 -0
  68. package/dist/client/index.browser.d.ts.map +1 -0
  69. package/dist/client/index.browser.js +64 -0
  70. package/dist/client/index.d.ts +6 -1
  71. package/dist/client/index.d.ts.map +1 -1
  72. package/dist/client/index.js +41 -21
  73. package/dist/client/live.d.ts +67 -0
  74. package/dist/client/live.d.ts.map +1 -0
  75. package/dist/client/reactive.d.ts +31 -0
  76. package/dist/client/reactive.d.ts.map +1 -0
  77. package/dist/client/sdk.browser.d.ts +104 -0
  78. package/dist/client/sdk.browser.d.ts.map +1 -0
  79. package/dist/client/sdk.browser.js +9 -0
  80. package/dist/client/sdk.d.ts +26 -2
  81. package/dist/client/sdk.d.ts.map +1 -1
  82. package/dist/client/sdk.js +9 -0
  83. package/dist/client/vcs-client.d.ts +129 -0
  84. package/dist/client/vcs-client.d.ts.map +1 -0
  85. package/dist/cms/index.js +171 -163
  86. package/dist/{config-8hczw0rs.js → config-PFTP67TR.js} +8 -9
  87. package/dist/core/computation/index.d.ts +5 -0
  88. package/dist/core/computation/index.d.ts.map +1 -0
  89. package/dist/core/computation/rollup.d.ts +18 -0
  90. package/dist/core/computation/rollup.d.ts.map +1 -0
  91. package/dist/core/index.d.ts +5 -0
  92. package/dist/core/index.d.ts.map +1 -1
  93. package/dist/core/index.js +171 -104
  94. package/dist/core/kernel/boot-middleware.d.ts +10 -0
  95. package/dist/core/kernel/boot-middleware.d.ts.map +1 -0
  96. package/dist/core/kernel/logic-middleware.d.ts +7 -1
  97. package/dist/core/kernel/logic-middleware.d.ts.map +1 -1
  98. package/dist/core/kernel/trellis-kernel.d.ts.map +1 -1
  99. package/dist/core/ontology/types.d.ts +5 -0
  100. package/dist/core/ontology/types.d.ts.map +1 -1
  101. package/dist/core/persist/better-sqlite-backend.d.ts +9 -2
  102. package/dist/core/persist/better-sqlite-backend.d.ts.map +1 -1
  103. package/dist/core/persist/factory.d.ts +6 -7
  104. package/dist/core/persist/factory.d.ts.map +1 -1
  105. package/dist/core/persist/factory.js +2 -3
  106. package/dist/core/persist/sqljs-backend.js +2 -3
  107. package/dist/db/index.d.ts +4 -1
  108. package/dist/db/index.d.ts.map +1 -1
  109. package/dist/db/index.js +67 -54
  110. package/dist/db/inspector.js +11 -19
  111. package/dist/db/trellis.css +1 -1
  112. package/dist/decisions/index.js +9 -10
  113. package/dist/deploy-LQ7GUGJ5.js +9 -0
  114. package/dist/deploy-YNVG5E4E.js +9 -0
  115. package/dist/deploy-cli-24BCHAXY.js +67 -0
  116. package/dist/deploy-cli-C35HTITO.js +67 -0
  117. package/dist/embeddings/auto-embed.d.ts +2 -2
  118. package/dist/embeddings/auto-embed.d.ts.map +1 -1
  119. package/dist/embeddings/index.js +20 -22
  120. package/dist/embeddings/search.d.ts +2 -1
  121. package/dist/embeddings/search.d.ts.map +1 -1
  122. package/dist/embeddings/store.d.ts +25 -4
  123. package/dist/embeddings/store.d.ts.map +1 -1
  124. package/dist/engine.d.ts +59 -19
  125. package/dist/engine.d.ts.map +1 -1
  126. package/dist/import-UZEKXU3B.js +10 -0
  127. package/dist/index.js +102 -93
  128. package/dist/launch-explorer-HZ4ZJA4X.js +95 -0
  129. package/dist/links/index.js +24 -26
  130. package/dist/mcp/server.d.ts.map +1 -1
  131. package/dist/plugins/agent-memory/index.js +316 -0
  132. package/dist/plugins/idea-garden/index.js +165 -0
  133. package/dist/plugins/plan-approval/index.js +579 -0
  134. package/dist/plugins/proactive-watcher/index.js +194 -0
  135. package/dist/{index-2r4jxwnb.js → query-XYLTJYSA.js} +14 -15
  136. package/dist/react/index.js +39 -70
  137. package/dist/react/realtime.js +11 -0
  138. package/dist/react/schema-hooks.js +87 -0
  139. package/dist/realtime/broadcast-channel-transport.d.ts +43 -0
  140. package/dist/realtime/broadcast-channel-transport.d.ts.map +1 -0
  141. package/dist/realtime/durable-object-relay-transport.d.ts +96 -0
  142. package/dist/realtime/durable-object-relay-transport.d.ts.map +1 -0
  143. package/dist/realtime/index.d.ts +44 -0
  144. package/dist/realtime/index.d.ts.map +1 -0
  145. package/dist/realtime/index.js +40 -0
  146. package/dist/realtime/memory-hub.d.ts +32 -0
  147. package/dist/realtime/memory-hub.d.ts.map +1 -0
  148. package/dist/realtime/persistent-channel.d.ts +105 -0
  149. package/dist/realtime/persistent-channel.d.ts.map +1 -0
  150. package/dist/realtime/presence.d.ts +73 -0
  151. package/dist/realtime/presence.d.ts.map +1 -0
  152. package/dist/realtime/relay-persistence.d.ts +37 -0
  153. package/dist/realtime/relay-persistence.d.ts.map +1 -0
  154. package/dist/realtime/relay-persistence.js +107 -0
  155. package/dist/realtime/relay-server.d.ts +103 -0
  156. package/dist/realtime/relay-server.d.ts.map +1 -0
  157. package/dist/realtime/room.d.ts +98 -0
  158. package/dist/realtime/room.d.ts.map +1 -0
  159. package/dist/realtime/text.d.ts +73 -0
  160. package/dist/realtime/text.d.ts.map +1 -0
  161. package/dist/realtime/types.d.ts +89 -0
  162. package/dist/realtime/types.d.ts.map +1 -0
  163. package/dist/realtime/websocket-relay-transport.d.ts +28 -0
  164. package/dist/realtime/websocket-relay-transport.d.ts.map +1 -0
  165. package/dist/realtime.bundle.js +1100 -0
  166. package/dist/{remote-manager-xvbg4230.js → remote-manager-ODE3T2KR.js} +25 -15
  167. package/dist/scaffold/seed.d.ts.map +1 -1
  168. package/dist/scaffold/write.d.ts +1 -1
  169. package/dist/scaffold/write.d.ts.map +1 -1
  170. package/dist/schema/define.d.ts +137 -0
  171. package/dist/schema/define.d.ts.map +1 -0
  172. package/dist/schema/entity-projection.d.ts +34 -0
  173. package/dist/schema/entity-projection.d.ts.map +1 -0
  174. package/dist/schema/eql.d.ts +46 -0
  175. package/dist/schema/eql.d.ts.map +1 -0
  176. package/dist/schema/index.d.ts +21 -0
  177. package/dist/schema/index.d.ts.map +1 -0
  178. package/dist/schema/index.js +46 -0
  179. package/dist/schema/kernel-resolve.d.ts +21 -0
  180. package/dist/schema/kernel-resolve.d.ts.map +1 -0
  181. package/dist/schema/mutations.d.ts +20 -0
  182. package/dist/schema/mutations.d.ts.map +1 -0
  183. package/dist/schema/resolve.d.ts +21 -0
  184. package/dist/schema/resolve.d.ts.map +1 -0
  185. package/dist/server/deploy-meta.d.ts +25 -0
  186. package/dist/server/deploy-meta.d.ts.map +1 -0
  187. package/dist/server/deploy.d.ts +7 -2
  188. package/dist/server/deploy.d.ts.map +1 -1
  189. package/dist/server/index.d.ts +7 -2
  190. package/dist/server/index.d.ts.map +1 -1
  191. package/dist/server/index.js +100 -58
  192. package/dist/server/node-adapter.js +5 -104
  193. package/dist/server/realtime.d.ts +14 -3
  194. package/dist/server/realtime.d.ts.map +1 -1
  195. package/dist/server/server.d.ts +8 -16
  196. package/dist/server/server.d.ts.map +1 -1
  197. package/dist/server/sprites.d.ts +18 -1
  198. package/dist/server/sprites.d.ts.map +1 -1
  199. package/dist/server/tenancy.d.ts +4 -0
  200. package/dist/server/tenancy.d.ts.map +1 -1
  201. package/dist/server/usage-meter.d.ts +53 -0
  202. package/dist/server/usage-meter.d.ts.map +1 -0
  203. package/dist/server-MB3OPSPI.js +18 -0
  204. package/dist/server-ZVWGLLRF.js +18 -0
  205. package/dist/sprites-KQGTGM6W.js +27 -0
  206. package/dist/{sprites-vc4qbrp1.js → sprites-RU3E4XQN.js} +6 -7
  207. package/dist/svelte/index.d.ts +17 -0
  208. package/dist/svelte/index.d.ts.map +1 -0
  209. package/dist/svelte/index.js +51 -0
  210. package/dist/svelte/schema-hooks.d.ts +45 -0
  211. package/dist/svelte/schema-hooks.d.ts.map +1 -0
  212. package/dist/svelte/schema-hooks.js +71 -0
  213. package/dist/svelte/stores.d.ts +78 -0
  214. package/dist/svelte/stores.d.ts.map +1 -0
  215. package/dist/sync/http-transport.d.ts +3 -3
  216. package/dist/sync/http-transport.d.ts.map +1 -1
  217. package/dist/sync/index.d.ts +15 -1
  218. package/dist/sync/index.d.ts.map +1 -1
  219. package/dist/sync/index.js +617 -0
  220. package/dist/sync/memory-room.d.ts +37 -0
  221. package/dist/sync/memory-room.d.ts.map +1 -0
  222. package/dist/sync/memory-transport.d.ts +3 -3
  223. package/dist/sync/memory-transport.d.ts.map +1 -1
  224. package/dist/sync/partykit-room.d.ts +40 -0
  225. package/dist/sync/partykit-room.d.ts.map +1 -0
  226. package/dist/sync/partykit-transport.d.ts +84 -0
  227. package/dist/sync/partykit-transport.d.ts.map +1 -0
  228. package/dist/sync/room-core.d.ts +53 -0
  229. package/dist/sync/room-core.d.ts.map +1 -0
  230. package/dist/sync/sync-engine.d.ts +40 -2
  231. package/dist/sync/sync-engine.d.ts.map +1 -1
  232. package/dist/sync/sync-room-server.d.ts +39 -0
  233. package/dist/sync/sync-room-server.d.ts.map +1 -0
  234. package/dist/sync/types.d.ts +70 -3
  235. package/dist/sync/types.d.ts.map +1 -1
  236. package/dist/sync/vcs-sync-peer.d.ts +63 -0
  237. package/dist/sync/vcs-sync-peer.d.ts.map +1 -0
  238. package/dist/sync/ws-transport.d.ts +2 -2
  239. package/dist/sync/ws-transport.d.ts.map +1 -1
  240. package/dist/tenancy-NBLLGCNJ.js +14 -0
  241. package/dist/tenancy-POMWQP6M.js +16 -0
  242. package/dist/ui/client.html +355 -67
  243. package/dist/ui/launch-explorer.d.ts +22 -0
  244. package/dist/ui/launch-explorer.d.ts.map +1 -0
  245. package/dist/ui/server.d.ts +1 -1
  246. package/dist/ui/server.d.ts.map +1 -1
  247. package/dist/vcs/blob-store.d.ts.map +1 -1
  248. package/dist/vcs/idb-op-log.d.ts +67 -0
  249. package/dist/vcs/idb-op-log.d.ts.map +1 -0
  250. package/dist/vcs/index.d.ts +1 -0
  251. package/dist/vcs/index.d.ts.map +1 -1
  252. package/dist/vcs/index.js +81 -72
  253. package/dist/vcs/issue.d.ts +22 -5
  254. package/dist/vcs/issue.d.ts.map +1 -1
  255. package/dist/vcs/lane-materialize.d.ts +5 -0
  256. package/dist/vcs/lane-materialize.d.ts.map +1 -1
  257. package/dist/vcs/op-log.d.ts +28 -2
  258. package/dist/vcs/op-log.d.ts.map +1 -1
  259. package/dist/vcs/ops.d.ts +10 -0
  260. package/dist/vcs/ops.d.ts.map +1 -1
  261. package/dist/vcs/types.d.ts +2 -0
  262. package/dist/vcs/types.d.ts.map +1 -1
  263. package/dist/{vm-config-6xhsj6b3.js → vm-config-JI4OXKDQ.js} +9 -10
  264. package/dist/vue/hooks.d.ts +64 -0
  265. package/dist/vue/hooks.d.ts.map +1 -0
  266. package/dist/vue/index.d.ts +19 -0
  267. package/dist/vue/index.d.ts.map +1 -0
  268. package/dist/vue/index.js +59 -0
  269. package/dist/vue/schema-hooks.d.ts +41 -0
  270. package/dist/vue/schema-hooks.d.ts.map +1 -0
  271. package/dist/vue/schema-hooks.js +64 -0
  272. package/package.json +130 -17
  273. package/dist/deploy-999q207z.js +0 -10
  274. package/dist/engine-y0724kjq.js +0 -8
  275. package/dist/import-s2b8e0ft.js +0 -11
  276. package/dist/index-a76rekgs.js +0 -67
  277. package/dist/index-c9h37r6h.js +0 -1
  278. package/dist/index-hr9qvv77.js +0 -860
  279. package/dist/index-k5b0xskw.js +0 -1
  280. package/dist/index-nzb3am4f.js +0 -80
  281. package/dist/index-wncptktd.js +0 -292
  282. package/dist/index-y6a4kj0p.js +0 -43
  283. package/dist/index-yhwjgfvj.js +0 -342
  284. package/dist/sdk-bepky0xs.js +0 -16
  285. package/dist/server-szdjx0nt.js +0 -13
  286. package/dist/sqlite-backend-0vsmc6qj.js +0 -8
  287. package/dist/tenancy-pjm32b4v.js +0 -14
@@ -1,342 +0,0 @@
1
- // @bun
2
- import {
3
- __esm
4
- } from "./index-a76rekgs.js";
5
-
6
- // src/core/store/eav-store.ts
7
- function* flatten(obj, base = "") {
8
- if (Array.isArray(obj)) {
9
- for (const v of obj) {
10
- yield* flatten(v, base);
11
- }
12
- } else if (obj && typeof obj === "object") {
13
- for (const [k, v] of Object.entries(obj)) {
14
- yield* flatten(v, base ? `${base}.${k}` : k);
15
- }
16
- } else {
17
- yield [base, obj];
18
- }
19
- }
20
- function jsonEntityFacts(entityId, root, type) {
21
- const facts = [{ e: entityId, a: "type", v: type }];
22
- for (const [a, v] of flatten(root)) {
23
- if (v === undefined || v === null)
24
- continue;
25
- if (Array.isArray(v)) {
26
- for (const el of v) {
27
- facts.push({ e: entityId, a, v: el });
28
- }
29
- } else if (typeof v === "object") {} else {
30
- facts.push({ e: entityId, a, v });
31
- }
32
- }
33
- return facts;
34
- }
35
-
36
- class EAVStore {
37
- facts = [];
38
- links = [];
39
- catalog = new Map;
40
- eavIndex = new Map;
41
- aevIndex = new Map;
42
- aveIndex = new Map;
43
- linkIndex = new Map;
44
- linkReverseIndex = new Map;
45
- linkAttrIndex = new Map;
46
- distinct = new Map;
47
- addFacts(facts) {
48
- for (let i = 0;i < facts.length; i++) {
49
- const fact = facts[i];
50
- if (fact) {
51
- if (this.hasFact(fact.e, fact.a, fact.v)) {
52
- continue;
53
- }
54
- this.facts.push(fact);
55
- this.updateIndexes(fact, this.facts.length - 1);
56
- this.updateCatalog(fact);
57
- }
58
- }
59
- }
60
- hasFact(entity, attribute, value) {
61
- const valueKey = this.valueKey(value);
62
- const indices = this.aveIndex.get(attribute)?.get(valueKey);
63
- if (!indices)
64
- return false;
65
- for (const idx of indices) {
66
- const fact = this.facts[idx];
67
- if (fact && fact.e === entity && fact.a === attribute) {
68
- return true;
69
- }
70
- }
71
- return false;
72
- }
73
- addLinks(links) {
74
- for (const link of links) {
75
- this.links.push(link);
76
- this.updateLinkIndexes(link);
77
- }
78
- }
79
- deleteFacts(factsToDelete) {
80
- for (const fact of factsToDelete) {
81
- const valueKey = this.valueKey(fact.v);
82
- const indices = this.aveIndex.get(fact.a)?.get(valueKey);
83
- if (!indices)
84
- continue;
85
- let foundIdx = -1;
86
- for (const idx of indices) {
87
- const storedFact = this.facts[idx];
88
- if (storedFact && storedFact.e === fact.e && storedFact.a === fact.a) {
89
- foundIdx = idx;
90
- break;
91
- }
92
- }
93
- if (foundIdx !== -1) {
94
- this.facts[foundIdx] = undefined;
95
- this.eavIndex.get(fact.e)?.get(fact.a)?.delete(foundIdx);
96
- this.aevIndex.get(fact.a)?.get(fact.e)?.delete(foundIdx);
97
- this.aveIndex.get(fact.a)?.get(valueKey)?.delete(foundIdx);
98
- const entry = this.catalog.get(fact.a);
99
- if (entry) {}
100
- }
101
- }
102
- }
103
- deleteLinks(linksToDelete) {
104
- for (const link of linksToDelete) {
105
- const initialLen = this.links.length;
106
- this.links = this.links.filter((l) => !(l.e1 === link.e1 && l.a === link.a && l.e2 === link.e2));
107
- if (this.links.length < initialLen) {
108
- this.linkIndex.get(link.e1)?.get(link.a)?.delete(link.e2);
109
- this.linkReverseIndex.get(link.e2)?.get(link.a)?.delete(link.e1);
110
- const attrPairs = this.linkAttrIndex.get(link.a);
111
- if (attrPairs) {
112
- for (const pair of attrPairs) {
113
- if (pair[0] === link.e1 && pair[1] === link.e2) {
114
- attrPairs.delete(pair);
115
- break;
116
- }
117
- }
118
- }
119
- }
120
- }
121
- }
122
- updateIndexes(fact, index) {
123
- if (!this.eavIndex.has(fact.e)) {
124
- this.eavIndex.set(fact.e, new Map);
125
- }
126
- if (!this.eavIndex.get(fact.e).has(fact.a)) {
127
- this.eavIndex.get(fact.e).set(fact.a, new Set);
128
- }
129
- this.eavIndex.get(fact.e).get(fact.a).add(index);
130
- if (!this.aevIndex.has(fact.a)) {
131
- this.aevIndex.set(fact.a, new Map);
132
- }
133
- if (!this.aevIndex.get(fact.a).has(fact.e)) {
134
- this.aevIndex.get(fact.a).set(fact.e, new Set);
135
- }
136
- this.aevIndex.get(fact.a).get(fact.e).add(index);
137
- if (!this.aveIndex.has(fact.a)) {
138
- this.aveIndex.set(fact.a, new Map);
139
- }
140
- const valueKey = this.valueKey(fact.v);
141
- if (!this.aveIndex.get(fact.a).has(valueKey)) {
142
- this.aveIndex.get(fact.a).set(valueKey, new Set);
143
- }
144
- this.aveIndex.get(fact.a).get(valueKey).add(index);
145
- }
146
- updateLinkIndexes(link) {
147
- if (!this.linkIndex.has(link.e1)) {
148
- this.linkIndex.set(link.e1, new Map);
149
- }
150
- const e1Attrs = this.linkIndex.get(link.e1);
151
- if (!e1Attrs.has(link.a)) {
152
- e1Attrs.set(link.a, new Set);
153
- }
154
- e1Attrs.get(link.a).add(link.e2);
155
- if (!this.linkReverseIndex.has(link.e2)) {
156
- this.linkReverseIndex.set(link.e2, new Map);
157
- }
158
- const e2Attrs = this.linkReverseIndex.get(link.e2);
159
- if (!e2Attrs.has(link.a)) {
160
- e2Attrs.set(link.a, new Set);
161
- }
162
- e2Attrs.get(link.a).add(link.e1);
163
- if (!this.linkAttrIndex.has(link.a)) {
164
- this.linkAttrIndex.set(link.a, new Set);
165
- }
166
- this.linkAttrIndex.get(link.a).add([link.e1, link.e2]);
167
- }
168
- valueKey(v) {
169
- if (v instanceof Date)
170
- return `date:${v.toISOString()}`;
171
- return `${typeof v}:${v}`;
172
- }
173
- updateCatalog(fact) {
174
- const entry = this.catalog.get(fact.a) || {
175
- attribute: fact.a,
176
- type: this.inferType(fact.v),
177
- cardinality: "one",
178
- distinctCount: 0,
179
- examples: []
180
- };
181
- const factType = this.inferType(fact.v);
182
- if (entry.type !== factType && entry.type !== "mixed") {
183
- entry.type = "mixed";
184
- }
185
- const entityAttrs = this.eavIndex.get(fact.e)?.get(fact.a);
186
- if (entityAttrs && entityAttrs.size > 1) {
187
- entry.cardinality = "many";
188
- }
189
- const k = this.valueKey(fact.v);
190
- const s = this.distinct.get(fact.a) || (this.distinct.set(fact.a, new Set), this.distinct.get(fact.a));
191
- s.add(k);
192
- entry.distinctCount = s.size;
193
- if (entry.examples.length < 5 && !entry.examples.includes(fact.v)) {
194
- entry.examples.push(fact.v);
195
- }
196
- if (typeof fact.v === "number") {
197
- entry.min = Math.min(entry.min ?? fact.v, fact.v);
198
- entry.max = Math.max(entry.max ?? fact.v, fact.v);
199
- }
200
- this.catalog.set(fact.a, entry);
201
- }
202
- inferType(v) {
203
- if (typeof v === "string")
204
- return "string";
205
- if (typeof v === "number")
206
- return "number";
207
- if (typeof v === "boolean")
208
- return "boolean";
209
- if (v instanceof Date)
210
- return "date";
211
- return "mixed";
212
- }
213
- getFactsByEntity(entity) {
214
- const indices = this.eavIndex.get(entity);
215
- if (!indices)
216
- return [];
217
- const result = [];
218
- for (const attrIndices of indices.values()) {
219
- for (const idx of attrIndices) {
220
- const fact = this.facts[idx];
221
- if (fact) {
222
- result.push(fact);
223
- }
224
- }
225
- }
226
- return result;
227
- }
228
- getFactsByAttribute(attribute) {
229
- const indices = this.aevIndex.get(attribute);
230
- if (!indices)
231
- return [];
232
- const result = [];
233
- for (const entityIndices of indices.values()) {
234
- for (const idx of entityIndices) {
235
- const fact = this.facts[idx];
236
- if (fact) {
237
- result.push(fact);
238
- }
239
- }
240
- }
241
- return result;
242
- }
243
- getFactsByValue(attribute, value) {
244
- const indices = this.aveIndex.get(attribute)?.get(this.valueKey(value));
245
- if (!indices)
246
- return [];
247
- return Array.from(indices).map((idx) => this.facts[idx]).filter((fact) => fact !== undefined);
248
- }
249
- getCatalog() {
250
- return Array.from(this.catalog.values());
251
- }
252
- getCatalogEntry(attribute) {
253
- return this.catalog.get(attribute);
254
- }
255
- getAllFacts() {
256
- return this.facts.filter((f) => f !== undefined);
257
- }
258
- getAllLinks() {
259
- return [...this.links];
260
- }
261
- getLinksByEntity(entity) {
262
- const results = [];
263
- const forwardLinks = this.linkIndex.get(entity);
264
- if (forwardLinks) {
265
- for (const [attr, targets] of forwardLinks) {
266
- for (const target of targets) {
267
- results.push({ e1: entity, a: attr, e2: target });
268
- }
269
- }
270
- }
271
- const reverseLinks = this.linkReverseIndex.get(entity);
272
- if (reverseLinks) {
273
- for (const [attr, sources] of reverseLinks) {
274
- for (const source of sources) {
275
- results.push({ e1: source, a: attr, e2: entity });
276
- }
277
- }
278
- }
279
- return results;
280
- }
281
- getLinksByAttribute(attribute) {
282
- const results = [];
283
- const links = this.linkAttrIndex.get(attribute);
284
- if (links) {
285
- for (const [e1, e2] of links) {
286
- results.push({ e1, a: attribute, e2 });
287
- }
288
- }
289
- return results;
290
- }
291
- getLinksByEntityAndAttribute(entity, attribute) {
292
- const results = [];
293
- const attrs = this.linkIndex.get(entity);
294
- if (attrs) {
295
- const targets = attrs.get(attribute);
296
- if (targets) {
297
- for (const target of targets) {
298
- results.push({ e1: entity, a: attribute, e2: target });
299
- }
300
- }
301
- }
302
- return results;
303
- }
304
- getStats() {
305
- return {
306
- totalFacts: this.facts.length,
307
- totalLinks: this.links.length,
308
- uniqueEntities: this.eavIndex.size,
309
- uniqueAttributes: this.aevIndex.size,
310
- catalogEntries: this.catalog.size
311
- };
312
- }
313
- snapshot() {
314
- return {
315
- facts: this.facts.filter((f) => f !== undefined),
316
- links: [...this.links],
317
- catalog: this.getCatalog()
318
- };
319
- }
320
- restore(snapshot) {
321
- this.facts = [];
322
- this.links = [];
323
- this.catalog.clear();
324
- this.eavIndex.clear();
325
- this.aevIndex.clear();
326
- this.aveIndex.clear();
327
- this.linkIndex.clear();
328
- this.linkReverseIndex.clear();
329
- this.linkAttrIndex.clear();
330
- this.distinct.clear();
331
- this.addFacts(snapshot.facts);
332
- this.addLinks(snapshot.links);
333
- if (snapshot.catalog) {
334
- for (const entry of snapshot.catalog) {
335
- this.catalog.set(entry.attribute, entry);
336
- }
337
- }
338
- }
339
- }
340
- var init_eav_store = () => {};
341
-
342
- export { flatten, jsonEntityFacts, EAVStore, init_eav_store };
@@ -1,16 +0,0 @@
1
- // @bun
2
- import {
3
- FetchError,
4
- TrellisDb
5
- } from "./index-wncptktd.js";
6
- import"./index-xzym9w0m.js";
7
- import"./index-7pjz3tsy.js";
8
- import"./index-4wxa8xz4.js";
9
- import"./index-yp88he8n.js";
10
- import"./index-yhwjgfvj.js";
11
- import"./index-h7zxhhhh.js";
12
- import"./index-a76rekgs.js";
13
- export {
14
- TrellisDb,
15
- FetchError
16
- };
@@ -1,13 +0,0 @@
1
- // @bun
2
- import {
3
- startServer,
4
- startServerCrossRuntime
5
- } from "./index-53f3b8p8.js";
6
- import"./index-n9f2qyh5.js";
7
- import"./index-yp88he8n.js";
8
- import"./index-yhwjgfvj.js";
9
- import"./index-a76rekgs.js";
10
- export {
11
- startServerCrossRuntime,
12
- startServer
13
- };
@@ -1,8 +0,0 @@
1
- // @bun
2
- import {
3
- SqliteKernelBackend
4
- } from "./index-h7zxhhhh.js";
5
- import"./index-a76rekgs.js";
6
- export {
7
- SqliteKernelBackend
8
- };
@@ -1,14 +0,0 @@
1
- // @bun
2
- import {
3
- DEFAULT_TENANT,
4
- TenantPool
5
- } from "./index-7pjz3tsy.js";
6
- import"./index-4wxa8xz4.js";
7
- import"./index-yp88he8n.js";
8
- import"./index-yhwjgfvj.js";
9
- import"./index-h7zxhhhh.js";
10
- import"./index-a76rekgs.js";
11
- export {
12
- TenantPool,
13
- DEFAULT_TENANT
14
- };