@vibesdotdev/storage 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (423) hide show
  1. package/README.md +75 -0
  2. package/SPEC.md +60 -0
  3. package/dist/adapters/index.d.ts +14 -0
  4. package/dist/adapters/index.d.ts.map +1 -0
  5. package/dist/adapters/index.js +15 -0
  6. package/dist/adapters/index.js.map +1 -0
  7. package/dist/bridge/index.d.ts +3 -0
  8. package/dist/bridge/index.d.ts.map +1 -0
  9. package/dist/bridge/index.js +2 -0
  10. package/dist/bridge/index.js.map +1 -0
  11. package/dist/bridge/storage-kind-bridge.d.ts +27 -0
  12. package/dist/bridge/storage-kind-bridge.d.ts.map +1 -0
  13. package/dist/bridge/storage-kind-bridge.js +110 -0
  14. package/dist/bridge/storage-kind-bridge.js.map +1 -0
  15. package/dist/bridge/types.d.ts +45 -0
  16. package/dist/bridge/types.d.ts.map +1 -0
  17. package/dist/bridge/types.js +8 -0
  18. package/dist/bridge/types.js.map +1 -0
  19. package/dist/cli/commands/list/storage.list.cli-command.descriptor.d.ts +4 -0
  20. package/dist/cli/commands/list/storage.list.cli-command.descriptor.d.ts.map +1 -0
  21. package/dist/cli/commands/list/storage.list.cli-command.descriptor.js +18 -0
  22. package/dist/cli/commands/list/storage.list.cli-command.descriptor.js.map +1 -0
  23. package/dist/cli/commands/list/storage.list.cli-command.impl.d.ts +11 -0
  24. package/dist/cli/commands/list/storage.list.cli-command.impl.d.ts.map +1 -0
  25. package/dist/cli/commands/list/storage.list.cli-command.impl.js +48 -0
  26. package/dist/cli/commands/list/storage.list.cli-command.impl.js.map +1 -0
  27. package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.descriptor.d.ts +4 -0
  28. package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.descriptor.d.ts.map +1 -0
  29. package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.descriptor.js +26 -0
  30. package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.descriptor.js.map +1 -0
  31. package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.d.ts +13 -0
  32. package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.d.ts.map +1 -0
  33. package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.js +136 -0
  34. package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.js.map +1 -0
  35. package/dist/cli/commands/sync/push/storage.sync.push.cli-command.descriptor.d.ts +4 -0
  36. package/dist/cli/commands/sync/push/storage.sync.push.cli-command.descriptor.d.ts.map +1 -0
  37. package/dist/cli/commands/sync/push/storage.sync.push.cli-command.descriptor.js +26 -0
  38. package/dist/cli/commands/sync/push/storage.sync.push.cli-command.descriptor.js.map +1 -0
  39. package/dist/cli/commands/sync/push/storage.sync.push.cli-command.impl.d.ts +13 -0
  40. package/dist/cli/commands/sync/push/storage.sync.push.cli-command.impl.d.ts.map +1 -0
  41. package/dist/cli/commands/sync/push/storage.sync.push.cli-command.impl.js +165 -0
  42. package/dist/cli/commands/sync/push/storage.sync.push.cli-command.impl.js.map +1 -0
  43. package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.descriptor.d.ts +4 -0
  44. package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.descriptor.d.ts.map +1 -0
  45. package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.descriptor.js +20 -0
  46. package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.descriptor.js.map +1 -0
  47. package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.d.ts +12 -0
  48. package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.d.ts.map +1 -0
  49. package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.js +95 -0
  50. package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.js.map +1 -0
  51. package/dist/cli/commands/sync/status/storage.sync.status.cli-command.descriptor.d.ts +4 -0
  52. package/dist/cli/commands/sync/status/storage.sync.status.cli-command.descriptor.d.ts.map +1 -0
  53. package/dist/cli/commands/sync/status/storage.sync.status.cli-command.descriptor.js +15 -0
  54. package/dist/cli/commands/sync/status/storage.sync.status.cli-command.descriptor.js.map +1 -0
  55. package/dist/cli/commands/sync/status/storage.sync.status.cli-command.impl.d.ts +13 -0
  56. package/dist/cli/commands/sync/status/storage.sync.status.cli-command.impl.d.ts.map +1 -0
  57. package/dist/cli/commands/sync/status/storage.sync.status.cli-command.impl.js +150 -0
  58. package/dist/cli/commands/sync/status/storage.sync.status.cli-command.impl.js.map +1 -0
  59. package/dist/cli/context.consumer.d.ts +26 -0
  60. package/dist/cli/context.consumer.d.ts.map +1 -0
  61. package/dist/cli/context.consumer.js +164 -0
  62. package/dist/cli/context.consumer.js.map +1 -0
  63. package/dist/cli/storage.cli-group.descriptor.d.ts +4 -0
  64. package/dist/cli/storage.cli-group.descriptor.d.ts.map +1 -0
  65. package/dist/cli/storage.cli-group.descriptor.js +11 -0
  66. package/dist/cli/storage.cli-group.descriptor.js.map +1 -0
  67. package/dist/cli/storage.sync.cli-group.descriptor.d.ts +4 -0
  68. package/dist/cli/storage.sync.cli-group.descriptor.d.ts.map +1 -0
  69. package/dist/cli/storage.sync.cli-group.descriptor.js +12 -0
  70. package/dist/cli/storage.sync.cli-group.descriptor.js.map +1 -0
  71. package/dist/cli/types.d.ts +26 -0
  72. package/dist/cli/types.d.ts.map +1 -0
  73. package/dist/cli/types.js +11 -0
  74. package/dist/cli/types.js.map +1 -0
  75. package/dist/client/index.d.ts +10 -0
  76. package/dist/client/index.d.ts.map +1 -0
  77. package/dist/client/index.js +10 -0
  78. package/dist/client/index.js.map +1 -0
  79. package/dist/client/list-browsable-adapters.d.ts +31 -0
  80. package/dist/client/list-browsable-adapters.d.ts.map +1 -0
  81. package/dist/client/list-browsable-adapters.js +40 -0
  82. package/dist/client/list-browsable-adapters.js.map +1 -0
  83. package/dist/daemon/commands/sync.d.ts +23 -0
  84. package/dist/daemon/commands/sync.d.ts.map +1 -0
  85. package/dist/daemon/commands/sync.js +169 -0
  86. package/dist/daemon/commands/sync.js.map +1 -0
  87. package/dist/docs/adapters.docs.descriptor.d.ts +4 -0
  88. package/dist/docs/adapters.docs.descriptor.d.ts.map +1 -0
  89. package/dist/docs/adapters.docs.descriptor.js +223 -0
  90. package/dist/docs/adapters.docs.descriptor.js.map +1 -0
  91. package/dist/docs/manifests.docs.descriptor.d.ts +4 -0
  92. package/dist/docs/manifests.docs.descriptor.d.ts.map +1 -0
  93. package/dist/docs/manifests.docs.descriptor.js +316 -0
  94. package/dist/docs/manifests.docs.descriptor.js.map +1 -0
  95. package/dist/docs/records.docs.descriptor.d.ts +4 -0
  96. package/dist/docs/records.docs.descriptor.d.ts.map +1 -0
  97. package/dist/docs/records.docs.descriptor.js +269 -0
  98. package/dist/docs/records.docs.descriptor.js.map +1 -0
  99. package/dist/docs/sync.docs.descriptor.d.ts +4 -0
  100. package/dist/docs/sync.docs.descriptor.d.ts.map +1 -0
  101. package/dist/docs/sync.docs.descriptor.js +279 -0
  102. package/dist/docs/sync.docs.descriptor.js.map +1 -0
  103. package/dist/index.d.ts +27 -0
  104. package/dist/index.d.ts.map +1 -0
  105. package/dist/index.js +29 -0
  106. package/dist/index.js.map +1 -0
  107. package/dist/interfaces/adapter.d.ts +382 -0
  108. package/dist/interfaces/adapter.d.ts.map +1 -0
  109. package/dist/interfaces/adapter.js +11 -0
  110. package/dist/interfaces/adapter.js.map +1 -0
  111. package/dist/interfaces/document-store.d.ts +62 -0
  112. package/dist/interfaces/document-store.d.ts.map +1 -0
  113. package/dist/interfaces/document-store.js +8 -0
  114. package/dist/interfaces/document-store.js.map +1 -0
  115. package/dist/interfaces/index.d.ts +17 -0
  116. package/dist/interfaces/index.d.ts.map +1 -0
  117. package/dist/interfaces/index.js +24 -0
  118. package/dist/interfaces/index.js.map +1 -0
  119. package/dist/interfaces/key-value.d.ts +95 -0
  120. package/dist/interfaces/key-value.d.ts.map +1 -0
  121. package/dist/interfaces/key-value.js +8 -0
  122. package/dist/interfaces/key-value.js.map +1 -0
  123. package/dist/interfaces/query-builder.d.ts +31 -0
  124. package/dist/interfaces/query-builder.d.ts.map +1 -0
  125. package/dist/interfaces/query-builder.js +11 -0
  126. package/dist/interfaces/query-builder.js.map +1 -0
  127. package/dist/interfaces/record/index.d.ts +7 -0
  128. package/dist/interfaces/record/index.d.ts.map +1 -0
  129. package/dist/interfaces/record/index.js +7 -0
  130. package/dist/interfaces/record/index.js.map +1 -0
  131. package/dist/interfaces/record/interface.d.ts +593 -0
  132. package/dist/interfaces/record/interface.d.ts.map +1 -0
  133. package/dist/interfaces/record/interface.js +49 -0
  134. package/dist/interfaces/record/interface.js.map +1 -0
  135. package/dist/interfaces/repository.d.ts +262 -0
  136. package/dist/interfaces/repository.d.ts.map +1 -0
  137. package/dist/interfaces/repository.js +8 -0
  138. package/dist/interfaces/repository.js.map +1 -0
  139. package/dist/interfaces/schema/index.d.ts +8 -0
  140. package/dist/interfaces/schema/index.d.ts.map +1 -0
  141. package/dist/interfaces/schema/index.js +10 -0
  142. package/dist/interfaces/schema/index.js.map +1 -0
  143. package/dist/interfaces/schema/schema-interface.d.ts +516 -0
  144. package/dist/interfaces/schema/schema-interface.d.ts.map +1 -0
  145. package/dist/interfaces/schema/schema-interface.js +31 -0
  146. package/dist/interfaces/schema/schema-interface.js.map +1 -0
  147. package/dist/interfaces/schema/table-interface.d.ts +250 -0
  148. package/dist/interfaces/schema/table-interface.d.ts.map +1 -0
  149. package/dist/interfaces/schema/table-interface.js +31 -0
  150. package/dist/interfaces/schema/table-interface.js.map +1 -0
  151. package/dist/interfaces/storage-consumer-fs.d.ts +40 -0
  152. package/dist/interfaces/storage-consumer-fs.d.ts.map +1 -0
  153. package/dist/interfaces/storage-consumer-fs.js +42 -0
  154. package/dist/interfaces/storage-consumer-fs.js.map +1 -0
  155. package/dist/manifest/base.d.ts +187 -0
  156. package/dist/manifest/base.d.ts.map +1 -0
  157. package/dist/manifest/base.js +516 -0
  158. package/dist/manifest/base.js.map +1 -0
  159. package/dist/manifest/cloud-sync.consumer.d.ts +7 -0
  160. package/dist/manifest/cloud-sync.consumer.d.ts.map +1 -0
  161. package/dist/manifest/cloud-sync.consumer.js +82 -0
  162. package/dist/manifest/cloud-sync.consumer.js.map +1 -0
  163. package/dist/manifest/index.d.ts +7 -0
  164. package/dist/manifest/index.d.ts.map +1 -0
  165. package/dist/manifest/index.js +7 -0
  166. package/dist/manifest/index.js.map +1 -0
  167. package/dist/manifest/source-policy.d.ts +8 -0
  168. package/dist/manifest/source-policy.d.ts.map +1 -0
  169. package/dist/manifest/source-policy.js +62 -0
  170. package/dist/manifest/source-policy.js.map +1 -0
  171. package/dist/paths.d.ts +6 -0
  172. package/dist/paths.d.ts.map +1 -0
  173. package/dist/paths.js +152 -0
  174. package/dist/paths.js.map +1 -0
  175. package/dist/policy/context.d.ts +9 -0
  176. package/dist/policy/context.d.ts.map +1 -0
  177. package/dist/policy/context.js +29 -0
  178. package/dist/policy/context.js.map +1 -0
  179. package/dist/policy/index.d.ts +4 -0
  180. package/dist/policy/index.d.ts.map +1 -0
  181. package/dist/policy/index.js +4 -0
  182. package/dist/policy/index.js.map +1 -0
  183. package/dist/policy/overrides.d.ts +40 -0
  184. package/dist/policy/overrides.d.ts.map +1 -0
  185. package/dist/policy/overrides.js +37 -0
  186. package/dist/policy/overrides.js.map +1 -0
  187. package/dist/policy/persistence.d.ts +38 -0
  188. package/dist/policy/persistence.d.ts.map +1 -0
  189. package/dist/policy/persistence.js +65 -0
  190. package/dist/policy/persistence.js.map +1 -0
  191. package/dist/policy/types.d.ts +21 -0
  192. package/dist/policy/types.d.ts.map +1 -0
  193. package/dist/policy/types.js +7 -0
  194. package/dist/policy/types.js.map +1 -0
  195. package/dist/record/base.d.ts +186 -0
  196. package/dist/record/base.d.ts.map +1 -0
  197. package/dist/record/base.js +1437 -0
  198. package/dist/record/base.js.map +1 -0
  199. package/dist/record/events.d.ts +71 -0
  200. package/dist/record/events.d.ts.map +1 -0
  201. package/dist/record/events.js +52 -0
  202. package/dist/record/events.js.map +1 -0
  203. package/dist/record/extensions.d.ts +51 -0
  204. package/dist/record/extensions.d.ts.map +1 -0
  205. package/dist/record/extensions.js +222 -0
  206. package/dist/record/extensions.js.map +1 -0
  207. package/dist/record/index.d.ts +7 -0
  208. package/dist/record/index.d.ts.map +1 -0
  209. package/dist/record/index.js +7 -0
  210. package/dist/record/index.js.map +1 -0
  211. package/dist/resolver/storage-backed-resolver.d.ts +23 -0
  212. package/dist/resolver/storage-backed-resolver.d.ts.map +1 -0
  213. package/dist/resolver/storage-backed-resolver.js +187 -0
  214. package/dist/resolver/storage-backed-resolver.js.map +1 -0
  215. package/dist/schemas/adapter-descriptor.d.ts +108 -0
  216. package/dist/schemas/adapter-descriptor.d.ts.map +1 -0
  217. package/dist/schemas/adapter-descriptor.js +101 -0
  218. package/dist/schemas/adapter-descriptor.js.map +1 -0
  219. package/dist/schemas/index.d.ts +14 -0
  220. package/dist/schemas/index.d.ts.map +1 -0
  221. package/dist/schemas/index.js +12 -0
  222. package/dist/schemas/index.js.map +1 -0
  223. package/dist/schemas/manifest-descriptor.d.ts +110 -0
  224. package/dist/schemas/manifest-descriptor.d.ts.map +1 -0
  225. package/dist/schemas/manifest-descriptor.js +114 -0
  226. package/dist/schemas/manifest-descriptor.js.map +1 -0
  227. package/dist/schemas/record/descriptor.d.ts +570 -0
  228. package/dist/schemas/record/descriptor.d.ts.map +1 -0
  229. package/dist/schemas/record/descriptor.js +389 -0
  230. package/dist/schemas/record/descriptor.js.map +1 -0
  231. package/dist/schemas/record/index.d.ts +8 -0
  232. package/dist/schemas/record/index.d.ts.map +1 -0
  233. package/dist/schemas/record/index.js +7 -0
  234. package/dist/schemas/record/index.js.map +1 -0
  235. package/dist/schemas/record/relation.d.ts +36 -0
  236. package/dist/schemas/record/relation.d.ts.map +1 -0
  237. package/dist/schemas/record/relation.js +37 -0
  238. package/dist/schemas/record/relation.js.map +1 -0
  239. package/dist/schemas/schema/descriptor.d.ts +231 -0
  240. package/dist/schemas/schema/descriptor.d.ts.map +1 -0
  241. package/dist/schemas/schema/descriptor.js +205 -0
  242. package/dist/schemas/schema/descriptor.js.map +1 -0
  243. package/dist/schemas/schema/index.d.ts +7 -0
  244. package/dist/schemas/schema/index.d.ts.map +1 -0
  245. package/dist/schemas/schema/index.js +7 -0
  246. package/dist/schemas/schema/index.js.map +1 -0
  247. package/dist/schemas/sync-bridge-descriptor.d.ts +124 -0
  248. package/dist/schemas/sync-bridge-descriptor.d.ts.map +1 -0
  249. package/dist/schemas/sync-bridge-descriptor.js +67 -0
  250. package/dist/schemas/sync-bridge-descriptor.js.map +1 -0
  251. package/dist/server/manifest-route.d.ts +92 -0
  252. package/dist/server/manifest-route.d.ts.map +1 -0
  253. package/dist/server/manifest-route.js +226 -0
  254. package/dist/server/manifest-route.js.map +1 -0
  255. package/dist/storage-policy.context.descriptor.d.ts +16 -0
  256. package/dist/storage-policy.context.descriptor.d.ts.map +1 -0
  257. package/dist/storage-policy.context.descriptor.js +16 -0
  258. package/dist/storage-policy.context.descriptor.js.map +1 -0
  259. package/dist/storage-policy.context.server.d.ts +14 -0
  260. package/dist/storage-policy.context.server.d.ts.map +1 -0
  261. package/dist/storage-policy.context.server.js +27 -0
  262. package/dist/storage-policy.context.server.js.map +1 -0
  263. package/dist/storage.plugin.d.ts +38 -0
  264. package/dist/storage.plugin.d.ts.map +1 -0
  265. package/dist/storage.plugin.js +204 -0
  266. package/dist/storage.plugin.js.map +1 -0
  267. package/dist/sync/cloud-pull.d.ts +15 -0
  268. package/dist/sync/cloud-pull.d.ts.map +1 -0
  269. package/dist/sync/cloud-pull.js +130 -0
  270. package/dist/sync/cloud-pull.js.map +1 -0
  271. package/dist/sync/cloud-record-crud-config.d.ts +19 -0
  272. package/dist/sync/cloud-record-crud-config.d.ts.map +1 -0
  273. package/dist/sync/cloud-record-crud-config.js +22 -0
  274. package/dist/sync/cloud-record-crud-config.js.map +1 -0
  275. package/dist/sync/record-sync-bridge.d.ts +5 -0
  276. package/dist/sync/record-sync-bridge.d.ts.map +1 -0
  277. package/dist/sync/record-sync-bridge.js +121 -0
  278. package/dist/sync/record-sync-bridge.js.map +1 -0
  279. package/dist/sync/resolve-sync-target.d.ts +23 -0
  280. package/dist/sync/resolve-sync-target.d.ts.map +1 -0
  281. package/dist/sync/resolve-sync-target.js +45 -0
  282. package/dist/sync/resolve-sync-target.js.map +1 -0
  283. package/dist/sync/schemas/cloud-pull.d.ts +25 -0
  284. package/dist/sync/schemas/cloud-pull.d.ts.map +1 -0
  285. package/dist/sync/schemas/cloud-pull.js +7 -0
  286. package/dist/sync/schemas/cloud-pull.js.map +1 -0
  287. package/dist/sync/schemas/index.d.ts +9 -0
  288. package/dist/sync/schemas/index.d.ts.map +1 -0
  289. package/dist/sync/schemas/index.js +9 -0
  290. package/dist/sync/schemas/index.js.map +1 -0
  291. package/dist/sync/schemas/sync-helpers.d.ts +17 -0
  292. package/dist/sync/schemas/sync-helpers.d.ts.map +1 -0
  293. package/dist/sync/schemas/sync-helpers.js +7 -0
  294. package/dist/sync/schemas/sync-helpers.js.map +1 -0
  295. package/dist/sync/schemas/sync-state.d.ts +65 -0
  296. package/dist/sync/schemas/sync-state.d.ts.map +1 -0
  297. package/dist/sync/schemas/sync-state.js +32 -0
  298. package/dist/sync/schemas/sync-state.js.map +1 -0
  299. package/dist/sync/sync-bridge.d.ts +80 -0
  300. package/dist/sync/sync-bridge.d.ts.map +1 -0
  301. package/dist/sync/sync-bridge.js +617 -0
  302. package/dist/sync/sync-bridge.js.map +1 -0
  303. package/dist/sync/sync-manifest.d.ts +20 -0
  304. package/dist/sync/sync-manifest.d.ts.map +1 -0
  305. package/dist/sync/sync-manifest.js +140 -0
  306. package/dist/sync/sync-manifest.js.map +1 -0
  307. package/dist/sync/sync-state.consumer.d.ts +23 -0
  308. package/dist/sync/sync-state.consumer.d.ts.map +1 -0
  309. package/dist/sync/sync-state.consumer.js +111 -0
  310. package/dist/sync/sync-state.consumer.js.map +1 -0
  311. package/dist/transform/index.d.ts +75 -0
  312. package/dist/transform/index.d.ts.map +1 -0
  313. package/dist/transform/index.js +81 -0
  314. package/dist/transform/index.js.map +1 -0
  315. package/dist/transform/transform-descriptor.d.ts +51 -0
  316. package/dist/transform/transform-descriptor.d.ts.map +1 -0
  317. package/dist/transform/transform-descriptor.js +30 -0
  318. package/dist/transform/transform-descriptor.js.map +1 -0
  319. package/dist/tui/storage-explorer.descriptor.d.ts +14 -0
  320. package/dist/tui/storage-explorer.descriptor.d.ts.map +1 -0
  321. package/dist/tui/storage-explorer.descriptor.js +29 -0
  322. package/dist/tui/storage-explorer.descriptor.js.map +1 -0
  323. package/dist/tui/storage-explorer.impl.consumer.d.ts +11 -0
  324. package/dist/tui/storage-explorer.impl.consumer.d.ts.map +1 -0
  325. package/dist/tui/storage-explorer.impl.consumer.js +13 -0
  326. package/dist/tui/storage-explorer.impl.consumer.js.map +1 -0
  327. package/dist/tui/storage-open.descriptor.d.ts +14 -0
  328. package/dist/tui/storage-open.descriptor.d.ts.map +1 -0
  329. package/dist/tui/storage-open.descriptor.js +28 -0
  330. package/dist/tui/storage-open.descriptor.js.map +1 -0
  331. package/dist/tui/storage-open.impl.consumer.d.ts +11 -0
  332. package/dist/tui/storage-open.impl.consumer.d.ts.map +1 -0
  333. package/dist/tui/storage-open.impl.consumer.js +13 -0
  334. package/dist/tui/storage-open.impl.consumer.js.map +1 -0
  335. package/dist/utils/error-context.d.ts +2 -0
  336. package/dist/utils/error-context.d.ts.map +1 -0
  337. package/dist/utils/error-context.js +17 -0
  338. package/dist/utils/error-context.js.map +1 -0
  339. package/package.json +241 -0
  340. package/src/adapters/index.ts +13 -0
  341. package/src/bridge/index.ts +2 -0
  342. package/src/bridge/storage-kind-bridge.ts +131 -0
  343. package/src/bridge/types.ts +46 -0
  344. package/src/cli/commands/list/storage.list.cli-command.descriptor.ts +20 -0
  345. package/src/cli/commands/list/storage.list.cli-command.impl.ts +72 -0
  346. package/src/cli/commands/sync/pull/storage.sync.pull.cli-command.descriptor.ts +28 -0
  347. package/src/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.ts +171 -0
  348. package/src/cli/commands/sync/push/storage.sync.push.cli-command.descriptor.ts +28 -0
  349. package/src/cli/commands/sync/push/storage.sync.push.cli-command.impl.ts +213 -0
  350. package/src/cli/commands/sync/resolve/storage.sync.resolve.cli-command.descriptor.ts +22 -0
  351. package/src/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.ts +129 -0
  352. package/src/cli/commands/sync/status/storage.sync.status.cli-command.descriptor.ts +17 -0
  353. package/src/cli/commands/sync/status/storage.sync.status.cli-command.impl.ts +192 -0
  354. package/src/cli/context.consumer.ts +195 -0
  355. package/src/cli/storage.cli-group.descriptor.ts +13 -0
  356. package/src/cli/storage.sync.cli-group.descriptor.ts +14 -0
  357. package/src/cli/types.ts +25 -0
  358. package/src/client/index.ts +10 -0
  359. package/src/client/list-browsable-adapters.ts +42 -0
  360. package/src/daemon/commands/sync.ts +225 -0
  361. package/src/docs/adapters.docs.descriptor.ts +225 -0
  362. package/src/docs/manifests.docs.descriptor.ts +318 -0
  363. package/src/docs/records.docs.descriptor.ts +271 -0
  364. package/src/docs/sync.docs.descriptor.ts +281 -0
  365. package/src/index.ts +109 -0
  366. package/src/interfaces/adapter.ts +451 -0
  367. package/src/interfaces/document-store.ts +74 -0
  368. package/src/interfaces/index.ts +117 -0
  369. package/src/interfaces/key-value.ts +112 -0
  370. package/src/interfaces/query-builder.ts +31 -0
  371. package/src/interfaces/record/index.ts +58 -0
  372. package/src/interfaces/record/interface.ts +723 -0
  373. package/src/interfaces/repository.ts +300 -0
  374. package/src/interfaces/schema/index.ts +37 -0
  375. package/src/interfaces/schema/schema-interface.ts +586 -0
  376. package/src/interfaces/schema/table-interface.ts +314 -0
  377. package/src/interfaces/storage-consumer-fs.ts +66 -0
  378. package/src/manifest/base.ts +594 -0
  379. package/src/manifest/cloud-sync.consumer.ts +120 -0
  380. package/src/manifest/index.ts +7 -0
  381. package/src/manifest/source-policy.ts +74 -0
  382. package/src/paths.ts +171 -0
  383. package/src/policy/context.ts +30 -0
  384. package/src/policy/index.ts +20 -0
  385. package/src/policy/overrides.ts +46 -0
  386. package/src/policy/persistence.ts +117 -0
  387. package/src/policy/types.ts +28 -0
  388. package/src/record/base.ts +1872 -0
  389. package/src/record/events.ts +56 -0
  390. package/src/record/extensions.ts +308 -0
  391. package/src/record/index.ts +7 -0
  392. package/src/resolver/storage-backed-resolver.ts +255 -0
  393. package/src/schemas/adapter-descriptor.ts +128 -0
  394. package/src/schemas/index.ts +104 -0
  395. package/src/schemas/manifest-descriptor.ts +143 -0
  396. package/src/schemas/record/descriptor.ts +621 -0
  397. package/src/schemas/record/index.ts +60 -0
  398. package/src/schemas/record/relation.ts +49 -0
  399. package/src/schemas/schema/descriptor.ts +278 -0
  400. package/src/schemas/schema/index.ts +14 -0
  401. package/src/schemas/sync-bridge-descriptor.ts +143 -0
  402. package/src/server/manifest-route.ts +319 -0
  403. package/src/storage-policy.context.descriptor.ts +17 -0
  404. package/src/storage-policy.context.server.ts +34 -0
  405. package/src/storage.plugin.ts +264 -0
  406. package/src/sync/cloud-pull.ts +202 -0
  407. package/src/sync/cloud-record-crud-config.ts +41 -0
  408. package/src/sync/record-sync-bridge.ts +183 -0
  409. package/src/sync/resolve-sync-target.ts +57 -0
  410. package/src/sync/schemas/cloud-pull.ts +26 -0
  411. package/src/sync/schemas/index.ts +18 -0
  412. package/src/sync/schemas/sync-helpers.ts +18 -0
  413. package/src/sync/schemas/sync-state.ts +41 -0
  414. package/src/sync/sync-bridge.ts +763 -0
  415. package/src/sync/sync-manifest.ts +212 -0
  416. package/src/sync/sync-state.consumer.ts +144 -0
  417. package/src/transform/index.ts +130 -0
  418. package/src/transform/transform-descriptor.ts +53 -0
  419. package/src/tui/storage-explorer.descriptor.ts +32 -0
  420. package/src/tui/storage-explorer.impl.consumer.ts +14 -0
  421. package/src/tui/storage-open.descriptor.ts +31 -0
  422. package/src/tui/storage-open.impl.consumer.ts +14 -0
  423. package/src/utils/error-context.ts +19 -0
@@ -0,0 +1,723 @@
1
+ /**
2
+ * Storage Record Interface
3
+ *
4
+ * Defines the interface for CRUD operations on a single table.
5
+ * This is what gets resolved when you query for a storage/record descriptor.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const todos = await runtime
10
+ * .query('storage/record')
11
+ * .withId('session.todos')
12
+ * .resolve();
13
+ *
14
+ * // Create
15
+ * const todo = await todos.create({
16
+ * sessionId: 'session-123',
17
+ * title: 'Implement storage',
18
+ * status: 'in_progress'
19
+ * });
20
+ *
21
+ * // Get
22
+ * const todo = await todos.get('todo-123');
23
+ *
24
+ * // List with filters
25
+ * const todos = await todos.list({
26
+ * where: { sessionId: 'session-123', status: 'pending' },
27
+ * include: { session: true },
28
+ * orderBy: { createdAt: 'desc' },
29
+ * limit: 50
30
+ * });
31
+ *
32
+ * // Full-text search
33
+ * const results = await todos.search('implement storage', {
34
+ * where: { sessionId: 'session-123' },
35
+ * highlight: true
36
+ * });
37
+ *
38
+ * // Get todo tree
39
+ * const tree = await todos.getTree({ where: { sessionId: 'session-123' } });
40
+ *
41
+ * // Update
42
+ * await todos.update('todo-123', { status: 'completed' });
43
+ *
44
+ * // Delete
45
+ * await todos.delete('todo-123');
46
+ * ```
47
+ */
48
+
49
+ import type { z } from 'zod/v4';
50
+ import type { StorageRelation } from '../../schemas/record/relation';
51
+
52
+ // QUERY TYPES
53
+
54
+ /**
55
+ * Filter conditions for queries
56
+ */
57
+ export type WhereFilter<T> = {
58
+ [P in keyof T]?:
59
+ | T[P]
60
+ | {
61
+ eq?: T[P];
62
+ ne?: T[P];
63
+ gt?: T[P];
64
+ gte?: T[P];
65
+ lt?: T[P];
66
+ lte?: T[P];
67
+ in?: T[P][];
68
+ notIn?: T[P][];
69
+ like?: string;
70
+ ilike?: string;
71
+ contains?: string;
72
+ startsWith?: string;
73
+ endsWith?: string;
74
+ isNull?: boolean;
75
+ isNotNull?: boolean;
76
+ between?: [T[P], T[P]];
77
+ };
78
+ };
79
+
80
+ /**
81
+ * Order by specification
82
+ */
83
+ export type OrderBy<T> =
84
+ | {
85
+ [P in keyof T]?: 'asc' | 'desc';
86
+ }
87
+ | {
88
+ field: keyof T;
89
+ direction: 'asc' | 'desc';
90
+ }[];
91
+
92
+ /**
93
+ * Relation include specification
94
+ */
95
+ export type IncludeRelations<R extends string = string> =
96
+ | R
97
+ | R[]
98
+ | { [K in R]?: boolean | IncludeRelations };
99
+
100
+ /**
101
+ * Pagination options
102
+ */
103
+ export interface PaginationOptions {
104
+ /** Number of items to return */
105
+ limit?: number;
106
+ /** Number of items to skip */
107
+ offset?: number;
108
+ /** Cursor for cursor-based pagination */
109
+ cursor?: string;
110
+ /** Cursor field (default: primaryKey) */
111
+ cursorField?: string;
112
+ }
113
+
114
+ /**
115
+ * Query options for list operations
116
+ */
117
+ export interface QueryOptions<T, R extends string = string> extends PaginationOptions {
118
+ /** Filter conditions */
119
+ where?: WhereFilter<T>;
120
+ /** Relations to include */
121
+ include?: IncludeRelations<R>;
122
+ /** Order by fields */
123
+ orderBy?: OrderBy<T>;
124
+ /** Fields to select */
125
+ select?: (keyof T)[];
126
+ /** Whether to include soft-deleted records */
127
+ includeDeleted?: boolean;
128
+ /** Distinct fields */
129
+ distinct?: keyof T | (keyof T)[];
130
+ /** Group by fields */
131
+ groupBy?: keyof T | (keyof T)[];
132
+ /** Having conditions (for groupBy) */
133
+ having?: Record<string, unknown>;
134
+ /** Include computed fields in results */
135
+ includeComputed?: (keyof T)[] | boolean;
136
+ }
137
+
138
+ /**
139
+ * Query result with pagination metadata
140
+ */
141
+ export interface QueryResult<T> {
142
+ /** Result items */
143
+ items: T[];
144
+ /** Total count (without pagination) */
145
+ total?: number;
146
+ /** Whether there are more items */
147
+ hasMore?: boolean;
148
+ /** Next cursor (for cursor-based pagination) */
149
+ nextCursor?: string;
150
+ /** Previous cursor (for cursor-based pagination) */
151
+ prevCursor?: string;
152
+ }
153
+
154
+ // SEARCH TYPES (FTS)
155
+
156
+ /**
157
+ * Full-text search options
158
+ */
159
+ export interface SearchOptions<T, R extends string = string> extends QueryOptions<T, R> {
160
+ /** Highlight matches in results */
161
+ highlight?: boolean;
162
+ /** Fields to search (default: all fts fields) */
163
+ fields?: (keyof T)[];
164
+ /** Rank by relevance score */
165
+ rankByRelevance?: boolean;
166
+ /** Minimum relevance score (0-1) */
167
+ minScore?: number;
168
+ /** Highlight tag prefix (default: <mark>) */
169
+ highlightPrefix?: string;
170
+ /** Highlight tag suffix (default: </mark>) */
171
+ highlightSuffix?: string;
172
+ }
173
+
174
+ /**
175
+ * Search result with relevance score
176
+ */
177
+ export interface SearchResult<T> extends QueryResult<T> {
178
+ /** Relevance scores per item */
179
+ scores?: number[];
180
+ /** Highlighted snippets per item */
181
+ highlights?: Map<string, string[]>;
182
+ }
183
+
184
+ // HIERARCHY TYPES (Recursive CTEs)
185
+
186
+ /**
187
+ * Tree node for hierarchical data
188
+ */
189
+ export interface TreeNode<T> {
190
+ /** The record data */
191
+ record: T;
192
+ /** Child nodes */
193
+ children: TreeNode<T>[];
194
+ /** Depth in tree (0 = root) */
195
+ depth: number;
196
+ /** Path from root (array of IDs) */
197
+ path?: string[];
198
+ }
199
+
200
+ /**
201
+ * Hierarchy query options
202
+ */
203
+ export interface HierarchyOptions<T, R extends string = string> extends QueryOptions<T, R> {
204
+ /** Maximum depth to traverse (default: unlimited) */
205
+ maxDepth?: number;
206
+ /** Include depth in results */
207
+ includeDepth?: boolean;
208
+ /** Include path from root */
209
+ includePath?: boolean;
210
+ }
211
+
212
+ // CREATE TYPES
213
+
214
+ /**
215
+ * Create input (excludes auto-managed fields)
216
+ */
217
+ export type CreateInput<T> = Omit<T, 'id' | 'createdAt' | 'updatedAt'> & {
218
+ /** Override auto-generated ID */
219
+ id?: string;
220
+ /** Override auto-generated createdAt */
221
+ createdAt?: string | Date;
222
+ /** Override auto-generated updatedAt */
223
+ updatedAt?: string | Date;
224
+ /** Override deletedAt when importing tombstones */
225
+ deletedAt?: string | Date | null;
226
+ };
227
+
228
+ /**
229
+ * Create many options
230
+ */
231
+ export interface CreateManyOptions {
232
+ /** Skip duplicate IDs */
233
+ skipDuplicates?: boolean;
234
+ /** Batch size for bulk insert */
235
+ batchSize?: number;
236
+ }
237
+
238
+ // UPDATE TYPES
239
+
240
+ /**
241
+ * Update input (partial with conditions)
242
+ */
243
+ export type UpdateInput<T> = Partial<Omit<T, 'id' | 'createdAt'>>;
244
+
245
+ /**
246
+ * Update options
247
+ */
248
+ export interface UpdateOptions {
249
+ /** Update only if conditions match */
250
+ where?: Record<string, unknown>;
251
+ /** Increment fields */
252
+ increment?: Record<string, number>;
253
+ /** Decrement fields */
254
+ decrement?: Record<string, number>;
255
+ /** Set fields to null */
256
+ unset?: string[];
257
+ /** Push to array fields */
258
+ push?: Record<string, unknown | unknown[]>;
259
+ /** Pull from array fields */
260
+ pull?: Record<string, unknown | unknown[]>;
261
+ }
262
+
263
+ /**
264
+ * Update result
265
+ */
266
+ export interface UpdateResult {
267
+ /** Number of records updated */
268
+ count: number;
269
+ /** Whether any records were updated */
270
+ success: boolean;
271
+ }
272
+
273
+ // DELETE TYPES
274
+
275
+ /**
276
+ * Delete options
277
+ */
278
+ export interface DeleteOptions {
279
+ /** Force delete (even with soft delete enabled) */
280
+ force?: boolean;
281
+ /** Delete only if conditions match */
282
+ where?: Record<string, unknown>;
283
+ }
284
+
285
+ /**
286
+ * Delete result
287
+ */
288
+ export interface DeleteResult {
289
+ /** Number of records deleted */
290
+ count: number;
291
+ /** Whether any records were deleted */
292
+ success: boolean;
293
+ }
294
+
295
+ // RELATION TYPES
296
+
297
+ /**
298
+ * Loaded relation data
299
+ */
300
+ export type LoadedRelation<T, R extends StorageRelation> = R extends {
301
+ type: 'belongs_to' | 'has_one';
302
+ }
303
+ ? T | null
304
+ : R extends { type: 'has_many' | 'many_to_many' }
305
+ ? T[]
306
+ : never;
307
+
308
+ /**
309
+ * Record with loaded relations
310
+ */
311
+ export type RecordWithRelations<T, R extends Record<string, StorageRelation>> = T & {
312
+ [K in keyof R]?: LoadedRelation<unknown, R[K]>;
313
+ };
314
+
315
+ // TRANSACTION TYPES
316
+
317
+ /**
318
+ * Transaction context
319
+ */
320
+ export interface TransactionContext {
321
+ /** Transaction ID */
322
+ id: string;
323
+ /** Transaction start time */
324
+ startTime: number;
325
+ /** Whether transaction is active */
326
+ isActive: boolean;
327
+ }
328
+
329
+ /**
330
+ * Transaction function
331
+ */
332
+ export type TransactionFn<T> = (tx: TransactionContext) => Promise<T>;
333
+
334
+ // AGGREGATION TYPES
335
+
336
+ /**
337
+ * Aggregation functions
338
+ */
339
+ export type AggregationFunction = 'count' | 'sum' | 'avg' | 'min' | 'max';
340
+
341
+ /**
342
+ * Aggregation options
343
+ */
344
+ export interface AggregationOptions<T> {
345
+ /** Field to aggregate (not needed for count) */
346
+ field?: keyof T;
347
+ /** Filter conditions */
348
+ where?: WhereFilter<T>;
349
+ /** Group by fields */
350
+ groupBy?: keyof T | (keyof T)[];
351
+ /** Having conditions */
352
+ having?: Record<string, unknown>;
353
+ /** Multiple aggregations in one query */
354
+ aggregations?: {
355
+ [alias: string]: {
356
+ function: AggregationFunction;
357
+ field?: keyof T;
358
+ };
359
+ };
360
+ /** Include grouped values in result */
361
+ includeGroups?: boolean;
362
+ }
363
+
364
+ /**
365
+ * Aggregation result
366
+ */
367
+ export interface AggregationResult {
368
+ /** Aggregation value */
369
+ value: number;
370
+ /** Group values (if grouped) */
371
+ group?: Record<string, unknown>;
372
+ /** Multiple aggregation values when using aggregations */
373
+ values?: Record<string, number>;
374
+ }
375
+
376
+ // STREAM TYPES
377
+
378
+ /**
379
+ * Stream options
380
+ */
381
+ export interface StreamOptions<T> extends QueryOptions<T> {
382
+ /** Batch size for streaming */
383
+ batchSize?: number;
384
+ /** High water mark for backpressure */
385
+ highWaterMark?: number;
386
+ }
387
+
388
+ // RAW QUERY TYPES
389
+
390
+ /**
391
+ * Raw query options
392
+ */
393
+ export interface RawQueryOptions<R = unknown> {
394
+ /** SQL query with placeholders */
395
+ sql: string;
396
+ /** Query parameters */
397
+ params?: unknown[];
398
+ /** Schema for result validation */
399
+ schema?: z.ZodType<R>;
400
+ }
401
+
402
+ // STORAGE RECORD INTERFACE
403
+
404
+ /**
405
+ * Storage Record Interface
406
+ *
407
+ * Provides CRUD operations on a single table with relations.
408
+ */
409
+ export interface StorageRecordInterface<
410
+ T = unknown,
411
+ R extends Record<string, StorageRelation> = Record<string, StorageRelation>
412
+ > {
413
+ // METADATA
414
+
415
+ /** Table name */
416
+ readonly tableName: string;
417
+
418
+ /** Primary key field */
419
+ readonly primaryKey: string;
420
+
421
+ /** Zod schema for validation */
422
+ readonly schema: z.ZodType<T>;
423
+
424
+ /** Available relations */
425
+ readonly relations: R;
426
+
427
+ // CREATE
428
+
429
+ /**
430
+ * Create a new record
431
+ *
432
+ * @param data - Record data
433
+ * @returns Created record
434
+ */
435
+ create(data: CreateInput<T>): Promise<T>;
436
+
437
+ /**
438
+ * Create multiple records
439
+ *
440
+ * @param data - Array of record data
441
+ * @param options - Create many options
442
+ * @returns Created records
443
+ */
444
+ createMany(data: CreateInput<T>[], options?: CreateManyOptions): Promise<T[]>;
445
+
446
+ // READ
447
+
448
+ /**
449
+ * Get a single record by ID
450
+ *
451
+ * @param id - Record ID
452
+ * @param options - Query options (include relations, select fields)
453
+ * @returns Record or null if not found
454
+ */
455
+ get(
456
+ id: string,
457
+ options?: Pick<QueryOptions<T, string & keyof R>, 'include' | 'select' | 'includeComputed'>
458
+ ): Promise<T | null>;
459
+
460
+ /**
461
+ * Get a single record or throw if not found
462
+ *
463
+ * @param id - Record ID
464
+ * @param options - Query options
465
+ * @returns Record
466
+ * @throws Error if record not found
467
+ */
468
+ getOrThrow(
469
+ id: string,
470
+ options?: Pick<QueryOptions<T, string & keyof R>, 'include' | 'select' | 'includeComputed'>
471
+ ): Promise<T>;
472
+
473
+ /**
474
+ * Get many records by IDs
475
+ *
476
+ * @param ids - Record IDs
477
+ * @param options - Query options
478
+ * @returns Records (may be fewer than requested if some not found)
479
+ */
480
+ getMany(
481
+ ids: string[],
482
+ options?: Pick<QueryOptions<T, string & keyof R>, 'include' | 'select' | 'includeComputed'>
483
+ ): Promise<T[]>;
484
+
485
+ /**
486
+ * List records with filtering, pagination, and relations
487
+ *
488
+ * @param options - Query options
489
+ * @returns Query result with items and pagination metadata
490
+ */
491
+ list(options?: QueryOptions<T, string & keyof R>): Promise<QueryResult<T>>;
492
+
493
+ /**
494
+ * Find first record matching conditions
495
+ *
496
+ * @param options - Query options
497
+ * @returns First matching record or null
498
+ */
499
+ findFirst(options?: QueryOptions<T, string & keyof R>): Promise<T | null>;
500
+
501
+ /**
502
+ * Find first record or throw if not found
503
+ *
504
+ * @param options - Query options
505
+ * @returns First matching record
506
+ * @throws Error if no record found
507
+ */
508
+ findFirstOrThrow(options?: QueryOptions<T, string & keyof R>): Promise<T>;
509
+
510
+ /**
511
+ * Check if record exists
512
+ *
513
+ * @param id - Record ID
514
+ * @returns True if record exists
515
+ */
516
+ exists(id: string): Promise<boolean>;
517
+
518
+ /**
519
+ * Count records matching conditions
520
+ *
521
+ * @param where - Filter conditions
522
+ * @returns Number of matching records
523
+ */
524
+ count(where?: WhereFilter<T>): Promise<number>;
525
+
526
+ // FULL-TEXT SEARCH
527
+
528
+ /**
529
+ * Full-text search on indexed fields
530
+ *
531
+ * @param query - Search query (FTS5 syntax supported)
532
+ * @param options - Search options
533
+ * @returns Search results with relevance scores
534
+ */
535
+ search(query: string, options?: SearchOptions<T, string & keyof R>): Promise<SearchResult<T>>;
536
+
537
+ // HIERARCHY (Recursive CTEs)
538
+
539
+ /**
540
+ * Get all descendants of a record
541
+ *
542
+ * @param id - Root record ID
543
+ * @param options - Hierarchy options
544
+ * @returns Query result with depth information
545
+ */
546
+ getDescendants(
547
+ id: string,
548
+ options?: HierarchyOptions<T, string & keyof R>
549
+ ): Promise<QueryResult<T & { depth: number; path?: string[] }>>;
550
+
551
+ /**
552
+ * Get all ancestors of a record
553
+ *
554
+ * @param id - Leaf record ID
555
+ * @param options - Query options
556
+ * @returns Ancestor records from root to parent
557
+ */
558
+ getAncestors(id: string, options?: QueryOptions<T, string & keyof R>): Promise<T[]>;
559
+
560
+ /**
561
+ * Get full tree starting from matching roots
562
+ *
563
+ * @param options - Query options for root selection
564
+ * @returns Tree structure with nested children
565
+ */
566
+ getTree(options?: HierarchyOptions<T, string & keyof R>): Promise<TreeNode<T>[]>;
567
+
568
+ // UPDATE
569
+
570
+ /**
571
+ * Update a record by ID
572
+ *
573
+ * @param id - Record ID
574
+ * @param data - Update data
575
+ * @param options - Update options
576
+ * @returns Updated record
577
+ * @throws Error if record not found
578
+ */
579
+ update(id: string, data: UpdateInput<T>, options?: UpdateOptions): Promise<T>;
580
+
581
+ /**
582
+ * Update many records matching conditions
583
+ *
584
+ * @param where - Filter conditions
585
+ * @param data - Update data
586
+ * @param options - Update options
587
+ * @returns Update result with count
588
+ */
589
+ updateMany(
590
+ where: WhereFilter<T>,
591
+ data: UpdateInput<T>,
592
+ options?: UpdateOptions
593
+ ): Promise<UpdateResult>;
594
+
595
+ /**
596
+ * Update or create a record
597
+ *
598
+ * @param id - Record ID
599
+ * @param create - Data to use if creating
600
+ * @param update - Data to use if updating
601
+ * @returns Created or updated record
602
+ */
603
+ upsert(id: string, create: CreateInput<T>, update: UpdateInput<T>): Promise<T>;
604
+
605
+ // DELETE
606
+
607
+ /**
608
+ * Delete a record by ID
609
+ *
610
+ * @param id - Record ID
611
+ * @param options - Delete options
612
+ * @returns Delete result
613
+ */
614
+ delete(id: string, options?: DeleteOptions): Promise<DeleteResult>;
615
+
616
+ /**
617
+ * Delete many records matching conditions
618
+ *
619
+ * @param where - Filter conditions
620
+ * @param options - Delete options
621
+ * @returns Delete result with count
622
+ */
623
+ deleteMany(where: WhereFilter<T>, options?: DeleteOptions): Promise<DeleteResult>;
624
+
625
+ /**
626
+ * Restore a soft-deleted record
627
+ *
628
+ * @param id - Record ID
629
+ * @returns Restored record
630
+ * @throws Error if record not found or not soft-deleted
631
+ */
632
+ restore(id: string): Promise<T>;
633
+
634
+ // AGGREGATION
635
+
636
+ /**
637
+ * Aggregate records
638
+ *
639
+ * @param options - Aggregation options with function
640
+ * @returns Aggregation results
641
+ */
642
+ aggregate(
643
+ options: AggregationOptions<T> & { function: AggregationFunction }
644
+ ): Promise<AggregationResult[]>;
645
+
646
+ // TRANSACTIONS
647
+
648
+ /**
649
+ * Execute operations in a transaction
650
+ *
651
+ * @param fn - Transaction function
652
+ * @returns Transaction result
653
+ */
654
+ transaction<U>(fn: TransactionFn<U>): Promise<U>;
655
+
656
+ // STREAMING
657
+
658
+ /**
659
+ * Stream records as async iterable
660
+ *
661
+ * @param options - Stream options
662
+ * @returns Async iterable of records
663
+ */
664
+ stream(options?: StreamOptions<T>): AsyncIterable<T>;
665
+
666
+ // BATCH OPERATIONS
667
+
668
+ /**
669
+ * Execute multiple operations in batch
670
+ *
671
+ * @param operations - Array of operations
672
+ * @returns Array of results
673
+ */
674
+ batch(
675
+ operations: Array<{
676
+ type: 'create' | 'update' | 'delete';
677
+ data?: unknown;
678
+ id?: string;
679
+ }>
680
+ ): Promise<unknown[]>;
681
+
682
+ // RAW QUERIES
683
+
684
+ /**
685
+ * Execute raw SQL query (adapter-specific)
686
+ * Use sparingly - breaks adapter portability
687
+ *
688
+ * @param sql - SQL query with placeholders
689
+ * @param params - Query parameters
690
+ * @returns Raw result rows
691
+ */
692
+ raw<R = unknown>(sql: string, ...params: unknown[]): Promise<R[]>;
693
+
694
+ /**
695
+ * Execute raw query with typed result
696
+ *
697
+ * @param options - Raw query options
698
+ * @returns Typed result rows
699
+ */
700
+ queryRaw<R>(options: RawQueryOptions<R>): Promise<R[]>;
701
+
702
+ // UTILITIES
703
+
704
+ /**
705
+ * Validate record data against schema
706
+ *
707
+ * @param data - Record data
708
+ * @returns Validation result
709
+ */
710
+ validate(data: unknown): Promise<{ success: boolean; data?: T; errors?: z.ZodError }>;
711
+
712
+ /**
713
+ * Get database adapter being used
714
+ *
715
+ * @returns Adapter ID
716
+ */
717
+ getAdapterId(): string;
718
+
719
+ /**
720
+ * Close connections and cleanup
721
+ */
722
+ close(): Promise<void>;
723
+ }