@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,343 @@
1
+ /**
2
+ * Core type definitions for CRUD operations with full type safety
3
+ */
4
+ import type { Effect } from "effect";
5
+ import type { TransactionError } from "../errors/crud-errors.js";
6
+ import type { SmartCollection } from "./types.js";
7
+ /**
8
+ * Base requirements for all entities in the database
9
+ */
10
+ export interface BaseEntity {
11
+ id: string;
12
+ createdAt?: string;
13
+ updatedAt?: string;
14
+ }
15
+ /**
16
+ * Minimal entity type with just id field
17
+ */
18
+ export interface MinimalEntity {
19
+ id: string;
20
+ }
21
+ /**
22
+ * Input type for create operations
23
+ * - ID is optional (will be auto-generated if not provided)
24
+ * - Timestamps are excluded (will be auto-generated)
25
+ */
26
+ export type CreateInput<T> = Omit<T, "id" | "createdAt" | "updatedAt"> & {
27
+ id?: string;
28
+ };
29
+ /**
30
+ * Options for batch create operations
31
+ */
32
+ export type CreateManyOptions = {
33
+ skipDuplicates?: boolean;
34
+ validateRelationships?: boolean;
35
+ };
36
+ /**
37
+ * Input type for update operations
38
+ * - ID and createdAt are immutable
39
+ * - All other fields are optional
40
+ */
41
+ export type UpdateInput<T> = Partial<Omit<T, "id" | "createdAt">> & {
42
+ updatedAt?: string;
43
+ };
44
+ /**
45
+ * Type-safe update operators for different field types
46
+ */
47
+ export type UpdateOperatorValue<T> = T extends number ? {
48
+ $increment?: number;
49
+ $decrement?: number;
50
+ $multiply?: number;
51
+ $set?: T;
52
+ } : T extends string ? {
53
+ $set?: T;
54
+ $append?: string;
55
+ $prepend?: string;
56
+ } : T extends unknown[] ? {
57
+ $append?: T extends (infer U)[] ? U | U[] : never;
58
+ $prepend?: T extends (infer U)[] ? U | U[] : never;
59
+ $remove?: T extends (infer U)[] ? U | ((item: U) => boolean) : never;
60
+ $set?: T;
61
+ } : T extends boolean ? {
62
+ $set?: T;
63
+ $toggle?: boolean;
64
+ } : {
65
+ $set?: T;
66
+ };
67
+ /**
68
+ * Primitive types that should not be treated as "nestable" objects for updates
69
+ */
70
+ type UpdatePrimitive = string | number | boolean | bigint | symbol | undefined | null;
71
+ /**
72
+ * Field update value that supports nested object deep merge.
73
+ * When T is an object type (not primitive, array, Date, etc.), this allows either:
74
+ * - Direct value T (replace entirely)
75
+ * - Standard update operators (UpdateOperatorValue<T>)
76
+ * - Nested object with update values on T's own fields (deep merge)
77
+ *
78
+ * The nested form is limited to 2 levels to avoid infinite recursion.
79
+ */
80
+ type FieldUpdateValue<T> = T extends UpdatePrimitive ? T | UpdateOperatorValue<T> : T extends readonly unknown[] ? T | UpdateOperatorValue<T> : T extends Date ? T | UpdateOperatorValue<T> : T extends (...args: unknown[]) => unknown ? T | UpdateOperatorValue<T> : T extends object ? T | UpdateOperatorValue<T> | NestedFieldUpdateValue<T> : T | UpdateOperatorValue<T>;
81
+ /**
82
+ * Nested field update value for second level (no further recursion).
83
+ * Allows specifying partial update values on the nested object's fields.
84
+ */
85
+ type NestedFieldUpdateValue<T> = {
86
+ [K in keyof T]?: T[K] | UpdateOperatorValue<T[K]>;
87
+ };
88
+ /**
89
+ * Update input with support for operators and nested object deep merge.
90
+ *
91
+ * For nested objects, this allows:
92
+ * - `{ metadata: { views: 500 } }` - deep merge, preserves sibling fields
93
+ * - `{ metadata: { views: { $increment: 1 } } }` - operator at nested level
94
+ * - `{ metadata: { $set: { views: 0 } } }` - replace entire nested object
95
+ */
96
+ export type UpdateWithOperators<T> = {
97
+ [K in keyof UpdateInput<T>]?: FieldUpdateValue<K extends keyof T ? T[K] : never>;
98
+ };
99
+ /**
100
+ * Options for delete operations
101
+ * - Soft delete is only available if entity has deletedAt field
102
+ */
103
+ export type DeleteOptions<T> = T extends {
104
+ deletedAt?: string | null | undefined;
105
+ } ? {
106
+ soft?: boolean;
107
+ returnDeleted?: boolean;
108
+ } : {
109
+ returnDeleted?: boolean;
110
+ };
111
+ /**
112
+ * Options for batch delete operations
113
+ */
114
+ export type DeleteManyOptions<T> = DeleteOptions<T> & {
115
+ limit?: number;
116
+ };
117
+ /**
118
+ * Input for upsert operations
119
+ * - Where clause must use unique fields
120
+ * - Create and update can have different shapes
121
+ */
122
+ export type UpsertInput<T, UniqueFields extends keyof T = never> = {
123
+ where: [UniqueFields] extends [never] ? {
124
+ id: string;
125
+ } : Pick<T, UniqueFields> | {
126
+ id: string;
127
+ };
128
+ create: CreateInput<T>;
129
+ update: UpdateWithOperators<T>;
130
+ };
131
+ /**
132
+ * Internal input type for upsert operations.
133
+ * Allows any where clause since validation is done at runtime.
134
+ * Use this for internal implementation; UpsertInput provides compile-time safety.
135
+ */
136
+ export type UpsertInternalInput<T> = {
137
+ where: Partial<T> | {
138
+ id: string;
139
+ };
140
+ create: CreateInput<T>;
141
+ update: UpdateWithOperators<T>;
142
+ };
143
+ /**
144
+ * Result type for upsert operations
145
+ * Includes metadata about whether entity was created or updated
146
+ */
147
+ export type UpsertResult<T> = T & {
148
+ __action: "created" | "updated";
149
+ };
150
+ /**
151
+ * Result for batch operations that can partially fail
152
+ */
153
+ export type BatchResult<T, E = never> = {
154
+ success: T[];
155
+ failed: Array<{
156
+ data: Partial<T>;
157
+ error: E;
158
+ index: number;
159
+ }>;
160
+ skipped?: Array<{
161
+ data: Partial<T>;
162
+ reason: string;
163
+ index: number;
164
+ }>;
165
+ };
166
+ /**
167
+ * Result for createMany operations
168
+ */
169
+ export type CreateManyResult<T> = {
170
+ created: T[];
171
+ skipped?: Array<{
172
+ data: Partial<T>;
173
+ reason: string;
174
+ }>;
175
+ };
176
+ /**
177
+ * Result for updateMany operations
178
+ */
179
+ export type UpdateManyResult<T> = {
180
+ count: number;
181
+ updated: T[];
182
+ };
183
+ /**
184
+ * Result for deleteMany operations
185
+ */
186
+ export type DeleteManyResult<T> = {
187
+ count: number;
188
+ deleted: T[];
189
+ };
190
+ /**
191
+ * Result for upsertMany operations
192
+ */
193
+ export type UpsertManyResult<T> = {
194
+ created: T[];
195
+ updated: T[];
196
+ unchanged: T[];
197
+ };
198
+ /**
199
+ * Result of validation operations
200
+ */
201
+ export type ValidationResult<_T = unknown> = {
202
+ valid: boolean;
203
+ errors: Array<{
204
+ field: string;
205
+ message: string;
206
+ value?: unknown;
207
+ code?: string;
208
+ }>;
209
+ warnings?: Array<{
210
+ field: string;
211
+ message: string;
212
+ }>;
213
+ };
214
+ /**
215
+ * Foreign key validation configuration
216
+ */
217
+ export type ForeignKeyValidation = {
218
+ field: string;
219
+ foreignKey: string;
220
+ targetCollection: string;
221
+ optional?: boolean;
222
+ };
223
+ /**
224
+ * Transaction context for multi-operation atomicity.
225
+ * Provides collection accessors, lifecycle methods, and introspection.
226
+ */
227
+ export type TransactionContext<DB = Record<string, SmartCollection<unknown>>> = {
228
+ /** Finalize changes, trigger persistence for mutated collections, mark inactive */
229
+ readonly commit: () => Effect.Effect<void, TransactionError>;
230
+ /** Restore all snapshots, mark inactive, trigger no persistence. Always fails to short-circuit. */
231
+ readonly rollback: () => Effect.Effect<never, TransactionError>;
232
+ /** Whether the transaction is still open */
233
+ readonly isActive: boolean;
234
+ /** Which collections have been written to during the transaction */
235
+ readonly mutatedCollections: ReadonlySet<string>;
236
+ } & {
237
+ /** Collection accessors — same interface as db.collectionName */
238
+ readonly [K in keyof DB]: DB[K];
239
+ };
240
+ /**
241
+ * Helper to make specific fields optional
242
+ */
243
+ export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
244
+ /**
245
+ * Helper to make specific fields required
246
+ */
247
+ export type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
248
+ /**
249
+ * Deep partial type that handles nested objects
250
+ */
251
+ export type DeepPartial<T> = T extends object ? {
252
+ [P in keyof T]?: DeepPartial<T[P]>;
253
+ } : T;
254
+ /**
255
+ * Extract the entity type from a collection
256
+ */
257
+ export type ExtractEntity<T> = T extends {
258
+ query: () => AsyncIterable<infer E>;
259
+ } ? E : never;
260
+ /**
261
+ * Check if a type has a specific field
262
+ */
263
+ export type HasField<T, K extends string> = K extends keyof T ? true : false;
264
+ /**
265
+ * Type guard for checking if value is an update operator
266
+ */
267
+ export declare function isUpdateOperator(value: unknown): value is Record<string, unknown>;
268
+ /**
269
+ * Type guard for checking if entity has soft delete capability
270
+ */
271
+ export declare function hasSoftDelete<T extends MinimalEntity>(entity: T): entity is T & {
272
+ deletedAt?: string;
273
+ };
274
+ /**
275
+ * Helper to create delete options for soft-deletable entities
276
+ */
277
+ export declare function softDelete(returnDeleted?: boolean): SoftDeleteOptions;
278
+ /**
279
+ * Helper to create delete options for hard delete
280
+ */
281
+ export declare function hardDelete(returnDeleted?: boolean): HardDeleteOptions;
282
+ /**
283
+ * Helper to create deleteMany options for soft-deletable entities
284
+ */
285
+ export declare function softDeleteMany(options?: {
286
+ returnDeleted?: boolean;
287
+ limit?: number;
288
+ }): SoftDeleteManyOptions;
289
+ /**
290
+ * Helper to create deleteMany options for hard delete
291
+ */
292
+ export declare function hardDeleteMany(options?: {
293
+ returnDeleted?: boolean;
294
+ limit?: number;
295
+ }): HardDeleteManyOptions;
296
+ /**
297
+ * Constraint for entities that support soft delete
298
+ */
299
+ export type SoftDeletable = {
300
+ deletedAt?: string;
301
+ };
302
+ /**
303
+ * Check if a type is soft deletable at the type level
304
+ */
305
+ export type IsSoftDeletable<T> = T extends SoftDeletable ? true : false;
306
+ /**
307
+ * Extract entities that support soft delete
308
+ */
309
+ export type ExtractSoftDeletable<T> = T extends SoftDeletable ? T : never;
310
+ /**
311
+ * Extract entities that don't support soft delete
312
+ */
313
+ export type ExtractNonSoftDeletable<T> = T extends SoftDeletable ? never : T;
314
+ /**
315
+ * Explicit delete options for soft-deletable entities
316
+ */
317
+ export type SoftDeleteOptions = {
318
+ soft?: boolean;
319
+ returnDeleted?: boolean;
320
+ };
321
+ /**
322
+ * Explicit delete options for non-soft-deletable entities
323
+ */
324
+ export type HardDeleteOptions = {
325
+ returnDeleted?: boolean;
326
+ };
327
+ /**
328
+ * Explicit delete many options for soft-deletable entities
329
+ */
330
+ export type SoftDeleteManyOptions = {
331
+ soft?: boolean;
332
+ returnDeleted?: boolean;
333
+ limit?: number;
334
+ };
335
+ /**
336
+ * Explicit delete many options for non-soft-deletable entities
337
+ */
338
+ export type HardDeleteManyOptions = {
339
+ returnDeleted?: boolean;
340
+ limit?: number;
341
+ };
342
+ export {};
343
+ //# sourceMappingURL=crud-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crud-types.d.ts","sourceRoot":"","sources":["../../src/types/crud-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAMlD;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,EAAE,EAAE,MAAM,CAAC;CACX;AAMD;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,WAAW,GAAG,WAAW,CAAC,GAAG;IACxE,EAAE,CAAC,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAMF;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,WAAW,CAAC,CAAC,GAAG;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAA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C,IAAI,CAAC,SAAS,aAAa,GAAG,KAAK,GAAG,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IACnC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IACnC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Core type definitions for CRUD operations with full type safety
3
+ */
4
+ /**
5
+ * Type guard for checking if value is an update operator
6
+ */
7
+ export function isUpdateOperator(value) {
8
+ if (typeof value !== "object" || value === null)
9
+ return false;
10
+ const keys = Object.keys(value);
11
+ return keys.some((key) => key.startsWith("$"));
12
+ }
13
+ /**
14
+ * Type guard for checking if entity has soft delete capability
15
+ */
16
+ export function hasSoftDelete(entity) {
17
+ return "deletedAt" in entity;
18
+ }
19
+ /**
20
+ * Helper to create delete options for soft-deletable entities
21
+ */
22
+ export function softDelete(returnDeleted = false) {
23
+ return { soft: true, returnDeleted };
24
+ }
25
+ /**
26
+ * Helper to create delete options for hard delete
27
+ */
28
+ export function hardDelete(returnDeleted = false) {
29
+ return { returnDeleted };
30
+ }
31
+ /**
32
+ * Helper to create deleteMany options for soft-deletable entities
33
+ */
34
+ export function softDeleteMany(options = {}) {
35
+ return { soft: true, ...options };
36
+ }
37
+ /**
38
+ * Helper to create deleteMany options for hard delete
39
+ */
40
+ export function hardDeleteMany(options = {}) {
41
+ return options;
42
+ }
43
+ //# sourceMappingURL=crud-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crud-types.js","sourceRoot":"","sources":["../../src/types/crud-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAwWH;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC/B,KAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAC5B,MAAS;IAET,OAAO,WAAW,IAAI,MAAM,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,gBAAyB,KAAK;IACxD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,gBAAyB,KAAK;IACxD,OAAO,EAAE,aAAa,EAAE,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC7B,UAAuD,EAAE;IAEzD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC7B,UAAuD,EAAE;IAEzD,OAAO,OAAO,CAAC;AAChB,CAAC"}
@@ -0,0 +1,52 @@
1
+ import type { Effect } from "effect";
2
+ /**
3
+ * Configuration for cursor-based pagination.
4
+ *
5
+ * Cursor pagination anchors page boundaries to a specific record's sort key
6
+ * value rather than a numeric position, eliminating duplicates/skips when
7
+ * data changes between page fetches.
8
+ */
9
+ export interface CursorConfig {
10
+ /** The field used as the cursor (sort key), e.g. "createdAt", "id" */
11
+ readonly key: string;
12
+ /** Fetch items after this cursor value (forward pagination) */
13
+ readonly after?: string;
14
+ /** Fetch items before this cursor value (backward pagination) */
15
+ readonly before?: string;
16
+ /** Maximum items per page (required, no default) */
17
+ readonly limit: number;
18
+ }
19
+ /**
20
+ * Metadata about page boundaries for cursor pagination.
21
+ */
22
+ export interface CursorPageInfo {
23
+ /** Cursor of the first item in the page (null if empty) */
24
+ readonly startCursor: string | null;
25
+ /** Cursor of the last item in the page (null if empty) */
26
+ readonly endCursor: string | null;
27
+ /** Whether more items exist after this page */
28
+ readonly hasNextPage: boolean;
29
+ /** Whether more items exist before this page */
30
+ readonly hasPreviousPage: boolean;
31
+ }
32
+ /**
33
+ * Result of a cursor-paginated query.
34
+ *
35
+ * Contains the page items and metadata about page boundaries.
36
+ */
37
+ export interface CursorPageResult<T> {
38
+ /** The items in this page */
39
+ readonly items: ReadonlyArray<T>;
40
+ /** Page boundary metadata */
41
+ readonly pageInfo: CursorPageInfo;
42
+ }
43
+ /**
44
+ * An Effect returning a CursorPageResult with a lazy `.runPromise` getter
45
+ * for non-Effect consumers.
46
+ *
47
+ * Accessing `.runPromise` runs the effect and returns a Promise.
48
+ */
49
+ export type RunnableCursorPage<T, E> = Effect.Effect<CursorPageResult<T>, E, never> & {
50
+ readonly runPromise: Promise<CursorPageResult<T>>;
51
+ };
52
+ //# sourceMappingURL=cursor-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor-types.d.ts","sourceRoot":"","sources":["../../src/types/cursor-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMrC;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,iEAAiE;IACjE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,2DAA2D;IAC3D,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,gDAAgD;IAChD,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC;IAClC,6BAA6B;IAC7B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACjC,6BAA6B;IAC7B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;CAClC;AAED;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,MAAM,CACnD,gBAAgB,CAAC,CAAC,CAAC,EACnB,CAAC,EACD,KAAK,CACL,GAAG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;CAClD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cursor-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor-types.js","sourceRoot":"","sources":["../../src/types/cursor-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Enhanced database configuration types that support persistence options.
3
+ * Extends the existing configuration to include optional file paths for collections.
4
+ */
5
+ import type { Schema } from "effect";
6
+ import type { Migration } from "../migrations/migration-types.js";
7
+ import type { ComputedFieldsConfig } from "./computed-types.js";
8
+ import type { HooksConfig } from "./hook-types.js";
9
+ /**
10
+ * Configuration for a single collection, now with optional persistence support.
11
+ */
12
+ export type CollectionConfig = {
13
+ /**
14
+ * Effect Schema for validating and encoding/decoding entities in this collection
15
+ */
16
+ readonly schema: Schema.Schema.All;
17
+ /**
18
+ * Optional file path for persisting this collection.
19
+ * If not provided, the collection will be in-memory only.
20
+ * Multiple collections can share the same file path.
21
+ */
22
+ readonly file?: string;
23
+ /**
24
+ * Relationship definitions for this collection
25
+ */
26
+ readonly relationships: Record<string, {
27
+ readonly type: "ref" | "inverse";
28
+ readonly target: string;
29
+ readonly foreignKey?: string;
30
+ }>;
31
+ /**
32
+ * Index definitions for this collection.
33
+ * Each entry can be a single field name (string) or an array of field names (compound index).
34
+ * Indexes accelerate equality queries on the specified fields.
35
+ */
36
+ readonly indexes?: ReadonlyArray<string | ReadonlyArray<string>>;
37
+ /**
38
+ * Lifecycle hooks for this collection.
39
+ * Hooks intercept CRUD operations for transformation, validation, or side effects.
40
+ * Before-hooks can transform data or reject operations.
41
+ * After-hooks and onChange run fire-and-forget after mutation.
42
+ */
43
+ readonly hooks?: HooksConfig<unknown>;
44
+ /**
45
+ * Schema version for this collection.
46
+ * When defined, the collection participates in schema migrations.
47
+ * The version number is stored in the persisted file as `_version`.
48
+ */
49
+ readonly version?: number;
50
+ /**
51
+ * Migration chain for this collection.
52
+ * Each migration transforms data from one version to the next.
53
+ * The chain must be contiguous: migrations[i].to === migrations[i].from + 1
54
+ * and the last migration's `to` must match the config `version`.
55
+ */
56
+ readonly migrations?: ReadonlyArray<Migration>;
57
+ /**
58
+ * Unique field constraints for this collection.
59
+ * Each entry can be a single field name (string) or an array of field names (compound unique constraint).
60
+ * Single strings are normalized to single-element arrays internally.
61
+ * Example: ["email", ["userId", "settingKey"]] means:
62
+ * - "email" must be unique across all entities
63
+ * - The combination of "userId" + "settingKey" must be unique
64
+ */
65
+ readonly uniqueFields?: ReadonlyArray<string | ReadonlyArray<string>>;
66
+ /**
67
+ * Computed field definitions for this collection.
68
+ * Computed fields are derived at query time from stored entity data.
69
+ * They are never persisted to disk - only materialized in the query pipeline.
70
+ *
71
+ * Each entry maps a field name to a derivation function.
72
+ * The function receives the entity (with populated relationships if applicable) and returns the computed value.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * computed: {
77
+ * displayName: (book) => `${book.title} (${book.year})`,
78
+ * isClassic: (book) => book.year < 1980,
79
+ * }
80
+ * ```
81
+ */
82
+ readonly computed?: ComputedFieldsConfig<unknown>;
83
+ /**
84
+ * Fields to include in the full-text search index for this collection.
85
+ * When specified, an inverted index is built and maintained for fast text search.
86
+ * Each entry should be the name of a string-typed field on the entity.
87
+ *
88
+ * Queries using `$search` will leverage this index when available for the queried fields.
89
+ * If not specified, `$search` queries will scan all entities (slower but still functional).
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * searchIndex: ["title", "author", "description"]
94
+ * ```
95
+ */
96
+ readonly searchIndex?: ReadonlyArray<string>;
97
+ /**
98
+ * Name of an ID generator provided by a plugin.
99
+ * When specified and no `id` is provided during entity creation,
100
+ * the named generator is used to produce the ID.
101
+ *
102
+ * The generator must be registered by a plugin in the database options.
103
+ * At init time, validation ensures the named generator exists in the plugin registry.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * idGenerator: "snowflake" // uses generator from a plugin
108
+ * ```
109
+ */
110
+ readonly idGenerator?: string;
111
+ /**
112
+ * When true, the collection uses an append-only persistence strategy.
113
+ * Each `create()` appends a single JSONL line to the file instead of rewriting it.
114
+ *
115
+ * Restrictions when append-only:
116
+ * - `update()`, `updateMany()`, `delete()`, `deleteMany()` fail with OperationError
117
+ * - The file should use a `.jsonl` extension
118
+ * - `flush()` writes a clean canonical JSONL file
119
+ *
120
+ * Useful for event logs and audit trails where data is only ever inserted.
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * events: {
125
+ * schema: EventSchema,
126
+ * file: "./data/events.jsonl",
127
+ * appendOnly: true,
128
+ * relationships: {},
129
+ * }
130
+ * ```
131
+ */
132
+ readonly appendOnly?: boolean;
133
+ };
134
+ /**
135
+ * Complete database configuration type that preserves literal types
136
+ */
137
+ export type DatabaseConfig = Record<string, CollectionConfig>;
138
+ /**
139
+ * Reactive query configuration options for the database.
140
+ * Controls behavior of watch() and watchById() subscriptions.
141
+ */
142
+ export interface ReactiveConfig {
143
+ /**
144
+ * Debounce interval in milliseconds for change event processing.
145
+ * When multiple mutations occur in rapid succession, they are coalesced
146
+ * into a single re-evaluation after the debounce interval settles.
147
+ * Default: 10ms (fast enough for interactive use, long enough to batch bursts).
148
+ */
149
+ readonly debounceMs?: number;
150
+ }
151
+ /**
152
+ * Database-level options that include reactive query configuration.
153
+ * Used by database factory functions to configure database-wide behavior.
154
+ */
155
+ export interface DatabaseReactiveOptions {
156
+ /**
157
+ * Reactive query configuration.
158
+ * Controls debouncing and other behavior of watch() and watchById() methods.
159
+ */
160
+ readonly reactive?: ReactiveConfig;
161
+ }
162
+ /**
163
+ * Type guard to check if a collection configuration includes persistence
164
+ */
165
+ export declare function isCollectionPersistent(config: CollectionConfig): config is CollectionConfig & {
166
+ file: string;
167
+ };
168
+ /**
169
+ * Extract only the persistent collections from a database configuration
170
+ */
171
+ export type PersistentCollections<Config extends DatabaseConfig> = {
172
+ readonly [K in keyof Config]: Config[K] extends {
173
+ file: string;
174
+ } ? Config[K] : never;
175
+ };
176
+ /**
177
+ * Extract only the in-memory collections from a database configuration
178
+ */
179
+ export type InMemoryCollections<Config extends DatabaseConfig> = {
180
+ readonly [K in keyof Config]: Config[K] extends {
181
+ file?: undefined;
182
+ } ? Config[K] : never;
183
+ };
184
+ /**
185
+ * Helper type to extract file paths from a database configuration
186
+ */
187
+ export type ExtractFilePaths<Config extends DatabaseConfig> = {
188
+ readonly [K in keyof Config]: Config[K] extends {
189
+ file: infer F;
190
+ } ? F : never;
191
+ }[keyof Config];
192
+ /**
193
+ * Type for mapping file paths to the collections that use them
194
+ */
195
+ export type FileToCollectionsMap<Config extends DatabaseConfig> = Map<ExtractFilePaths<Config> & string, Array<keyof Config & string>>;
196
+ //# sourceMappingURL=database-config-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database-config-types.d.ts","sourceRoot":"","sources":["../../src/types/database-config-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC9B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAEnC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAC7B,MAAM,EACN;QACC,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;QACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;KAC7B,CACD,CAAC;IAEF;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAEjE;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAEtC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAE/C;;;;;;;OAOG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,MAA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AS;QAAE,IAAI,CAAC,EAAE,SAAS,CAAA;KAAE,GACjE,MAAM,CAAC,CAAC,CAAC,GACT,KAAK;CACR,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,MAAM,SAAS,cAAc,IAAI;IAC7D,QAAQ,EAAE,CAAC,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,CAAC,GAAG,KAAK;CAC7E,CAAC,MAAM,MAAM,CAAC,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,oBAAoB,CAAC,MAAM,SAAS,cAAc,IAAI,GAAG,CACpE,gBAAgB,CAAC,MAAM,CAAC,GAAG,MAAM,EACjC,KAAK,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,CAC5B,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Enhanced database configuration types that support persistence options.
3
+ * Extends the existing configuration to include optional file paths for collections.
4
+ */
5
+ /**
6
+ * Type guard to check if a collection configuration includes persistence
7
+ */
8
+ export function isCollectionPersistent(config) {
9
+ return typeof config.file === "string" && config.file.length > 0;
10
+ }
11
+ //# sourceMappingURL=database-config-types.js.map