@alneas/eaos-server 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (360) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE +21 -0
  3. package/README.ja.md +49 -0
  4. package/README.md +46 -2
  5. package/dist/agentic/agent-jobs.d.ts +333 -0
  6. package/dist/agentic/agent-jobs.js +15 -0
  7. package/dist/agentic/agent-jobs.js.map +1 -0
  8. package/dist/agentic/agent-node.d.ts +40 -0
  9. package/dist/agentic/agent-node.js +7 -0
  10. package/dist/agentic/agent-node.js.map +1 -0
  11. package/dist/agentic/agent-runner.d.ts +33 -0
  12. package/dist/agentic/agent-runner.js +7 -0
  13. package/dist/agentic/agent-runner.js.map +1 -0
  14. package/dist/agentic/ai-broker.d.ts +169 -0
  15. package/dist/agentic/ai-broker.js +8 -0
  16. package/dist/agentic/ai-broker.js.map +1 -0
  17. package/dist/agentic/atomic-checkpointer.d.ts +137 -0
  18. package/dist/agentic/atomic-checkpointer.js +9 -0
  19. package/dist/agentic/atomic-checkpointer.js.map +1 -0
  20. package/dist/agentic/autonomous-worker.d.ts +122 -0
  21. package/dist/agentic/autonomous-worker.js +10 -0
  22. package/dist/agentic/autonomous-worker.js.map +1 -0
  23. package/dist/agentic/event-bridge.d.ts +350 -0
  24. package/dist/agentic/event-bridge.js +9 -0
  25. package/dist/agentic/event-bridge.js.map +1 -0
  26. package/dist/agentic/executor.d.ts +91 -0
  27. package/dist/agentic/executor.js +12 -0
  28. package/dist/agentic/executor.js.map +1 -0
  29. package/dist/agentic/graph-projection.d.ts +119 -0
  30. package/dist/agentic/graph-projection.js +7 -0
  31. package/dist/agentic/graph-projection.js.map +1 -0
  32. package/dist/agentic/graph.d.ts +524 -0
  33. package/dist/agentic/graph.js +7 -0
  34. package/dist/agentic/graph.js.map +1 -0
  35. package/dist/agentic/index.d.ts +28 -0
  36. package/dist/agentic/index.js +87 -0
  37. package/dist/agentic/index.js.map +1 -0
  38. package/dist/agentic/local-runner.d.ts +106 -0
  39. package/dist/agentic/local-runner.js +7 -0
  40. package/dist/agentic/local-runner.js.map +1 -0
  41. package/dist/agentic/remote-executor.d.ts +67 -0
  42. package/dist/agentic/remote-executor.js +8 -0
  43. package/dist/agentic/remote-executor.js.map +1 -0
  44. package/dist/agentic/types.d.ts +157 -0
  45. package/dist/agentic/types.js +7 -0
  46. package/dist/agentic/types.js.map +1 -0
  47. package/dist/agentic/workflow-catalog.d.ts +152 -0
  48. package/dist/agentic/workflow-catalog.js +7 -0
  49. package/dist/agentic/workflow-catalog.js.map +1 -0
  50. package/dist/agentic/workflow-compiler.d.ts +44 -0
  51. package/dist/agentic/workflow-compiler.js +8 -0
  52. package/dist/agentic/workflow-compiler.js.map +1 -0
  53. package/dist/agentic/workflow-coordinator.d.ts +170 -0
  54. package/dist/agentic/workflow-coordinator.js +8 -0
  55. package/dist/agentic/workflow-coordinator.js.map +1 -0
  56. package/dist/agentic/workflow-manager.d.ts +91 -0
  57. package/dist/agentic/workflow-manager.js +7 -0
  58. package/dist/agentic/workflow-manager.js.map +1 -0
  59. package/dist/agentic/workflow-registry.d.ts +334 -0
  60. package/dist/agentic/workflow-registry.js +7 -0
  61. package/dist/agentic/workflow-registry.js.map +1 -0
  62. package/dist/artifacts-CteHmCMI.d.ts +614 -0
  63. package/dist/auth-hooks/api-key.d.ts +75 -0
  64. package/dist/auth-hooks/api-key.js +7 -0
  65. package/dist/auth-hooks/api-key.js.map +1 -0
  66. package/dist/auth-hooks/index.d.ts +80 -0
  67. package/dist/auth-hooks/index.js +28 -0
  68. package/dist/auth-hooks/index.js.map +1 -0
  69. package/dist/browser-auth/account-memberships.d.ts +213 -0
  70. package/dist/browser-auth/account-memberships.js +13 -0
  71. package/dist/browser-auth/account-memberships.js.map +1 -0
  72. package/dist/browser-auth/index.d.ts +8 -0
  73. package/dist/browser-auth/index.js +59 -0
  74. package/dist/browser-auth/index.js.map +1 -0
  75. package/dist/browser-auth/kratos-session.d.ts +37 -0
  76. package/dist/browser-auth/kratos-session.js +7 -0
  77. package/dist/browser-auth/kratos-session.js.map +1 -0
  78. package/dist/browser-auth/platform-session.d.ts +120 -0
  79. package/dist/browser-auth/platform-session.js +7 -0
  80. package/dist/browser-auth/platform-session.js.map +1 -0
  81. package/dist/browser-auth/public-memberships.d.ts +22 -0
  82. package/dist/browser-auth/public-memberships.js +7 -0
  83. package/dist/browser-auth/public-memberships.js.map +1 -0
  84. package/dist/cache/index.d.ts +181 -0
  85. package/dist/cache/index.js +197 -0
  86. package/dist/cache/index.js.map +1 -0
  87. package/dist/chunk-32746UQZ.js +131 -0
  88. package/dist/chunk-32746UQZ.js.map +1 -0
  89. package/dist/chunk-3NLSWP2Y.js +223 -0
  90. package/dist/chunk-3NLSWP2Y.js.map +1 -0
  91. package/dist/chunk-3P4XTTQH.js +346 -0
  92. package/dist/chunk-3P4XTTQH.js.map +1 -0
  93. package/dist/chunk-3VITSHN3.js +15 -0
  94. package/dist/chunk-3VITSHN3.js.map +1 -0
  95. package/dist/chunk-46UWPEW2.js +226 -0
  96. package/dist/chunk-46UWPEW2.js.map +1 -0
  97. package/dist/chunk-4BARRLJR.js +180 -0
  98. package/dist/chunk-4BARRLJR.js.map +1 -0
  99. package/dist/chunk-4VORUFKR.js +45 -0
  100. package/dist/chunk-4VORUFKR.js.map +1 -0
  101. package/dist/chunk-55D4ERWO.js +1 -0
  102. package/dist/chunk-55D4ERWO.js.map +1 -0
  103. package/dist/chunk-5TBBZIND.js +18 -0
  104. package/dist/chunk-5TBBZIND.js.map +1 -0
  105. package/dist/chunk-5WOZWPZA.js +211 -0
  106. package/dist/chunk-5WOZWPZA.js.map +1 -0
  107. package/dist/chunk-6CBVZ6CT.js +168 -0
  108. package/dist/chunk-6CBVZ6CT.js.map +1 -0
  109. package/dist/chunk-6XZXYNJR.js +74 -0
  110. package/dist/chunk-6XZXYNJR.js.map +1 -0
  111. package/dist/chunk-753HWDSC.js +222 -0
  112. package/dist/chunk-753HWDSC.js.map +1 -0
  113. package/dist/chunk-7AHSS7SO.js +81 -0
  114. package/dist/chunk-7AHSS7SO.js.map +1 -0
  115. package/dist/chunk-7FTJN4SA.js +1 -0
  116. package/dist/chunk-7FTJN4SA.js.map +1 -0
  117. package/dist/chunk-AVDMLTPF.js +24 -0
  118. package/dist/chunk-AVDMLTPF.js.map +1 -0
  119. package/dist/chunk-BKAHUEIT.js +95 -0
  120. package/dist/chunk-BKAHUEIT.js.map +1 -0
  121. package/dist/chunk-CJ7OFEF7.js +134 -0
  122. package/dist/chunk-CJ7OFEF7.js.map +1 -0
  123. package/dist/chunk-EJKWDZIU.js +111 -0
  124. package/dist/chunk-EJKWDZIU.js.map +1 -0
  125. package/dist/chunk-F2J6IQ6I.js +247 -0
  126. package/dist/chunk-F2J6IQ6I.js.map +1 -0
  127. package/dist/chunk-F3O7CELI.js +23 -0
  128. package/dist/chunk-F3O7CELI.js.map +1 -0
  129. package/dist/chunk-F4IITPGX.js +221 -0
  130. package/dist/chunk-F4IITPGX.js.map +1 -0
  131. package/dist/chunk-FD6VC2NA.js +66 -0
  132. package/dist/chunk-FD6VC2NA.js.map +1 -0
  133. package/dist/chunk-FRRRWAHO.js +14 -0
  134. package/dist/chunk-FRRRWAHO.js.map +1 -0
  135. package/dist/chunk-HCKAGLLB.js +17 -0
  136. package/dist/chunk-HCKAGLLB.js.map +1 -0
  137. package/dist/chunk-HVC7FG6B.js +191 -0
  138. package/dist/chunk-HVC7FG6B.js.map +1 -0
  139. package/dist/chunk-HXFVOR7Z.js +496 -0
  140. package/dist/chunk-HXFVOR7Z.js.map +1 -0
  141. package/dist/chunk-IJWYS2PF.js +122 -0
  142. package/dist/chunk-IJWYS2PF.js.map +1 -0
  143. package/dist/chunk-INCHXAFK.js +1395 -0
  144. package/dist/chunk-INCHXAFK.js.map +1 -0
  145. package/dist/chunk-JT6BRGQM.js +1 -0
  146. package/dist/chunk-JT6BRGQM.js.map +1 -0
  147. package/dist/chunk-L6PMAEMB.js +115 -0
  148. package/dist/chunk-L6PMAEMB.js.map +1 -0
  149. package/dist/chunk-LOUGW6MU.js +126 -0
  150. package/dist/chunk-LOUGW6MU.js.map +1 -0
  151. package/dist/chunk-LYPZPE53.js +129 -0
  152. package/dist/chunk-LYPZPE53.js.map +1 -0
  153. package/dist/chunk-NNCCN7JP.js +186 -0
  154. package/dist/chunk-NNCCN7JP.js.map +1 -0
  155. package/dist/chunk-PBC3MZUL.js +212 -0
  156. package/dist/chunk-PBC3MZUL.js.map +1 -0
  157. package/dist/chunk-R4ADP2DC.js +20 -0
  158. package/dist/chunk-R4ADP2DC.js.map +1 -0
  159. package/dist/chunk-RHN4Y6VS.js +44 -0
  160. package/dist/chunk-RHN4Y6VS.js.map +1 -0
  161. package/dist/chunk-SDJNYPYK.js +770 -0
  162. package/dist/chunk-SDJNYPYK.js.map +1 -0
  163. package/dist/chunk-UGNTCOVR.js +28 -0
  164. package/dist/chunk-UGNTCOVR.js.map +1 -0
  165. package/dist/chunk-VC2PCK2S.js +31 -0
  166. package/dist/chunk-VC2PCK2S.js.map +1 -0
  167. package/dist/chunk-VF5YDZJC.js +305 -0
  168. package/dist/chunk-VF5YDZJC.js.map +1 -0
  169. package/dist/chunk-VISRDVTK.js +675 -0
  170. package/dist/chunk-VISRDVTK.js.map +1 -0
  171. package/dist/chunk-W6O3LVBY.js +102 -0
  172. package/dist/chunk-W6O3LVBY.js.map +1 -0
  173. package/dist/chunk-WFEAKJLR.js +47 -0
  174. package/dist/chunk-WFEAKJLR.js.map +1 -0
  175. package/dist/chunk-XIEY2OF4.js +67 -0
  176. package/dist/chunk-XIEY2OF4.js.map +1 -0
  177. package/dist/chunk-XITLHDG3.js +37 -0
  178. package/dist/chunk-XITLHDG3.js.map +1 -0
  179. package/dist/chunk-XMWPYZWZ.js +61 -0
  180. package/dist/chunk-XMWPYZWZ.js.map +1 -0
  181. package/dist/chunk-XUP6CNOM.js +34 -0
  182. package/dist/chunk-XUP6CNOM.js.map +1 -0
  183. package/dist/chunk-YABTQZDJ.js +25 -0
  184. package/dist/chunk-YABTQZDJ.js.map +1 -0
  185. package/dist/chunk-YMHVRBUU.js +199 -0
  186. package/dist/chunk-YMHVRBUU.js.map +1 -0
  187. package/dist/chunk-YMJ7BRKU.js +510 -0
  188. package/dist/chunk-YMJ7BRKU.js.map +1 -0
  189. package/dist/chunk-ZC3XWU7B.js +28 -0
  190. package/dist/chunk-ZC3XWU7B.js.map +1 -0
  191. package/dist/chunk-ZHMTD5KV.js +90 -0
  192. package/dist/chunk-ZHMTD5KV.js.map +1 -0
  193. package/dist/chunk-ZWZDLOE7.js +160 -0
  194. package/dist/chunk-ZWZDLOE7.js.map +1 -0
  195. package/dist/db-package/db/local-first-sqlite-adapter.d.ts +432 -0
  196. package/dist/db-package/db/local-first-sqlite-adapter.js +7 -0
  197. package/dist/db-package/db/local-first-sqlite-adapter.js.map +1 -0
  198. package/dist/db-package/index.d.ts +7 -0
  199. package/dist/db-package/index.js +16 -0
  200. package/dist/db-package/index.js.map +1 -0
  201. package/dist/db-package/migration/aggregator.d.ts +86 -0
  202. package/dist/db-package/migration/aggregator.js +7 -0
  203. package/dist/db-package/migration/aggregator.js.map +1 -0
  204. package/dist/db-package/migration/index.d.ts +3 -0
  205. package/dist/db-package/migration/index.js +8 -0
  206. package/dist/db-package/migration/index.js.map +1 -0
  207. package/dist/engine.d.ts +205 -0
  208. package/dist/engine.js +20 -0
  209. package/dist/engine.js.map +1 -0
  210. package/dist/entitlements/index.d.ts +313 -0
  211. package/dist/entitlements/index.js +23 -0
  212. package/dist/entitlements/index.js.map +1 -0
  213. package/dist/execution/chat.d.ts +7 -0
  214. package/dist/execution/chat.js +7 -0
  215. package/dist/execution/chat.js.map +1 -0
  216. package/dist/execution/index.d.ts +342 -0
  217. package/dist/execution/index.js +66 -0
  218. package/dist/execution/index.js.map +1 -0
  219. package/dist/execution/tool-agent.d.ts +7 -0
  220. package/dist/execution/tool-agent.js +8 -0
  221. package/dist/execution/tool-agent.js.map +1 -0
  222. package/dist/extensions/index.d.ts +172 -0
  223. package/dist/extensions/index.js +95 -0
  224. package/dist/extensions/index.js.map +1 -0
  225. package/dist/health/index.d.ts +35 -0
  226. package/dist/health/index.js +7 -0
  227. package/dist/health/index.js.map +1 -0
  228. package/dist/index.d.ts +43 -0
  229. package/dist/index.js +161 -0
  230. package/dist/index.js.map +1 -0
  231. package/dist/lifecycle/index.d.ts +133 -0
  232. package/dist/lifecycle/index.js +13 -0
  233. package/dist/lifecycle/index.js.map +1 -0
  234. package/dist/lifecycle-engine/backend-migration.d.ts +2 -0
  235. package/dist/lifecycle-engine/backend-migration.js +11 -0
  236. package/dist/lifecycle-engine/backend-migration.js.map +1 -0
  237. package/dist/lifecycle-engine/baseline.d.ts +2 -0
  238. package/dist/lifecycle-engine/baseline.js +9 -0
  239. package/dist/lifecycle-engine/baseline.js.map +1 -0
  240. package/dist/lifecycle-engine/index.d.ts +1497 -0
  241. package/dist/lifecycle-engine/index.js +41 -0
  242. package/dist/lifecycle-engine/index.js.map +1 -0
  243. package/dist/lifecycle-engine/platform/artifacts.d.ts +4 -0
  244. package/dist/lifecycle-engine/platform/artifacts.js +7 -0
  245. package/dist/lifecycle-engine/platform/artifacts.js.map +1 -0
  246. package/dist/lifecycle-engine/platform/control-plane.d.ts +12 -0
  247. package/dist/lifecycle-engine/platform/control-plane.js +2 -0
  248. package/dist/lifecycle-engine/platform/control-plane.js.map +1 -0
  249. package/dist/lifecycle-engine/platform/database-router.d.ts +118 -0
  250. package/dist/lifecycle-engine/platform/database-router.js +7 -0
  251. package/dist/lifecycle-engine/platform/database-router.js.map +1 -0
  252. package/dist/lifecycle-engine/platform/deployment-placements.d.ts +464 -0
  253. package/dist/lifecycle-engine/platform/deployment-placements.js +16 -0
  254. package/dist/lifecycle-engine/platform/deployment-placements.js.map +1 -0
  255. package/dist/lifecycle-engine/platform/deployment.d.ts +4 -0
  256. package/dist/lifecycle-engine/platform/deployment.js +17 -0
  257. package/dist/lifecycle-engine/platform/deployment.js.map +1 -0
  258. package/dist/lifecycle-engine/platform/index.d.ts +737 -0
  259. package/dist/lifecycle-engine/platform/index.js +60 -0
  260. package/dist/lifecycle-engine/platform/index.js.map +1 -0
  261. package/dist/lifecycle-engine/platform/runtime.d.ts +80 -0
  262. package/dist/lifecycle-engine/platform/runtime.js +11 -0
  263. package/dist/lifecycle-engine/platform/runtime.js.map +1 -0
  264. package/dist/lifecycle-engine/platform/site-publication.d.ts +102 -0
  265. package/dist/lifecycle-engine/platform/site-publication.js +7 -0
  266. package/dist/lifecycle-engine/platform/site-publication.js.map +1 -0
  267. package/dist/lifecycle-engine/platform/user-directory.d.ts +139 -0
  268. package/dist/lifecycle-engine/platform/user-directory.js +13 -0
  269. package/dist/lifecycle-engine/platform/user-directory.js.map +1 -0
  270. package/dist/mcp.d.ts +92 -0
  271. package/dist/mcp.js +10 -0
  272. package/dist/mcp.js.map +1 -0
  273. package/dist/middleware/auth.d.ts +118 -0
  274. package/dist/middleware/auth.js +7 -0
  275. package/dist/middleware/auth.js.map +1 -0
  276. package/dist/middleware/error-handler.d.ts +35 -0
  277. package/dist/middleware/error-handler.js +7 -0
  278. package/dist/middleware/error-handler.js.map +1 -0
  279. package/dist/middleware/module-guard.d.ts +33 -0
  280. package/dist/middleware/module-guard.js +7 -0
  281. package/dist/middleware/module-guard.js.map +1 -0
  282. package/dist/platform-admin/index.d.ts +37 -0
  283. package/dist/platform-admin/index.js +11 -0
  284. package/dist/platform-admin/index.js.map +1 -0
  285. package/dist/platform-admin/store.d.ts +346 -0
  286. package/dist/platform-admin/store.js +7 -0
  287. package/dist/platform-admin/store.js.map +1 -0
  288. package/dist/plugin-data/annotations.d.ts +6 -0
  289. package/dist/plugin-data/annotations.js +12 -0
  290. package/dist/plugin-data/annotations.js.map +1 -0
  291. package/dist/plugin-data/atomic-context.d.ts +41 -0
  292. package/dist/plugin-data/atomic-context.js +9 -0
  293. package/dist/plugin-data/atomic-context.js.map +1 -0
  294. package/dist/plugin-data/atomic.d.ts +6 -0
  295. package/dist/plugin-data/atomic.js +26 -0
  296. package/dist/plugin-data/atomic.js.map +1 -0
  297. package/dist/plugin-data/audit.d.ts +6 -0
  298. package/dist/plugin-data/audit.js +12 -0
  299. package/dist/plugin-data/audit.js.map +1 -0
  300. package/dist/plugin-data/commands.d.ts +6 -0
  301. package/dist/plugin-data/commands.js +8 -0
  302. package/dist/plugin-data/commands.js.map +1 -0
  303. package/dist/plugin-data/composite.d.ts +6 -0
  304. package/dist/plugin-data/composite.js +8 -0
  305. package/dist/plugin-data/composite.js.map +1 -0
  306. package/dist/plugin-data/delivery.d.ts +6 -0
  307. package/dist/plugin-data/delivery.js +16 -0
  308. package/dist/plugin-data/delivery.js.map +1 -0
  309. package/dist/plugin-data/index.d.ts +2798 -0
  310. package/dist/plugin-data/index.js +102 -0
  311. package/dist/plugin-data/index.js.map +1 -0
  312. package/dist/plugin-data/json-documents.d.ts +6 -0
  313. package/dist/plugin-data/json-documents.js +16 -0
  314. package/dist/plugin-data/json-documents.js.map +1 -0
  315. package/dist/plugin-data/outbox.d.ts +6 -0
  316. package/dist/plugin-data/outbox.js +16 -0
  317. package/dist/plugin-data/outbox.js.map +1 -0
  318. package/dist/plugin-data/scoped-records.d.ts +6 -0
  319. package/dist/plugin-data/scoped-records.js +10 -0
  320. package/dist/plugin-data/scoped-records.js.map +1 -0
  321. package/dist/plugin-sdk.d.ts +41 -0
  322. package/dist/plugin-sdk.js +10 -0
  323. package/dist/plugin-sdk.js.map +1 -0
  324. package/dist/sql-lifecycle/index.d.ts +138 -0
  325. package/dist/sql-lifecycle/index.js +167 -0
  326. package/dist/sql-lifecycle/index.js.map +1 -0
  327. package/dist/storage/index.d.ts +2 -0
  328. package/dist/storage/index.js +13 -0
  329. package/dist/storage/index.js.map +1 -0
  330. package/dist/storage/s3-compatible.d.ts +139 -0
  331. package/dist/storage/s3-compatible.js +11 -0
  332. package/dist/storage/s3-compatible.js.map +1 -0
  333. package/dist/tenant.d.ts +108 -0
  334. package/dist/tenant.js +9 -0
  335. package/dist/tenant.js.map +1 -0
  336. package/dist/workspace-context.d.ts +119 -0
  337. package/dist/workspace-context.js +9 -0
  338. package/dist/workspace-context.js.map +1 -0
  339. package/docs/api.md +30560 -0
  340. package/docs/db/README.md +49 -0
  341. package/docs/db/docs/api.md +1613 -0
  342. package/docs/db/docs/guide.md +47 -0
  343. package/docs/entitlements.md +60 -0
  344. package/docs/guide.md +92 -0
  345. package/docs/index.md +57 -0
  346. package/docs/ja/db/README.md +46 -0
  347. package/docs/ja/db/docs/guide.md +53 -0
  348. package/docs/ja/guide.md +46 -0
  349. package/docs/ja/lifecycle/README.md +46 -0
  350. package/docs/ja/lifecycle/docs/guide.md +45 -0
  351. package/docs/ja/storage/README.md +46 -0
  352. package/docs/ja/storage/docs/guide.md +43 -0
  353. package/docs/lifecycle/README.md +49 -0
  354. package/docs/lifecycle/docs/api.md +3770 -0
  355. package/docs/lifecycle/docs/baseline.md +50 -0
  356. package/docs/lifecycle/docs/guide.md +47 -0
  357. package/docs/storage/README.md +49 -0
  358. package/docs/storage/docs/api.md +470 -0
  359. package/docs/storage/docs/guide.md +47 -0
  360. package/package.json +354 -4
@@ -0,0 +1,432 @@
1
+ import { DataAccessAdapter, Filter, QueryOptions } from '@alneas/appkit-core/data/types';
2
+
3
+ /**
4
+ * @fileoverview Local-First SQLite DataAccessAdapter with Adaptive Sync & WAL Lock Prevention
5
+ *
6
+ * Implements @alneas/appkit-core DataAccessAdapter interface.
7
+ * - Reads/writes locally to SQLite before attempting remote delivery.
8
+ * - Configures SQLite WAL mode, NORMAL synchronous, and busy_timeout to prevent DB locking.
9
+ * - Records mutations in an outbox queue (_outbox_queue) with pre-change snapshots for attempted rollback after permanent delivery failure.
10
+ * - Tracks user access frequency (_access_frequency) to adaptively sync frequently used collections.
11
+ * - Pulls remote incremental changes from an ORA_ROWSCN-capable upstream within batch transactions.
12
+ * - Handles window focus & network online lifecycle hooks for seamless just-in-time synchronization.
13
+ *
14
+ * @module db/local-first-sqlite-adapter
15
+ */
16
+
17
+ /**
18
+ * Host SQLite operations required by {@link LocalFirstSqliteAdapter}; execution and transaction ownership belong to the host.
19
+ */
20
+ interface SqliteDriver {
21
+ /**
22
+ * Executes SQLite SQL with positional bindings.
23
+ * @param sql - SQL statement, including transaction control statements.
24
+ * @param params - Positional values for question-mark placeholders; omitted for parameterless SQL.
25
+ * @returns Driver-specific execution result, which the adapter does not inspect.
26
+ * @throws Rejects on driver/database failure; callers determine rollback handling.
27
+
28
+ * @example
29
+ * ```typescript
30
+ * import type { SqliteDriver } from "@alneas/eaos-server/db";
31
+ * export async function inspectConnectedSqlite(driver: SqliteDriver) {
32
+ * // The host opens and closes the connection; this statement changes no records.
33
+ * return await driver.execute("SELECT 1 AS ready", []);
34
+ * }
35
+ * ```
36
+ */
37
+ execute(sql: string, params?: any[]): Promise<any>;
38
+ /**
39
+ * Selects SQLite rows using positional bindings.
40
+ * @typeParam T - Row shape expected by the caller; the driver does not establish runtime validation.
41
+ * @param sql - SELECT statement.
42
+ * @param params - Positional values, or omitted for parameterless queries.
43
+ * @returns Matching rows, or an empty array.
44
+ * @throws Rejects on driver/database failure.
45
+
46
+ * @example
47
+ * ```typescript
48
+ * import type { SqliteDriver } from "@alneas/eaos-server/db";
49
+ * export async function selectConnectedSqlite(driver: SqliteDriver) {
50
+ * const rows = await driver.select<{ ready: number }>("SELECT 1 AS ready", []);
51
+ * return rows[0]?.ready; // The type argument does not perform runtime validation.
52
+ * }
53
+ * ```
54
+ */
55
+ select<T = any>(sql: string, params?: any[]): Promise<T[]>;
56
+ }
57
+ /**
58
+ * Local outbox lifecycle status; successfully synchronized rows are removed by processOutbox.
59
+ * @see LocalFirstSqliteAdapter.processOutbox.
60
+ */
61
+ type SyncStatus = 'pending' | 'syncing' | 'synced' | 'failed';
62
+ /**
63
+ * Local mutation and rollback snapshot awaiting upstream synchronization.
64
+ * @see LocalFirstSqliteAdapter.processOutbox.
65
+ */
66
+ interface OutboxItem {
67
+ /** Outbox row identifier. */
68
+ id: string;
69
+ /** Target local/upstream table. */
70
+ tableName: string;
71
+ /** Mutation record identifier. */
72
+ recordId: string;
73
+ /** INSERT, UPDATE, or DELETE operation forwarded upstream. */
74
+ operation: 'INSERT' | 'UPDATE' | 'DELETE';
75
+ /** Mutation data; update retains only the supplied changes. */
76
+ payload: Record<string, any>;
77
+ /** Optional pre-mutation row used for rollback; null for inserts or missing snapshots. */
78
+ previousState?: Record<string, any> | null;
79
+ /** Persisted synchronization state. */
80
+ status: SyncStatus;
81
+ /** Optional most recent persisted error description. */
82
+ errorMessage?: string;
83
+ /** Number of recognized transient failures recorded so far. */
84
+ retryCount: number;
85
+ /** ISO creation timestamp used for batch ordering. */
86
+ createdAt: string;
87
+ }
88
+ /**
89
+ * Permanent synchronization failure notification emitted after local rollback handling.
90
+ * @see LocalFirstSqliteAdapterOptions.onSyncError.
91
+ */
92
+ interface SyncErrorEvent {
93
+ /** Outbox item whose permanent failure caused rollback handling. */
94
+ item: OutboxItem;
95
+ /** Underlying synchronization failure. */
96
+ error: Error;
97
+ /** True when rollback handling reached the callback; it is not a remote rollback guarantee. */
98
+ rolledBack: boolean;
99
+ }
100
+ /**
101
+ * Per-table local counters used to rank adaptive synchronization candidates.
102
+ * @see LocalFirstSqliteAdapter.recordAccess.
103
+ */
104
+ interface AccessFrequencyRecord {
105
+ /** Tracked collection identifier. */
106
+ table_name: string;
107
+ /** Accumulated read count. */
108
+ read_count: number;
109
+ /** Accumulated write count. */
110
+ write_count: number;
111
+ /** ISO timestamp of the most recently recorded access. */
112
+ last_accessed_at: string;
113
+ }
114
+ /**
115
+ * Host drivers, sync behavior, and cleanup-sensitive scheduling for {@link LocalFirstSqliteAdapter}.
116
+ */
117
+ interface LocalFirstSqliteAdapterOptions {
118
+ /** SQLite driver instance */
119
+ sqlite: SqliteDriver;
120
+ /** Cloud upstream adapter (e.g. OracleOrdsAdapter / SupabaseAdapter) */
121
+ upstream: DataAccessAdapter;
122
+ /** Optional tenant_id default added only on create when neither tenant_id nor tenantId is supplied; this does not scope reads, updates, deletes, or upstream access. Host authorization remains required. */
123
+ tenantId?: string;
124
+ /** Essential master tables that are always synchronized (Tier 1) */
125
+ essentialTables?: string[];
126
+ /** Callback fired when an outbox sync fails permanently and triggers a rollback */
127
+ onSyncError?: (event: SyncErrorEvent) => void;
128
+ /** Outbox polling interval in milliseconds. Zero disables polling; other falsy values fall back to 5000. @defaultValue 5000 */
129
+ syncIntervalMs?: number;
130
+ /** Whether to immediately trigger background sync after local mutation (default: true) */
131
+ autoSyncOnMutation?: boolean;
132
+ /** Whether to attach window focus / online event listeners (default: true if in browser/tauri) */
133
+ enableLifecycleSync?: boolean;
134
+ }
135
+ /**
136
+ * Persists local mutations and an outbox, then synchronizes with a host-provided upstream adapter.
137
+ * @remarks Call initSchema before use; it creates metadata only, so provision domain tables separately. Local mutation and outbox insertion are separate writes, so failure may leave an unqueued local change. No tenant authorization is implemented: tenantId is only a create default. Serialize transaction-sensitive operations on the host driver; processOutbox excludes overlapping calls on this instance only. Call destroy to remove timers/listeners; it does not cancel in-flight work or close either driver.
138
+ * @example
139
+ * ```typescript
140
+ * import { LocalFirstSqliteAdapter, type LocalFirstSqliteAdapterOptions } from "@alneas/eaos-server/db/local-first-sqlite-adapter";
141
+ * export async function example(options: LocalFirstSqliteAdapterOptions) {
142
+ * // The host supplies an initialized domain schema and authorized upstream adapter.
143
+ * const adapter = new LocalFirstSqliteAdapter({ ...options, syncIntervalMs: 0, enableLifecycleSync: false });
144
+ * try {
145
+ * await adapter.initSchema();
146
+ * return await adapter.find("records");
147
+ * } finally { adapter.destroy(); }
148
+ * }
149
+ * ```
150
+ */
151
+ declare class LocalFirstSqliteAdapter implements DataAccessAdapter {
152
+ /** Optional create-time tenant_id fallback captured from options; not a read or mutation authorization filter. */
153
+ readonly tenantId?: string;
154
+ private sqlite;
155
+ private upstream;
156
+ private onSyncError?;
157
+ private autoSyncOnMutation;
158
+ private essentialTables;
159
+ private syncTimer;
160
+ private isSyncing;
161
+ private cleanupListeners?;
162
+ /**
163
+ * Captures drivers and starts optional outbox polling and browser lifecycle listeners.
164
+ * @param options - Host drivers and synchronization settings; see {@link LocalFirstSqliteAdapterOptions}.
165
+ * @remarks The constructor performs no schema initialization. Timers/listeners start immediately unless disabled; call destroy when the instance is no longer needed.
166
+ */
167
+ constructor(options: LocalFirstSqliteAdapterOptions);
168
+ /**
169
+ * Initializes SQLite synchronization metadata tables and attempts WAL, NORMAL, and 5000 ms busy-timeout pragmas.
170
+ * @returns No value; resolves after metadata table creation. Pragma failures are deliberately ignored.
171
+ * @throws Rejects metadata table creation failures; earlier tables may already exist.
172
+ * @example
173
+ * ```typescript
174
+ * import { LocalFirstSqliteAdapter, type LocalFirstSqliteAdapterOptions } from "@alneas/eaos-server/db/local-first-sqlite-adapter";
175
+ * export async function example(options: LocalFirstSqliteAdapterOptions) {
176
+ * // The host supplies an initialized domain schema and authorized upstream adapter.
177
+ * const adapter = new LocalFirstSqliteAdapter({ ...options, syncIntervalMs: 0, enableLifecycleSync: false });
178
+ * try {
179
+ * await adapter.initSchema();
180
+ * await adapter.initSchema();
181
+ * } finally { adapter.destroy(); }
182
+ * }
183
+ * ```
184
+ */
185
+ initSchema(): Promise<void>;
186
+ /**
187
+ * Attaches window focus & network online hooks to trigger synchronization at user activity moments.
188
+ */
189
+ private attachLifecycleListeners;
190
+ /**
191
+ * Increments a table read or write counter and records the current ISO timestamp.
192
+ * @param collection - Table name recorded as a metadata value.
193
+ * @param type - Counter to increment; read contributes weight 2 and write weight 5 in adaptive ranking.
194
+ * @returns No value; resolves after the counter upsert.
195
+ * @throws Rejects SQLite failures.
196
+ * @example
197
+ * ```typescript
198
+ * import { LocalFirstSqliteAdapter, type LocalFirstSqliteAdapterOptions } from "@alneas/eaos-server/db/local-first-sqlite-adapter";
199
+ * export async function example(options: LocalFirstSqliteAdapterOptions) {
200
+ * // The host supplies an initialized domain schema and authorized upstream adapter.
201
+ * const adapter = new LocalFirstSqliteAdapter({ ...options, syncIntervalMs: 0, enableLifecycleSync: false });
202
+ * try {
203
+ * await adapter.initSchema();
204
+ * await adapter.recordAccess("records", "read");
205
+ * } finally { adapter.destroy(); }
206
+ * }
207
+ * ```
208
+ */
209
+ recordAccess(collection: string, type: 'read' | 'write'): Promise<void>;
210
+ /**
211
+ * Pulls every essential table plus the highest weighted access-frequency tables sequentially.
212
+ * @param limit - Maximum frequency-ranked tables selected in addition to essential tables; defaults to 8 and is passed to SQLite without additional validation.
213
+ * @returns Names whose pullChanges calls completed, including tables with no new rows; failed tables are warned and omitted.
214
+ * @throws Rejects the initial frequency query failure; individual pull failures are caught.
215
+ * @example
216
+ * ```typescript
217
+ * import { LocalFirstSqliteAdapter, type LocalFirstSqliteAdapterOptions } from "@alneas/eaos-server/db/local-first-sqlite-adapter";
218
+ * export async function example(options: LocalFirstSqliteAdapterOptions) {
219
+ * // The host supplies an initialized domain schema and authorized upstream adapter.
220
+ * const adapter = new LocalFirstSqliteAdapter({ ...options, syncIntervalMs: 0, enableLifecycleSync: false });
221
+ * try {
222
+ * await adapter.initSchema();
223
+ * return await adapter.syncActiveTables(8);
224
+ * } finally { adapter.destroy(); }
225
+ * }
226
+ * ```
227
+ */
228
+ syncActiveTables(limit?: number): Promise<string[]>;
229
+ /**
230
+ * Queries local SQLite rows and schedules a best-effort read-frequency update.
231
+ * @typeParam T - Expected local row shape; no runtime schema validation is performed.
232
+ * @param collection - Local table identifier, quoted by the adapter.
233
+ * @param filter - AND-combined equality/null or $eq/$gt/$gte/$lt/$lte column conditions; other operator objects are rejected.
234
+ * @param options - Supports sort, limit, and skip; limit/skip must be nonnegative safe integers. Projection and other options are ignored.
235
+ * @returns Local rows, or an empty array; remote freshness is not implied.
236
+ * @throws Rejects unsupported filters, invalid pagination, or SQLite query failures. Access-stat failures are ignored.
237
+ * @example
238
+ * ```typescript
239
+ * import { LocalFirstSqliteAdapter, type LocalFirstSqliteAdapterOptions } from "@alneas/eaos-server/db/local-first-sqlite-adapter";
240
+ * export async function example(options: LocalFirstSqliteAdapterOptions) {
241
+ * // The host supplies an initialized domain schema and authorized upstream adapter.
242
+ * const adapter = new LocalFirstSqliteAdapter({ ...options, syncIntervalMs: 0, enableLifecycleSync: false });
243
+ * try {
244
+ * await adapter.initSchema();
245
+ * return await adapter.find("records", { active: true }, { limit: 10 });
246
+ * } finally { adapter.destroy(); }
247
+ * }
248
+ * ```
249
+ */
250
+ find<T = unknown>(collection: string, filter?: Filter, options?: QueryOptions): Promise<T[]>;
251
+ /**
252
+ * Counts local rows matching a filter without pagination.
253
+ * @param collection - Local table identifier, quoted by the adapter.
254
+ * @param filter - Same supported AND-combined conditions as find.
255
+ * @param options - Sort is retained; limit and skip are discarded. Other options are ignored.
256
+ * @returns Numeric count, or zero if the driver returns no count row.
257
+ * @throws Rejects unsupported filters or SQLite failures; access-stat failures are ignored.
258
+ * @example
259
+ * ```typescript
260
+ * import { LocalFirstSqliteAdapter, type LocalFirstSqliteAdapterOptions } from "@alneas/eaos-server/db/local-first-sqlite-adapter";
261
+ * export async function example(options: LocalFirstSqliteAdapterOptions) {
262
+ * // The host supplies an initialized domain schema and authorized upstream adapter.
263
+ * const adapter = new LocalFirstSqliteAdapter({ ...options, syncIntervalMs: 0, enableLifecycleSync: false });
264
+ * try {
265
+ * await adapter.initSchema();
266
+ * return await adapter.count("records");
267
+ * } finally { adapter.destroy(); }
268
+ * }
269
+ * ```
270
+ */
271
+ count(collection: string, filter?: Filter, options?: QueryOptions): Promise<number>;
272
+ /**
273
+ * Queries a local row by its id column.
274
+ * @typeParam T - Expected local row shape; no runtime validation is performed.
275
+ * @param collection - Local table identifier.
276
+ * @param id - ID value bound to an equality filter.
277
+ * @param options - find options with limit overridden to 1; skip, if supplied, still applies.
278
+ * @returns First matching row, or null.
279
+ * @throws Rejects invalid pagination or SQLite query failures.
280
+ * @example
281
+ * ```typescript
282
+ * import { LocalFirstSqliteAdapter, type LocalFirstSqliteAdapterOptions } from "@alneas/eaos-server/db/local-first-sqlite-adapter";
283
+ * export async function example(options: LocalFirstSqliteAdapterOptions) {
284
+ * // The host supplies an initialized domain schema and authorized upstream adapter.
285
+ * const adapter = new LocalFirstSqliteAdapter({ ...options, syncIntervalMs: 0, enableLifecycleSync: false });
286
+ * try {
287
+ * await adapter.initSchema();
288
+ * return await adapter.findOne("records", "record-1");
289
+ * } finally { adapter.destroy(); }
290
+ * }
291
+ * ```
292
+ */
293
+ findOne<T = unknown>(collection: string, id: string, options?: QueryOptions): Promise<T | null>;
294
+ /**
295
+ * Inserts a local record before separately enqueueing its upstream INSERT.
296
+ * @typeParam T - Expected returned record shape; no runtime validation is performed.
297
+ * @param collection - Provisioned local table identifier.
298
+ * @param data - Column values; a truthy id is retained, otherwise an ID is generated. Missing tenant columns may receive the configured tenantId. Object values are JSON-encoded for local SQL.
299
+ * @param _options - Accepted for DataAccessAdapter compatibility and ignored.
300
+ * @returns The input record with its chosen ID and optional tenant default, before upstream acknowledgement.
301
+ * @throws Rejects local SQL, serialization, or enqueue failure; a local insert may already have committed. Background outbox errors are ignored by this call.
302
+ * @example
303
+ * ```typescript
304
+ * import { LocalFirstSqliteAdapter, type LocalFirstSqliteAdapterOptions } from "@alneas/eaos-server/db/local-first-sqlite-adapter";
305
+ * export async function example(options: LocalFirstSqliteAdapterOptions) {
306
+ * // The host supplies an initialized domain schema and authorized upstream adapter.
307
+ * const adapter = new LocalFirstSqliteAdapter({ ...options, syncIntervalMs: 0, enableLifecycleSync: false });
308
+ * try {
309
+ * await adapter.initSchema();
310
+ * return await adapter.create("records", { title: "Example" });
311
+ * } finally { adapter.destroy(); }
312
+ * }
313
+ * ```
314
+ */
315
+ create<T = unknown>(collection: string, data: Record<string, unknown>, _options?: QueryOptions): Promise<T>;
316
+ /**
317
+ * Snapshots a local row, updates its columns, and separately enqueues an upstream UPDATE.
318
+ * @typeParam T - Expected returned merged record shape.
319
+ * @param collection - Provisioned local table identifier.
320
+ * @param id - Record ID bound in local SQL and used for upstream update.
321
+ * @param data - Updated columns; local SQL excludes id but the payload is forwarded unchanged upstream. An empty update can cause a SQLite syntax failure.
322
+ * @param _options - Accepted for DataAccessAdapter compatibility and ignored.
323
+ * @returns Snapshot merged with data and the supplied id, even if no local row existed.
324
+ * @throws Rejects snapshot, local SQL, serialization, or enqueue failures; local changes may already have committed.
325
+ * @example
326
+ * ```typescript
327
+ * import { LocalFirstSqliteAdapter, type LocalFirstSqliteAdapterOptions } from "@alneas/eaos-server/db/local-first-sqlite-adapter";
328
+ * export async function example(options: LocalFirstSqliteAdapterOptions) {
329
+ * // The host supplies an initialized domain schema and authorized upstream adapter.
330
+ * const adapter = new LocalFirstSqliteAdapter({ ...options, syncIntervalMs: 0, enableLifecycleSync: false });
331
+ * try {
332
+ * await adapter.initSchema();
333
+ * return await adapter.update("records", "record-1", { title: "Changed" });
334
+ * } finally { adapter.destroy(); }
335
+ * }
336
+ * ```
337
+ */
338
+ update<T = unknown>(collection: string, id: string, data: Record<string, unknown>, _options?: QueryOptions): Promise<T>;
339
+ /**
340
+ * Deletes a local row and separately enqueues upstream deletion with a rollback snapshot.
341
+ * @typeParam T - Expected deleted record shape.
342
+ * @param collection - Provisioned local table identifier.
343
+ * @param id - Record ID used for local and upstream deletion.
344
+ * @param _options - Accepted for DataAccessAdapter compatibility and ignored.
345
+ * @returns The previous local record, or an object containing only id when absent.
346
+ * @throws Rejects snapshot, local delete, or enqueue failures; local deletion may already have committed.
347
+ * @example
348
+ * ```typescript
349
+ * import { LocalFirstSqliteAdapter, type LocalFirstSqliteAdapterOptions } from "@alneas/eaos-server/db/local-first-sqlite-adapter";
350
+ * export async function example(options: LocalFirstSqliteAdapterOptions) {
351
+ * // The host supplies an initialized domain schema and authorized upstream adapter.
352
+ * const adapter = new LocalFirstSqliteAdapter({ ...options, syncIntervalMs: 0, enableLifecycleSync: false });
353
+ * try {
354
+ * await adapter.initSchema();
355
+ * return await adapter.delete("records", "record-1");
356
+ * } finally { adapter.destroy(); }
357
+ * }
358
+ * ```
359
+ */
360
+ delete<T = unknown>(collection: string, id: string, _options?: QueryOptions): Promise<T>;
361
+ /**
362
+ * Pulls incremental remote changes from Oracle ADB using ORA_ROWSCN cursor within a batch transaction.
363
+ *
364
+ * @param collection - Provisioned local table whose upstream supports ORA_ROWSCN filtering, ordering, and projection.
365
+ * @returns Number of remote rows upserted, or zero when no changes were returned.
366
+ * @throws Rejects upstream or local SQL failures; an opened local transaction is rolled back best-effort on upsert/cursor failure.
367
+ * @remarks Remote deletes are not discovered by this pull. No per-table synchronization lock prevents overlapping pulls or concurrent host transactions.
368
+ * @example
369
+ * ```typescript
370
+ * import { LocalFirstSqliteAdapter, type LocalFirstSqliteAdapterOptions } from "@alneas/eaos-server/db/local-first-sqlite-adapter";
371
+ * export async function example(options: LocalFirstSqliteAdapterOptions) {
372
+ * // The host supplies an initialized domain schema and authorized upstream adapter.
373
+ * const adapter = new LocalFirstSqliteAdapter({ ...options, syncIntervalMs: 0, enableLifecycleSync: false });
374
+ * try {
375
+ * await adapter.initSchema();
376
+ * return await adapter.pullChanges("records");
377
+ * } finally { adapter.destroy(); }
378
+ * }
379
+ * ```
380
+ */
381
+ pullChanges(collection: string): Promise<number>;
382
+ /**
383
+ * Background Outbox Worker:
384
+ * Processes at most 20 pending mutations in creation order, pushes upstream, and attempts rollback for non-network failures.
385
+ * @returns No value; resolves after one batch, or immediately if this instance already has a batch running.
386
+ * @throws Rejects metadata reads, malformed persisted JSON, or error-handling SQL failures. Ordinary upstream failures are recorded or rolled back rather than rejected.
387
+ * @remarks Recognized network failures return rows to pending and increment retry_count; no delay/backoff is applied here. Other failures attempt local snapshot rollback and mark failed; rollback/callback errors are logged. Remote success followed by local queue-delete failure may leave an uncertain delivery outcome. There is no cross-instance lease or deduplication.
388
+ * @example
389
+ * ```typescript
390
+ * import { LocalFirstSqliteAdapter, type LocalFirstSqliteAdapterOptions } from "@alneas/eaos-server/db/local-first-sqlite-adapter";
391
+ * export async function example(options: LocalFirstSqliteAdapterOptions) {
392
+ * // The host supplies an initialized domain schema and authorized upstream adapter.
393
+ * const adapter = new LocalFirstSqliteAdapter({ ...options, syncIntervalMs: 0, enableLifecycleSync: false });
394
+ * try {
395
+ * await adapter.initSchema();
396
+ * await adapter.processOutbox();
397
+ * } finally { adapter.destroy(); }
398
+ * }
399
+ * ```
400
+ */
401
+ processOutbox(): Promise<void>;
402
+ /**
403
+ * Rolls back a failed mutation in local SQLite using its previousState snapshot.
404
+ */
405
+ private rollbackItem;
406
+ private enqueueOutbox;
407
+ private insertLocal;
408
+ private updateLocal;
409
+ private upsertLocal;
410
+ private buildSelectQuery;
411
+ private escapeId;
412
+ /**
413
+ * Stops this instance's polling timer and removes its browser focus/online listeners.
414
+ * @returns No value; repeated calls are safe. In-flight synchronization continues and drivers remain open.
415
+ * @example
416
+ * ```typescript
417
+ * import { LocalFirstSqliteAdapter, type LocalFirstSqliteAdapterOptions } from "@alneas/eaos-server/db/local-first-sqlite-adapter";
418
+ * export async function example(options: LocalFirstSqliteAdapterOptions) {
419
+ * // The host supplies an initialized domain schema and authorized upstream adapter.
420
+ * const adapter = new LocalFirstSqliteAdapter({ ...options, syncIntervalMs: 0, enableLifecycleSync: false });
421
+ * try {
422
+ * await adapter.initSchema();
423
+ * adapter.destroy();
424
+ * } finally { adapter.destroy(); }
425
+ * }
426
+ * ```
427
+ */
428
+ destroy(): void;
429
+ }
430
+
431
+ export { LocalFirstSqliteAdapter };
432
+ export type { AccessFrequencyRecord, LocalFirstSqliteAdapterOptions, OutboxItem, SqliteDriver, SyncErrorEvent, SyncStatus };
@@ -0,0 +1,7 @@
1
+ import {
2
+ LocalFirstSqliteAdapter
3
+ } from "../../chunk-VISRDVTK.js";
4
+ export {
5
+ LocalFirstSqliteAdapter
6
+ };
7
+ //# sourceMappingURL=local-first-sqlite-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,7 @@
1
+ export * from '@alneas/eaos-core/contracts/data-contracts';
2
+ export * from '@alneas/eaos-core/migration-types';
3
+ export { MigrationAggregator, SchemaSource } from './migration/aggregator.js';
4
+ export { AccessFrequencyRecord, LocalFirstSqliteAdapter, LocalFirstSqliteAdapterOptions, OutboxItem, SqliteDriver, SyncErrorEvent, SyncStatus } from './db/local-first-sqlite-adapter.js';
5
+ export { ConnectionStats, DatabaseAdapter, TenantSessionContext } from '@alneas/eaos-core/db';
6
+ import '@alneas/eaos-core/plugin-sdk/types';
7
+ import '@alneas/appkit-core/data/types';
@@ -0,0 +1,16 @@
1
+ import "../chunk-JT6BRGQM.js";
2
+ import {
3
+ MigrationAggregator
4
+ } from "../chunk-5WOZWPZA.js";
5
+ import {
6
+ LocalFirstSqliteAdapter
7
+ } from "../chunk-VISRDVTK.js";
8
+
9
+ // src/db-package/index.ts
10
+ export * from "@alneas/eaos-core/contracts/data-contracts";
11
+ export * from "@alneas/eaos-core/migration-types";
12
+ export {
13
+ LocalFirstSqliteAdapter,
14
+ MigrationAggregator
15
+ };
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/db-package/index.ts"],"sourcesContent":["export * from '@alneas/eaos-core/contracts/data-contracts'\nexport * from '@alneas/eaos-core/migration-types'\nexport * from './migration/index'\nexport * from './db/local-first-sqlite-adapter'\nexport type { DatabaseAdapter, TenantSessionContext, ConnectionStats } from '@alneas/eaos-core/db'\n"],"mappings":";;;;;;;;;AAAA,cAAc;AACd,cAAc;","names":[]}
@@ -0,0 +1,86 @@
1
+ import { DataContract } from '@alneas/eaos-core/contracts/data-contracts';
2
+ import { PluginManifest } from '@alneas/eaos-core/plugin-sdk/types';
3
+
4
+ /**
5
+ * Legacy table-schema input collected for migration text generation.
6
+ * @see MigrationAggregator for a complete usage example.
7
+ */
8
+ interface SchemaSource {
9
+ /** Plugin ID, or data:{contractId} for resolved data contracts. */
10
+ pluginId: string;
11
+ /** Optional display label used in generated SQL comments. */
12
+ pluginName?: string;
13
+ /** Optional extension ID appended to the source identifier. */
14
+ extensionId?: string;
15
+ /** Sort order from the plugin manifest; defaults to 999 for plugin schemas. */
16
+ migrationOrder?: number;
17
+ /** Legacy tables/columns schema; canonical x-db/$defs schemas require reviewed lifecycle migrations instead. */
18
+ schemaJson: Record<string, any>;
19
+ }
20
+ /**
21
+ * Collects plugin schema sources and renders legacy PostgreSQL or Oracle DDL text.
22
+ * @remarks Generation never executes SQL. Schema identifiers, defaults, and comments are interpolated from trusted schema inputs; review generated SQL before applying it. Canonical data-contract JSON Schema requires reviewed lifecycle migrations rather than these legacy converters.
23
+ * @example
24
+ * ```typescript
25
+ * import { MigrationAggregator } from "@alneas/eaos-server/db/migration/aggregator";
26
+ * const aggregator = new MigrationAggregator([]);
27
+ * console.log(aggregator.generatePostgres([]));
28
+ * ```
29
+ */
30
+ declare class MigrationAggregator {
31
+ private plugins;
32
+ private dataContracts;
33
+ /**
34
+ * Captures plugin manifests and available data contracts for later collection.
35
+ * @param plugins - Manifests consulted on every collection call; the array is retained rather than cloned.
36
+ * @param dataContracts - Available contracts used to resolve manifest requirements; defaults to none and is retained.
37
+ */
38
+ constructor(plugins: PluginManifest[], dataContracts?: DataContract[]);
39
+ /**
40
+ * Collects resolved data contracts first, then plugin and extension schemas by migration order.
41
+ * @param resolveSchema - Called with plugin ID and optional extension ID; returns a legacy schema or null to skip it. Plugin schemas declaring data contracts skip the plugin-level callback, but extensions are still resolved.
42
+ * @returns Ordered schema sources; manifests with equal order retain their sort order and missing callback results are omitted.
43
+ * @throws Propagates contract resolution or callback errors.
44
+ * @example
45
+ * ```typescript
46
+ * import { MigrationAggregator } from "@alneas/eaos-server/db/migration/aggregator";
47
+ * const aggregator = new MigrationAggregator([]);
48
+ * console.log(aggregator.collectSchemas(() => null)); // []
49
+ * ```
50
+ */
51
+ collectSchemas(resolveSchema: (pluginId: string, extensionId?: string) => Record<string, any> | null): SchemaSource[];
52
+ /**
53
+ * Renders PostgreSQL table DDL and tenant_id row-level-security policies as text.
54
+ * @param sources - Trusted legacy schemas rendered in supplied order. Every table must declare tenant_id not explicitly nullable.
55
+ * @param dbDriver - Label included in SQL comments only; defaults to postgres and does not change dialect.
56
+ * @returns SQL text with a generated timestamp, CREATE TABLE IF NOT EXISTS, and tenant policies using app.current_tenant as UUID.
57
+ * @throws For canonical x-db/$defs schemas or missing/nullable tenant_id columns.
58
+ * @remarks The host must set app.current_tenant appropriately and review/apply SQL separately.
59
+ * @example
60
+ * ```typescript
61
+ * import { MigrationAggregator } from "@alneas/eaos-server/db/migration/aggregator";
62
+ * const aggregator = new MigrationAggregator([]);
63
+ * console.log(aggregator.generatePostgres([]));
64
+ * ```
65
+ */
66
+ generatePostgres(sources: SchemaSource[], dbDriver?: string): string;
67
+ /**
68
+ * Renders legacy Oracle table DDL as text.
69
+ * @param sources - Trusted legacy schemas rendered in supplied order; every table must declare tenant_id not explicitly nullable.
70
+ * @returns SQL text with a generated timestamp and CREATE TABLE statements; no VPD policies or default clauses are emitted by this converter.
71
+ * @throws For canonical x-db/$defs schemas or missing/nullable tenant_id columns.
72
+ * @remarks Applying SQL and enforcing Oracle tenant isolation remain host responsibilities.
73
+ * @example
74
+ * ```typescript
75
+ * import { MigrationAggregator } from "@alneas/eaos-server/db/migration/aggregator";
76
+ * const aggregator = new MigrationAggregator([]);
77
+ * console.log(aggregator.generateOracle([]));
78
+ * ```
79
+ */
80
+ generateOracle(sources: SchemaSource[]): string;
81
+ private convertJsonSchemaToPostgresSql;
82
+ private convertJsonSchemaToOracleSql;
83
+ }
84
+
85
+ export { MigrationAggregator };
86
+ export type { SchemaSource };
@@ -0,0 +1,7 @@
1
+ import {
2
+ MigrationAggregator
3
+ } from "../../chunk-5WOZWPZA.js";
4
+ export {
5
+ MigrationAggregator
6
+ };
7
+ //# sourceMappingURL=aggregator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,3 @@
1
+ export { MigrationAggregator, SchemaSource } from './aggregator.js';
2
+ import '@alneas/eaos-core/contracts/data-contracts';
3
+ import '@alneas/eaos-core/plugin-sdk/types';
@@ -0,0 +1,8 @@
1
+ import "../../chunk-JT6BRGQM.js";
2
+ import {
3
+ MigrationAggregator
4
+ } from "../../chunk-5WOZWPZA.js";
5
+ export {
6
+ MigrationAggregator
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}