@proseql/core 0.1.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 (342) hide show
  1. package/LICENSE +21 -0
  2. package/dist/errors/crud-errors.d.ts +98 -0
  3. package/dist/errors/crud-errors.d.ts.map +1 -0
  4. package/dist/errors/crud-errors.js +23 -0
  5. package/dist/errors/crud-errors.js.map +1 -0
  6. package/dist/errors/index.d.ts +16 -0
  7. package/dist/errors/index.d.ts.map +1 -0
  8. package/dist/errors/index.js +12 -0
  9. package/dist/errors/index.js.map +1 -0
  10. package/dist/errors/migration-errors.d.ts +22 -0
  11. package/dist/errors/migration-errors.d.ts.map +1 -0
  12. package/dist/errors/migration-errors.js +14 -0
  13. package/dist/errors/migration-errors.js.map +1 -0
  14. package/dist/errors/plugin-errors.d.ts +15 -0
  15. package/dist/errors/plugin-errors.d.ts.map +1 -0
  16. package/dist/errors/plugin-errors.js +11 -0
  17. package/dist/errors/plugin-errors.js.map +1 -0
  18. package/dist/errors/query-errors.d.ts +31 -0
  19. package/dist/errors/query-errors.d.ts.map +1 -0
  20. package/dist/errors/query-errors.js +11 -0
  21. package/dist/errors/query-errors.js.map +1 -0
  22. package/dist/errors/storage-errors.d.ts +30 -0
  23. package/dist/errors/storage-errors.d.ts.map +1 -0
  24. package/dist/errors/storage-errors.js +11 -0
  25. package/dist/errors/storage-errors.js.map +1 -0
  26. package/dist/factories/crud-factory-with-relationships.d.ts +28 -0
  27. package/dist/factories/crud-factory-with-relationships.d.ts.map +1 -0
  28. package/dist/factories/crud-factory-with-relationships.js +8 -0
  29. package/dist/factories/crud-factory-with-relationships.js.map +1 -0
  30. package/dist/factories/crud-factory.d.ts +25 -0
  31. package/dist/factories/crud-factory.d.ts.map +1 -0
  32. package/dist/factories/crud-factory.js +8 -0
  33. package/dist/factories/crud-factory.js.map +1 -0
  34. package/dist/factories/database-effect.d.ts +241 -0
  35. package/dist/factories/database-effect.d.ts.map +1 -0
  36. package/dist/factories/database-effect.js +859 -0
  37. package/dist/factories/database-effect.js.map +1 -0
  38. package/dist/hooks/hook-runner.d.ts +60 -0
  39. package/dist/hooks/hook-runner.d.ts.map +1 -0
  40. package/dist/hooks/hook-runner.js +107 -0
  41. package/dist/hooks/hook-runner.js.map +1 -0
  42. package/dist/index.d.ts +84 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +110 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/indexes/index-lookup.d.ts +33 -0
  47. package/dist/indexes/index-lookup.d.ts.map +1 -0
  48. package/dist/indexes/index-lookup.js +180 -0
  49. package/dist/indexes/index-lookup.js.map +1 -0
  50. package/dist/indexes/index-manager.d.ts +118 -0
  51. package/dist/indexes/index-manager.d.ts.map +1 -0
  52. package/dist/indexes/index-manager.js +345 -0
  53. package/dist/indexes/index-manager.js.map +1 -0
  54. package/dist/indexes/search-index.d.ts +179 -0
  55. package/dist/indexes/search-index.d.ts.map +1 -0
  56. package/dist/indexes/search-index.js +405 -0
  57. package/dist/indexes/search-index.js.map +1 -0
  58. package/dist/migrations/migration-runner.d.ts +70 -0
  59. package/dist/migrations/migration-runner.d.ts.map +1 -0
  60. package/dist/migrations/migration-runner.js +271 -0
  61. package/dist/migrations/migration-runner.js.map +1 -0
  62. package/dist/migrations/migration-types.d.ts +63 -0
  63. package/dist/migrations/migration-types.d.ts.map +1 -0
  64. package/dist/migrations/migration-types.js +5 -0
  65. package/dist/migrations/migration-types.js.map +1 -0
  66. package/dist/operations/crud/create-with-relationships.d.ts +44 -0
  67. package/dist/operations/crud/create-with-relationships.d.ts.map +1 -0
  68. package/dist/operations/crud/create-with-relationships.js +483 -0
  69. package/dist/operations/crud/create-with-relationships.js.map +1 -0
  70. package/dist/operations/crud/create.d.ts +48 -0
  71. package/dist/operations/crud/create.d.ts.map +1 -0
  72. package/dist/operations/crud/create.js +333 -0
  73. package/dist/operations/crud/create.js.map +1 -0
  74. package/dist/operations/crud/delete-with-relationships.d.ts +63 -0
  75. package/dist/operations/crud/delete-with-relationships.d.ts.map +1 -0
  76. package/dist/operations/crud/delete-with-relationships.js +395 -0
  77. package/dist/operations/crud/delete-with-relationships.js.map +1 -0
  78. package/dist/operations/crud/delete.d.ts +58 -0
  79. package/dist/operations/crud/delete.d.ts.map +1 -0
  80. package/dist/operations/crud/delete.js +267 -0
  81. package/dist/operations/crud/delete.js.map +1 -0
  82. package/dist/operations/crud/unique-check.d.ts +114 -0
  83. package/dist/operations/crud/unique-check.d.ts.map +1 -0
  84. package/dist/operations/crud/unique-check.js +383 -0
  85. package/dist/operations/crud/unique-check.js.map +1 -0
  86. package/dist/operations/crud/update-with-relationships.d.ts +45 -0
  87. package/dist/operations/crud/update-with-relationships.d.ts.map +1 -0
  88. package/dist/operations/crud/update-with-relationships.js +516 -0
  89. package/dist/operations/crud/update-with-relationships.js.map +1 -0
  90. package/dist/operations/crud/update.d.ts +91 -0
  91. package/dist/operations/crud/update.d.ts.map +1 -0
  92. package/dist/operations/crud/update.js +505 -0
  93. package/dist/operations/crud/update.js.map +1 -0
  94. package/dist/operations/crud/upsert.d.ts +52 -0
  95. package/dist/operations/crud/upsert.d.ts.map +1 -0
  96. package/dist/operations/crud/upsert.js +386 -0
  97. package/dist/operations/crud/upsert.js.map +1 -0
  98. package/dist/operations/query/aggregate.d.ts +30 -0
  99. package/dist/operations/query/aggregate.d.ts.map +1 -0
  100. package/dist/operations/query/aggregate.js +227 -0
  101. package/dist/operations/query/aggregate.js.map +1 -0
  102. package/dist/operations/query/cursor-stream.d.ts +18 -0
  103. package/dist/operations/query/cursor-stream.d.ts.map +1 -0
  104. package/dist/operations/query/cursor-stream.js +199 -0
  105. package/dist/operations/query/cursor-stream.js.map +1 -0
  106. package/dist/operations/query/filter-stream.d.ts +12 -0
  107. package/dist/operations/query/filter-stream.d.ts.map +1 -0
  108. package/dist/operations/query/filter-stream.js +167 -0
  109. package/dist/operations/query/filter-stream.js.map +1 -0
  110. package/dist/operations/query/filter.d.ts +13 -0
  111. package/dist/operations/query/filter.d.ts.map +1 -0
  112. package/dist/operations/query/filter.js +267 -0
  113. package/dist/operations/query/filter.js.map +1 -0
  114. package/dist/operations/query/paginate-stream.d.ts +11 -0
  115. package/dist/operations/query/paginate-stream.d.ts.map +1 -0
  116. package/dist/operations/query/paginate-stream.js +22 -0
  117. package/dist/operations/query/paginate-stream.js.map +1 -0
  118. package/dist/operations/query/query-helpers.d.ts +14 -0
  119. package/dist/operations/query/query-helpers.d.ts.map +1 -0
  120. package/dist/operations/query/query-helpers.js +22 -0
  121. package/dist/operations/query/query-helpers.js.map +1 -0
  122. package/dist/operations/query/resolve-computed.d.ts +142 -0
  123. package/dist/operations/query/resolve-computed.d.ts.map +1 -0
  124. package/dist/operations/query/resolve-computed.js +197 -0
  125. package/dist/operations/query/resolve-computed.js.map +1 -0
  126. package/dist/operations/query/search.d.ts +110 -0
  127. package/dist/operations/query/search.d.ts.map +1 -0
  128. package/dist/operations/query/search.js +188 -0
  129. package/dist/operations/query/search.js.map +1 -0
  130. package/dist/operations/query/select-stream.d.ts +27 -0
  131. package/dist/operations/query/select-stream.d.ts.map +1 -0
  132. package/dist/operations/query/select-stream.js +88 -0
  133. package/dist/operations/query/select-stream.js.map +1 -0
  134. package/dist/operations/query/select.d.ts +54 -0
  135. package/dist/operations/query/select.d.ts.map +1 -0
  136. package/dist/operations/query/select.js +159 -0
  137. package/dist/operations/query/select.js.map +1 -0
  138. package/dist/operations/query/sort-stream.d.ts +46 -0
  139. package/dist/operations/query/sort-stream.d.ts.map +1 -0
  140. package/dist/operations/query/sort-stream.js +158 -0
  141. package/dist/operations/query/sort-stream.js.map +1 -0
  142. package/dist/operations/query/sort.d.ts +9 -0
  143. package/dist/operations/query/sort.d.ts.map +1 -0
  144. package/dist/operations/query/sort.js +58 -0
  145. package/dist/operations/query/sort.js.map +1 -0
  146. package/dist/operations/relationships/populate-stream.d.ts +29 -0
  147. package/dist/operations/relationships/populate-stream.d.ts.map +1 -0
  148. package/dist/operations/relationships/populate-stream.js +159 -0
  149. package/dist/operations/relationships/populate-stream.js.map +1 -0
  150. package/dist/operations/relationships/populate.d.ts +15 -0
  151. package/dist/operations/relationships/populate.d.ts.map +1 -0
  152. package/dist/operations/relationships/populate.js +228 -0
  153. package/dist/operations/relationships/populate.js.map +1 -0
  154. package/dist/plugins/plugin-hooks.d.ts +25 -0
  155. package/dist/plugins/plugin-hooks.d.ts.map +1 -0
  156. package/dist/plugins/plugin-hooks.js +64 -0
  157. package/dist/plugins/plugin-hooks.js.map +1 -0
  158. package/dist/plugins/plugin-registry.d.ts +26 -0
  159. package/dist/plugins/plugin-registry.d.ts.map +1 -0
  160. package/dist/plugins/plugin-registry.js +150 -0
  161. package/dist/plugins/plugin-registry.js.map +1 -0
  162. package/dist/plugins/plugin-types.d.ts +95 -0
  163. package/dist/plugins/plugin-types.d.ts.map +1 -0
  164. package/dist/plugins/plugin-types.js +6 -0
  165. package/dist/plugins/plugin-types.js.map +1 -0
  166. package/dist/plugins/plugin-validation.d.ts +49 -0
  167. package/dist/plugins/plugin-validation.d.ts.map +1 -0
  168. package/dist/plugins/plugin-validation.js +295 -0
  169. package/dist/plugins/plugin-validation.js.map +1 -0
  170. package/dist/reactive/change-event.d.ts +44 -0
  171. package/dist/reactive/change-event.d.ts.map +1 -0
  172. package/dist/reactive/change-event.js +49 -0
  173. package/dist/reactive/change-event.js.map +1 -0
  174. package/dist/reactive/change-pubsub.d.ts +32 -0
  175. package/dist/reactive/change-pubsub.d.ts.map +1 -0
  176. package/dist/reactive/change-pubsub.js +31 -0
  177. package/dist/reactive/change-pubsub.js.map +1 -0
  178. package/dist/reactive/evaluate-query.d.ts +62 -0
  179. package/dist/reactive/evaluate-query.d.ts.map +1 -0
  180. package/dist/reactive/evaluate-query.js +57 -0
  181. package/dist/reactive/evaluate-query.js.map +1 -0
  182. package/dist/reactive/watch-by-id.d.ts +53 -0
  183. package/dist/reactive/watch-by-id.d.ts.map +1 -0
  184. package/dist/reactive/watch-by-id.js +55 -0
  185. package/dist/reactive/watch-by-id.js.map +1 -0
  186. package/dist/reactive/watch.d.ts +78 -0
  187. package/dist/reactive/watch.d.ts.map +1 -0
  188. package/dist/reactive/watch.js +133 -0
  189. package/dist/reactive/watch.js.map +1 -0
  190. package/dist/serializers/codecs/hjson.d.ts +33 -0
  191. package/dist/serializers/codecs/hjson.d.ts.map +1 -0
  192. package/dist/serializers/codecs/hjson.js +40 -0
  193. package/dist/serializers/codecs/hjson.js.map +1 -0
  194. package/dist/serializers/codecs/json.d.ts +22 -0
  195. package/dist/serializers/codecs/json.d.ts.map +1 -0
  196. package/dist/serializers/codecs/json.js +28 -0
  197. package/dist/serializers/codecs/json.js.map +1 -0
  198. package/dist/serializers/codecs/json5.d.ts +26 -0
  199. package/dist/serializers/codecs/json5.d.ts.map +1 -0
  200. package/dist/serializers/codecs/json5.js +33 -0
  201. package/dist/serializers/codecs/json5.js.map +1 -0
  202. package/dist/serializers/codecs/jsonc.d.ts +29 -0
  203. package/dist/serializers/codecs/jsonc.d.ts.map +1 -0
  204. package/dist/serializers/codecs/jsonc.js +38 -0
  205. package/dist/serializers/codecs/jsonc.js.map +1 -0
  206. package/dist/serializers/codecs/jsonl.d.ts +17 -0
  207. package/dist/serializers/codecs/jsonl.d.ts.map +1 -0
  208. package/dist/serializers/codecs/jsonl.js +31 -0
  209. package/dist/serializers/codecs/jsonl.js.map +1 -0
  210. package/dist/serializers/codecs/prose.d.ts +419 -0
  211. package/dist/serializers/codecs/prose.d.ts.map +1 -0
  212. package/dist/serializers/codecs/prose.js +1060 -0
  213. package/dist/serializers/codecs/prose.js.map +1 -0
  214. package/dist/serializers/codecs/toml.d.ts +23 -0
  215. package/dist/serializers/codecs/toml.d.ts.map +1 -0
  216. package/dist/serializers/codecs/toml.js +66 -0
  217. package/dist/serializers/codecs/toml.js.map +1 -0
  218. package/dist/serializers/codecs/toon.d.ts +20 -0
  219. package/dist/serializers/codecs/toon.d.ts.map +1 -0
  220. package/dist/serializers/codecs/toon.js +33 -0
  221. package/dist/serializers/codecs/toon.js.map +1 -0
  222. package/dist/serializers/codecs/yaml.d.ts +24 -0
  223. package/dist/serializers/codecs/yaml.d.ts.map +1 -0
  224. package/dist/serializers/codecs/yaml.js +31 -0
  225. package/dist/serializers/codecs/yaml.js.map +1 -0
  226. package/dist/serializers/format-codec.d.ts +53 -0
  227. package/dist/serializers/format-codec.d.ts.map +1 -0
  228. package/dist/serializers/format-codec.js +148 -0
  229. package/dist/serializers/format-codec.js.map +1 -0
  230. package/dist/serializers/presets.d.ts +48 -0
  231. package/dist/serializers/presets.d.ts.map +1 -0
  232. package/dist/serializers/presets.js +72 -0
  233. package/dist/serializers/presets.js.map +1 -0
  234. package/dist/serializers/serializer-service.d.ts +11 -0
  235. package/dist/serializers/serializer-service.d.ts.map +1 -0
  236. package/dist/serializers/serializer-service.js +4 -0
  237. package/dist/serializers/serializer-service.js.map +1 -0
  238. package/dist/state/collection-state.d.ts +19 -0
  239. package/dist/state/collection-state.d.ts.map +1 -0
  240. package/dist/state/collection-state.js +15 -0
  241. package/dist/state/collection-state.js.map +1 -0
  242. package/dist/state/state-operations.d.ts +38 -0
  243. package/dist/state/state-operations.d.ts.map +1 -0
  244. package/dist/state/state-operations.js +65 -0
  245. package/dist/state/state-operations.js.map +1 -0
  246. package/dist/storage/in-memory-adapter-layer.d.ts +16 -0
  247. package/dist/storage/in-memory-adapter-layer.d.ts.map +1 -0
  248. package/dist/storage/in-memory-adapter-layer.js +81 -0
  249. package/dist/storage/in-memory-adapter-layer.js.map +1 -0
  250. package/dist/storage/persistence-effect.d.ts +244 -0
  251. package/dist/storage/persistence-effect.d.ts.map +1 -0
  252. package/dist/storage/persistence-effect.js +551 -0
  253. package/dist/storage/persistence-effect.js.map +1 -0
  254. package/dist/storage/storage-service.d.ts +22 -0
  255. package/dist/storage/storage-service.d.ts.map +1 -0
  256. package/dist/storage/storage-service.js +4 -0
  257. package/dist/storage/storage-service.js.map +1 -0
  258. package/dist/storage/transforms.d.ts +183 -0
  259. package/dist/storage/transforms.d.ts.map +1 -0
  260. package/dist/storage/transforms.js +263 -0
  261. package/dist/storage/transforms.js.map +1 -0
  262. package/dist/transactions/transaction.d.ts +87 -0
  263. package/dist/transactions/transaction.d.ts.map +1 -0
  264. package/dist/transactions/transaction.js +240 -0
  265. package/dist/transactions/transaction.js.map +1 -0
  266. package/dist/types/aggregate-types.d.ts +73 -0
  267. package/dist/types/aggregate-types.d.ts.map +1 -0
  268. package/dist/types/aggregate-types.js +14 -0
  269. package/dist/types/aggregate-types.js.map +1 -0
  270. package/dist/types/computed-types.d.ts +71 -0
  271. package/dist/types/computed-types.d.ts.map +1 -0
  272. package/dist/types/computed-types.js +8 -0
  273. package/dist/types/computed-types.js.map +1 -0
  274. package/dist/types/crud-relationship-types.d.ts +180 -0
  275. package/dist/types/crud-relationship-types.d.ts.map +1 -0
  276. package/dist/types/crud-relationship-types.js +17 -0
  277. package/dist/types/crud-relationship-types.js.map +1 -0
  278. package/dist/types/crud-types.d.ts +343 -0
  279. package/dist/types/crud-types.d.ts.map +1 -0
  280. package/dist/types/crud-types.js +43 -0
  281. package/dist/types/crud-types.js.map +1 -0
  282. package/dist/types/cursor-types.d.ts +52 -0
  283. package/dist/types/cursor-types.d.ts.map +1 -0
  284. package/dist/types/cursor-types.js +2 -0
  285. package/dist/types/cursor-types.js.map +1 -0
  286. package/dist/types/database-config-types.d.ts +196 -0
  287. package/dist/types/database-config-types.d.ts.map +1 -0
  288. package/dist/types/database-config-types.js +11 -0
  289. package/dist/types/database-config-types.js.map +1 -0
  290. package/dist/types/hook-types.d.ts +158 -0
  291. package/dist/types/hook-types.d.ts.map +1 -0
  292. package/dist/types/hook-types.js +6 -0
  293. package/dist/types/hook-types.js.map +1 -0
  294. package/dist/types/index-types.d.ts +42 -0
  295. package/dist/types/index-types.d.ts.map +1 -0
  296. package/dist/types/index-types.js +8 -0
  297. package/dist/types/index-types.js.map +1 -0
  298. package/dist/types/operators.d.ts +5 -0
  299. package/dist/types/operators.d.ts.map +1 -0
  300. package/dist/types/operators.js +297 -0
  301. package/dist/types/operators.js.map +1 -0
  302. package/dist/types/query-overloads.d.ts +54 -0
  303. package/dist/types/query-overloads.d.ts.map +1 -0
  304. package/dist/types/query-overloads.js +3 -0
  305. package/dist/types/query-overloads.js.map +1 -0
  306. package/dist/types/reactive-types.d.ts +75 -0
  307. package/dist/types/reactive-types.d.ts.map +1 -0
  308. package/dist/types/reactive-types.js +7 -0
  309. package/dist/types/reactive-types.js.map +1 -0
  310. package/dist/types/schema-types.d.ts +56 -0
  311. package/dist/types/schema-types.d.ts.map +1 -0
  312. package/dist/types/schema-types.js +8 -0
  313. package/dist/types/schema-types.js.map +1 -0
  314. package/dist/types/search-types.d.ts +82 -0
  315. package/dist/types/search-types.d.ts.map +1 -0
  316. package/dist/types/search-types.js +110 -0
  317. package/dist/types/search-types.js.map +1 -0
  318. package/dist/types/types.d.ts +286 -0
  319. package/dist/types/types.d.ts.map +1 -0
  320. package/dist/types/types.js +2 -0
  321. package/dist/types/types.js.map +1 -0
  322. package/dist/utils/id-generator.d.ts +97 -0
  323. package/dist/utils/id-generator.d.ts.map +1 -0
  324. package/dist/utils/id-generator.js +247 -0
  325. package/dist/utils/id-generator.js.map +1 -0
  326. package/dist/utils/nested-path.d.ts +56 -0
  327. package/dist/utils/nested-path.d.ts.map +1 -0
  328. package/dist/utils/nested-path.js +119 -0
  329. package/dist/utils/nested-path.js.map +1 -0
  330. package/dist/utils/path.d.ts +16 -0
  331. package/dist/utils/path.d.ts.map +1 -0
  332. package/dist/utils/path.js +24 -0
  333. package/dist/utils/path.js.map +1 -0
  334. package/dist/validators/foreign-key.d.ts +49 -0
  335. package/dist/validators/foreign-key.d.ts.map +1 -0
  336. package/dist/validators/foreign-key.js +153 -0
  337. package/dist/validators/foreign-key.js.map +1 -0
  338. package/dist/validators/schema-validator.d.ts +19 -0
  339. package/dist/validators/schema-validator.d.ts.map +1 -0
  340. package/dist/validators/schema-validator.js +34 -0
  341. package/dist/validators/schema-validator.js.map +1 -0
  342. package/package.json +57 -0
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Reactive query types for live subscriptions to data changes.
3
+ * Enables watch() and watchById() methods that emit streams of results
4
+ * whenever the underlying data changes.
5
+ */
6
+ import type { PopulateConfig, SelectConfig, SortConfig, WhereClause } from "./types.js";
7
+ /**
8
+ * Represents a mutation event that occurred on a collection.
9
+ * Published by CRUD operations and file watchers to notify reactive subscriptions.
10
+ *
11
+ * - "create": One or more entities were created
12
+ * - "update": One or more entities were updated
13
+ * - "delete": One or more entities were deleted
14
+ * - "reload": Data was reloaded from disk (file watcher detected external change)
15
+ */
16
+ export interface ChangeEvent {
17
+ readonly collection: string;
18
+ readonly operation: "create" | "update" | "delete" | "reload";
19
+ }
20
+ /**
21
+ * Configuration for reactive watch queries.
22
+ * Mirrors QueryConfig but excludes cursor pagination (watches are continuous streams).
23
+ *
24
+ * @template T - The entity type being watched
25
+ * @template Relations - Relationship definitions for the collection
26
+ * @template DB - The full database type (for cross-collection type resolution)
27
+ */
28
+ export type WatchConfig<T, Relations extends Record<string, unknown> = Record<string, never>, DB = unknown> = {
29
+ readonly where?: WhereClause<T, Relations, DB>;
30
+ readonly sort?: SortConfig<T, Relations, Record<string, never>, DB>;
31
+ readonly select?: SelectConfig<T, Relations, DB>;
32
+ readonly limit?: number;
33
+ readonly offset?: number;
34
+ } | {
35
+ readonly populate: PopulateConfig<Relations, DB>;
36
+ readonly where?: WhereClause<T, Relations, DB>;
37
+ readonly sort?: SortConfig<T, Relations, {
38
+ populate: PopulateConfig<Relations, DB>;
39
+ }, DB>;
40
+ readonly select?: SelectConfig<T, Relations, DB>;
41
+ readonly limit?: number;
42
+ readonly offset?: number;
43
+ };
44
+ /**
45
+ * Signature for the watch() method on collections.
46
+ *
47
+ * Creates a reactive subscription that emits the current result set immediately,
48
+ * then re-emits whenever the underlying data changes (create/update/delete/reload).
49
+ *
50
+ * The stream is scoped: it subscribes to change notifications on creation and
51
+ * automatically unsubscribes when the scope closes or the stream is interrupted.
52
+ *
53
+ * @template T - The entity type being watched
54
+ * @template Relations - Relationship definitions for the collection
55
+ * @template DB - The full database type (for cross-collection type resolution)
56
+ * @param config - Optional query configuration (where, sort, select, limit, offset, populate)
57
+ * @returns A scoped Effect that produces a Stream of result arrays
58
+ */
59
+ export type WatchMethod<T, Relations extends Record<string, unknown> = Record<string, never>, DB = unknown> = <C extends WatchConfig<T, Relations, DB>>(config?: C) => import("effect").Effect.Effect<import("effect").Stream.Stream<ReadonlyArray<T>, never, never>, never, import("effect").Scope.Scope>;
60
+ /**
61
+ * Signature for the watchById() method on collections.
62
+ *
63
+ * Creates a reactive subscription for a single entity by ID.
64
+ * Emits the entity immediately if it exists (or null if not), then re-emits
65
+ * whenever the entity is created, updated, or deleted.
66
+ *
67
+ * The stream is scoped: it subscribes to change notifications on creation and
68
+ * automatically unsubscribes when the scope closes or the stream is interrupted.
69
+ *
70
+ * @template T - The entity type being watched
71
+ * @param id - The entity ID to watch
72
+ * @returns A scoped Effect that produces a Stream of T | null
73
+ */
74
+ export type WatchByIdMethod<T> = (id: string) => import("effect").Effect.Effect<import("effect").Stream.Stream<T | null, never, never>, never, import("effect").Scope.Scope>;
75
+ //# sourceMappingURL=reactive-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactive-types.d.ts","sourceRoot":"","sources":["../../src/types/reactive-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACX,cAAc,EACd,YAAY,EACZ,UAAU,EACV,WAAW,EACX,MAAM,YAAY,CAAC;AAMpB;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;CAC9D;AAMD;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,CACtB,CAAC,EACD,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACjE,EAAE,GAAG,OAAO,IAEX;IACA,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACxB,GAED;IACA,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CACzB,CAAC,EACD,SAAS,EACT;QAAE,QAAQ,EAAE,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;KAAE,EAC3C,EAAE,CACF,CAAC;IACF,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAMJ;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,WAAW,CACtB,CAAC,EACD,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACjE,EAAE,GAAG,OAAO,IACT,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,EAC3C,MAAM,CAAC,EAAE,CAAC,KACN,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,CAClC,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,EAC9D,KAAK,EACL,OAAO,QAAQ,EAAE,KAAK,CAAC,KAAK,CAC5B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAChC,EAAE,EAAE,MAAM,KACN,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,CAClC,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,EACtD,KAAK,EACL,OAAO,QAAQ,EAAE,KAAK,CAAC,KAAK,CAC5B,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Reactive query types for live subscriptions to data changes.
3
+ * Enables watch() and watchById() methods that emit streams of results
4
+ * whenever the underlying data changes.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=reactive-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactive-types.js","sourceRoot":"","sources":["../../src/types/reactive-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Effect Schema type utilities for the database.
3
+ *
4
+ * Provides helper types for working with Effect Schema in entity definitions.
5
+ * All entity schemas are Schema.Struct-based and support bidirectional encode/decode.
6
+ */
7
+ import type { Schema } from "effect";
8
+ /**
9
+ * Constraint for entity schemas: the decoded Type must include `{ readonly id: string }`.
10
+ * The Encoded and Context parameters are left open so schemas with transformations
11
+ * (e.g., DateFromString) or context requirements are accepted.
12
+ *
13
+ * Usage:
14
+ * ```ts
15
+ * const UserSchema = Schema.Struct({
16
+ * id: Schema.String,
17
+ * name: Schema.String,
18
+ * age: Schema.Number,
19
+ * })
20
+ *
21
+ * // Satisfies EntitySchema because Type includes { id: string }
22
+ * type Check = typeof UserSchema extends EntitySchema<Schema.Schema.Type<typeof UserSchema>> ? true : false
23
+ * ```
24
+ */
25
+ export type EntitySchema<T extends {
26
+ readonly id: string;
27
+ }> = Schema.Schema<T, unknown, never>;
28
+ /**
29
+ * Extract the runtime (decoded) type from a schema.
30
+ * This is the type that queries return and CRUD operations work with.
31
+ *
32
+ * Usage:
33
+ * ```ts
34
+ * const UserSchema = Schema.Struct({ id: Schema.String, name: Schema.String })
35
+ * type User = InferEntity<typeof UserSchema>
36
+ * // => { readonly id: string; readonly name: string }
37
+ * ```
38
+ */
39
+ export type InferEntity<S extends Schema.Schema.All> = Schema.Schema.Type<S>;
40
+ /**
41
+ * Extract the encoded (on-disk) type from a schema.
42
+ * This is the type stored in JSON/YAML files.
43
+ *
44
+ * For simple schemas (String, Number, etc.) this matches the runtime type.
45
+ * For schemas with transformations (e.g., Schema.DateFromSelf) the encoded
46
+ * type may differ (e.g., string on disk vs Date at runtime).
47
+ *
48
+ * Usage:
49
+ * ```ts
50
+ * const UserSchema = Schema.Struct({ id: Schema.String, name: Schema.String })
51
+ * type UserEncoded = InferEncoded<typeof UserSchema>
52
+ * // => { readonly id: string; readonly name: string }
53
+ * ```
54
+ */
55
+ export type InferEncoded<S extends Schema.Schema.All> = Schema.Schema.Encoded<S>;
56
+ //# sourceMappingURL=schema-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-types.d.ts","sourceRoot":"","sources":["../../src/types/schema-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,IAAI,MAAM,CAAC,MAAM,CAC1E,CAAC,EACD,OAAO,EACP,KAAK,CACL,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAE7E;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,IACnD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Effect Schema type utilities for the database.
3
+ *
4
+ * Provides helper types for working with Effect Schema in entity definitions.
5
+ * All entity schemas are Schema.Struct-based and support bidirectional encode/decode.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=schema-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-types.js","sourceRoot":"","sources":["../../src/types/schema-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Types for full-text search functionality.
3
+ *
4
+ * Provides types for search configuration, relevance scoring,
5
+ * and inverted index structures for text search operations.
6
+ */
7
+ /**
8
+ * Configuration for multi-field search queries.
9
+ * Used with the top-level $search operator in where clauses.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * // Search across specific fields
14
+ * const config: SearchConfig = {
15
+ * query: "herbert dune",
16
+ * fields: ["title", "author"],
17
+ * }
18
+ *
19
+ * // Search across all string fields (fields omitted)
20
+ * const config2: SearchConfig = {
21
+ * query: "science fiction",
22
+ * }
23
+ * ```
24
+ */
25
+ export interface SearchConfig {
26
+ /**
27
+ * The search query string.
28
+ * Will be tokenized and matched against field values.
29
+ */
30
+ readonly query: string;
31
+ /**
32
+ * Optional list of fields to search.
33
+ * If omitted, all string fields on the entity are searched.
34
+ */
35
+ readonly fields?: ReadonlyArray<string>;
36
+ }
37
+ /**
38
+ * Represents the relevance score for a single entity.
39
+ * Used for ranking search results by relevance.
40
+ */
41
+ export interface SearchScore {
42
+ /**
43
+ * The ID of the entity this score belongs to.
44
+ */
45
+ readonly entityId: string;
46
+ /**
47
+ * The computed relevance score.
48
+ * Higher scores indicate better matches.
49
+ * Score of 0 indicates no match.
50
+ */
51
+ readonly score: number;
52
+ }
53
+ /**
54
+ * Type alias for the inverted index structure used in full-text search.
55
+ *
56
+ * Maps tokens to sets of entity IDs that contain those tokens.
57
+ * This enables fast lookup of candidate entities for a given search term.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * // Example index structure:
62
+ * // "dune" -> Set(["book-1", "book-7"])
63
+ * // "gibson" -> Set(["book-3"])
64
+ * // "left" -> Set(["book-2"])
65
+ * ```
66
+ */
67
+ export type SearchIndexMap = Map<string, Set<string>>;
68
+ /**
69
+ * Key used to store computed search relevance scores on entities.
70
+ * This metadata is attached after filtering and consumed by the sort stage.
71
+ *
72
+ * @internal
73
+ */
74
+ export declare const SEARCH_SCORE_KEY: "_searchScore";
75
+ /**
76
+ * Common English stop words that can optionally be filtered from search queries.
77
+ * These words are typically too common to be useful for search relevance.
78
+ *
79
+ * Includes: articles, prepositions, conjunctions, and common verbs.
80
+ */
81
+ export declare const STOP_WORDS: ReadonlySet<string>;
82
+ //# sourceMappingURL=search-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-types.d.ts","sourceRoot":"","sources":["../../src/types/search-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,YAAY;IAC5B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACxC;AAMD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAMD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAUtD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAG,cAAuB,CAAC;AAExD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,MAAM,CAmFzC,CAAC"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Types for full-text search functionality.
3
+ *
4
+ * Provides types for search configuration, relevance scoring,
5
+ * and inverted index structures for text search operations.
6
+ */
7
+ // ============================================================================
8
+ // Stop Words
9
+ // ============================================================================
10
+ // ============================================================================
11
+ // Metadata Keys
12
+ // ============================================================================
13
+ /**
14
+ * Key used to store computed search relevance scores on entities.
15
+ * This metadata is attached after filtering and consumed by the sort stage.
16
+ *
17
+ * @internal
18
+ */
19
+ export const SEARCH_SCORE_KEY = "_searchScore";
20
+ /**
21
+ * Common English stop words that can optionally be filtered from search queries.
22
+ * These words are typically too common to be useful for search relevance.
23
+ *
24
+ * Includes: articles, prepositions, conjunctions, and common verbs.
25
+ */
26
+ export const STOP_WORDS = new Set([
27
+ // Articles
28
+ "a",
29
+ "an",
30
+ "the",
31
+ // Prepositions
32
+ "at",
33
+ "by",
34
+ "for",
35
+ "from",
36
+ "in",
37
+ "into",
38
+ "of",
39
+ "off",
40
+ "on",
41
+ "onto",
42
+ "out",
43
+ "over",
44
+ "to",
45
+ "up",
46
+ "with",
47
+ // Conjunctions
48
+ "and",
49
+ "but",
50
+ "or",
51
+ "nor",
52
+ "so",
53
+ "yet",
54
+ // Common verbs
55
+ "am",
56
+ "are",
57
+ "be",
58
+ "been",
59
+ "being",
60
+ "did",
61
+ "do",
62
+ "does",
63
+ "doing",
64
+ "done",
65
+ "had",
66
+ "has",
67
+ "have",
68
+ "having",
69
+ "is",
70
+ "it",
71
+ "its",
72
+ "was",
73
+ "were",
74
+ // Pronouns
75
+ "he",
76
+ "her",
77
+ "him",
78
+ "his",
79
+ "i",
80
+ "me",
81
+ "my",
82
+ "she",
83
+ "that",
84
+ "them",
85
+ "they",
86
+ "this",
87
+ "us",
88
+ "we",
89
+ "what",
90
+ "which",
91
+ "who",
92
+ "you",
93
+ "your",
94
+ // Other common words
95
+ "as",
96
+ "if",
97
+ "not",
98
+ "no",
99
+ "yes",
100
+ "all",
101
+ "any",
102
+ "can",
103
+ "will",
104
+ "just",
105
+ "than",
106
+ "then",
107
+ "too",
108
+ "very",
109
+ ]);
110
+ //# sourceMappingURL=search-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-types.js","sourceRoot":"","sources":["../../src/types/search-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgFH,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAuB,CAAC;AAExD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAC;IACtD,WAAW;IACX,GAAG;IACH,IAAI;IACJ,KAAK;IACL,eAAe;IACf,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,MAAM;IACN,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,MAAM;IACN,KAAK;IACL,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,eAAe;IACf,KAAK;IACL,KAAK;IACL,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,eAAe;IACf,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,MAAM;IACN,OAAO;IACP,KAAK;IACL,IAAI;IACJ,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,KAAK;IACL,MAAM;IACN,QAAQ;IACR,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;IACL,MAAM;IACN,WAAW;IACX,IAAI;IACJ,KAAK;IACL,KAAK;IACL,KAAK;IACL,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,OAAO;IACP,KAAK;IACL,KAAK;IACL,MAAM;IACN,qBAAqB;IACrB,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;CACN,CAAC,CAAC"}