@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,150 @@
1
+ /**
2
+ * Plugin registry builder.
3
+ * Validates plugins and merges their contributions into a single registry.
4
+ */
5
+ import { Effect } from "effect";
6
+ import { validateDependencies, validateOperatorConflicts, validatePlugin, } from "./plugin-validation.js";
7
+ /**
8
+ * Type guard to filter out undefined values from arrays.
9
+ */
10
+ const isDefined = (value) => value !== undefined;
11
+ // ============================================================================
12
+ // Plugin Registry Builder
13
+ // ============================================================================
14
+ /**
15
+ * Creates an empty PluginRegistry with no contributions.
16
+ */
17
+ const createEmptyRegistry = () => ({
18
+ codecs: [],
19
+ operators: new Map(),
20
+ idGenerators: new Map(),
21
+ globalHooks: {},
22
+ });
23
+ /**
24
+ * Builds a PluginRegistry from an array of plugins.
25
+ *
26
+ * This function:
27
+ * 1. Validates each plugin individually (structure, codecs, operators, generators)
28
+ * 2. Validates operator conflicts (between plugins and with built-in operators)
29
+ * 3. Validates dependencies (all declared dependencies must exist)
30
+ * 4. Merges codecs (append in registration order)
31
+ * 5. Merges operators into a Map (O(1) lookup)
32
+ * 6. Merges ID generators into a Map (O(1) lookup)
33
+ * 7. Merges global hooks (concatenate arrays in registration order)
34
+ *
35
+ * If plugins is undefined or empty, returns an empty registry.
36
+ *
37
+ * @param plugins - Array of plugins to validate and merge (optional)
38
+ * @returns Effect<PluginRegistry, PluginError> - The merged registry or validation error
39
+ */
40
+ export const buildPluginRegistry = (plugins) => {
41
+ // Handle empty or undefined plugin arrays
42
+ if (plugins === undefined || plugins.length === 0) {
43
+ return Effect.succeed(createEmptyRegistry());
44
+ }
45
+ return Effect.gen(function* () {
46
+ // Validate each plugin individually
47
+ for (const plugin of plugins) {
48
+ yield* validatePlugin(plugin);
49
+ }
50
+ // Validate operator conflicts
51
+ yield* validateOperatorConflicts(plugins);
52
+ // Validate dependencies
53
+ yield* validateDependencies(plugins);
54
+ // Merge codecs (append in registration order)
55
+ const codecs = plugins.flatMap((plugin) => plugin.codecs ?? []);
56
+ // Merge operators into a Map
57
+ const operators = new Map();
58
+ for (const plugin of plugins) {
59
+ if (plugin.operators !== undefined) {
60
+ for (const operator of plugin.operators) {
61
+ operators.set(operator.name, operator);
62
+ }
63
+ }
64
+ }
65
+ // Merge ID generators into a Map
66
+ const idGenerators = new Map();
67
+ for (const plugin of plugins) {
68
+ if (plugin.idGenerators !== undefined) {
69
+ for (const generator of plugin.idGenerators) {
70
+ idGenerators.set(generator.name, generator);
71
+ }
72
+ }
73
+ }
74
+ // Merge global hooks (concatenate arrays in registration order)
75
+ const globalHooks = mergeGlobalHooks(plugins);
76
+ return {
77
+ codecs,
78
+ operators,
79
+ idGenerators,
80
+ globalHooks,
81
+ };
82
+ });
83
+ };
84
+ /**
85
+ * Merges global hooks from all plugins.
86
+ * Hooks are concatenated in plugin registration order.
87
+ */
88
+ const mergeGlobalHooks = (plugins) => {
89
+ // Use a mutable object for building
90
+ const mutableResult = {};
91
+ for (const plugin of plugins) {
92
+ if (plugin.hooks === undefined) {
93
+ continue;
94
+ }
95
+ if (plugin.hooks.beforeCreate !== undefined) {
96
+ mutableResult.beforeCreate = mutableResult.beforeCreate ?? [];
97
+ mutableResult.beforeCreate.push(plugin.hooks.beforeCreate);
98
+ }
99
+ if (plugin.hooks.afterCreate !== undefined) {
100
+ mutableResult.afterCreate = mutableResult.afterCreate ?? [];
101
+ mutableResult.afterCreate.push(plugin.hooks.afterCreate);
102
+ }
103
+ if (plugin.hooks.beforeUpdate !== undefined) {
104
+ mutableResult.beforeUpdate = mutableResult.beforeUpdate ?? [];
105
+ mutableResult.beforeUpdate.push(plugin.hooks.beforeUpdate);
106
+ }
107
+ if (plugin.hooks.afterUpdate !== undefined) {
108
+ mutableResult.afterUpdate = mutableResult.afterUpdate ?? [];
109
+ mutableResult.afterUpdate.push(plugin.hooks.afterUpdate);
110
+ }
111
+ if (plugin.hooks.beforeDelete !== undefined) {
112
+ mutableResult.beforeDelete = mutableResult.beforeDelete ?? [];
113
+ mutableResult.beforeDelete.push(plugin.hooks.beforeDelete);
114
+ }
115
+ if (plugin.hooks.afterDelete !== undefined) {
116
+ mutableResult.afterDelete = mutableResult.afterDelete ?? [];
117
+ mutableResult.afterDelete.push(plugin.hooks.afterDelete);
118
+ }
119
+ if (plugin.hooks.onChange !== undefined) {
120
+ mutableResult.onChange = mutableResult.onChange ?? [];
121
+ mutableResult.onChange.push(plugin.hooks.onChange);
122
+ }
123
+ }
124
+ // Flatten the arrays
125
+ const finalResult = {};
126
+ if (mutableResult.beforeCreate !== undefined) {
127
+ finalResult.beforeCreate = mutableResult.beforeCreate.flat().filter(isDefined);
128
+ }
129
+ if (mutableResult.afterCreate !== undefined) {
130
+ finalResult.afterCreate = mutableResult.afterCreate.flat().filter(isDefined);
131
+ }
132
+ if (mutableResult.beforeUpdate !== undefined) {
133
+ finalResult.beforeUpdate = mutableResult.beforeUpdate.flat().filter(isDefined);
134
+ }
135
+ if (mutableResult.afterUpdate !== undefined) {
136
+ finalResult.afterUpdate = mutableResult.afterUpdate.flat().filter(isDefined);
137
+ }
138
+ if (mutableResult.beforeDelete !== undefined) {
139
+ finalResult.beforeDelete = mutableResult.beforeDelete.flat().filter(isDefined);
140
+ }
141
+ if (mutableResult.afterDelete !== undefined) {
142
+ finalResult.afterDelete = mutableResult.afterDelete.flat().filter(isDefined);
143
+ }
144
+ if (mutableResult.onChange !== undefined) {
145
+ finalResult.onChange =
146
+ mutableResult.onChange.flat().filter(isDefined);
147
+ }
148
+ return finalResult;
149
+ };
150
+ //# sourceMappingURL=plugin-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-registry.js","sourceRoot":"","sources":["../../src/plugins/plugin-registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAShC,OAAO,EACN,oBAAoB,EACpB,yBAAyB,EACzB,cAAc,GACd,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,MAAM,S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,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Plugin system types for extending ProseQL functionality.
3
+ * Plugins can provide custom codecs, operators, ID generators, and global lifecycle hooks.
4
+ */
5
+ import type { Effect } from "effect";
6
+ import type { FormatCodec } from "../serializers/format-codec.js";
7
+ import type { HooksConfig } from "../types/hook-types.js";
8
+ /**
9
+ * A custom query operator that extends the filter system.
10
+ * Operators must start with `$` prefix (e.g., `$regex`, `$fuzzy`).
11
+ */
12
+ export interface CustomOperator {
13
+ /** Operator name, must start with $ (e.g., "$regex", "$fuzzy") */
14
+ readonly name: string;
15
+ /** Field types this operator works with */
16
+ readonly types: ReadonlyArray<"string" | "number" | "boolean" | "array">;
17
+ /** Evaluates whether the field value matches the operand */
18
+ readonly evaluate: (fieldValue: unknown, operand: unknown) => boolean;
19
+ }
20
+ /**
21
+ * A custom ID generator that can be referenced by collections.
22
+ * Generators are named and referenced by string in collection config.
23
+ */
24
+ export interface CustomIdGenerator {
25
+ /** Generator name (e.g., "snowflake", "uuid-v7") */
26
+ readonly name: string;
27
+ /** Generates a unique ID string */
28
+ readonly generate: () => string;
29
+ }
30
+ /**
31
+ * Global hooks configuration that applies to all collections.
32
+ * Uses untyped Record<string, unknown> since global hooks span all collections.
33
+ */
34
+ export type GlobalHooksConfig = HooksConfig<Record<string, unknown>>;
35
+ /**
36
+ * A plugin that extends ProseQL functionality.
37
+ *
38
+ * Plugins can contribute:
39
+ * - Custom format codecs (serialization formats)
40
+ * - Custom query operators (filter extensions)
41
+ * - Custom ID generators (referenced by name in collection config)
42
+ * - Global lifecycle hooks (run before/after collection hooks)
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const myPlugin: ProseQLPlugin = {
47
+ * name: "my-plugin",
48
+ * version: "1.0.0",
49
+ * operators: [{
50
+ * name: "$regex",
51
+ * types: ["string"],
52
+ * evaluate: (value, pattern) =>
53
+ * typeof value === "string" && new RegExp(pattern as string).test(value)
54
+ * }],
55
+ * hooks: {
56
+ * beforeCreate: [(ctx) => Effect.succeed(ctx.data)]
57
+ * }
58
+ * }
59
+ * ```
60
+ */
61
+ export interface ProseQLPlugin {
62
+ /** Plugin name (required, must be non-empty) */
63
+ readonly name: string;
64
+ /** Plugin version (optional, for informational purposes) */
65
+ readonly version?: string;
66
+ /** Custom format codecs for serialization */
67
+ readonly codecs?: ReadonlyArray<FormatCodec>;
68
+ /** Custom query operators */
69
+ readonly operators?: ReadonlyArray<CustomOperator>;
70
+ /** Custom ID generators */
71
+ readonly idGenerators?: ReadonlyArray<CustomIdGenerator>;
72
+ /** Global lifecycle hooks */
73
+ readonly hooks?: GlobalHooksConfig;
74
+ /** Plugin dependencies (names of plugins that must be loaded first) */
75
+ readonly dependencies?: ReadonlyArray<string>;
76
+ /** Initialization Effect (runs once during database creation, after validation) */
77
+ readonly initialize?: () => Effect.Effect<void>;
78
+ /** Shutdown Effect (runs during scope finalization) */
79
+ readonly shutdown?: () => Effect.Effect<void>;
80
+ }
81
+ /**
82
+ * Resolved internal state holding merged plugin contributions.
83
+ * Built by `buildPluginRegistry` after validation.
84
+ */
85
+ export interface PluginRegistry {
86
+ /** All codecs from plugins (in registration order) */
87
+ readonly codecs: ReadonlyArray<FormatCodec>;
88
+ /** Custom operators by name (for O(1) lookup) */
89
+ readonly operators: Map<string, CustomOperator>;
90
+ /** ID generators by name (for O(1) lookup) */
91
+ readonly idGenerators: Map<string, CustomIdGenerator>;
92
+ /** Merged global hooks from all plugins */
93
+ readonly globalHooks: GlobalHooksConfig;
94
+ }
95
+ //# sourceMappingURL=plugin-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-types.d.ts","sourceRoot":"","sources":["../../src/plugins/plugin-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QA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AiB,CAAC;IACnC,uEAAuE;IACvE,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C,mFAAmF;IACnF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChD,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CAC9C;AAMD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC5C,iDAAiD;IACjD,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAChD,8CAA8C;IAC9C,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACtD,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;CACxC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Plugin system types for extending ProseQL functionality.
3
+ * Plugins can provide custom codecs, operators, ID generators, and global lifecycle hooks.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=plugin-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-types.js","sourceRoot":"","sources":["../../src/plugins/plugin-types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Plugin validation functions.
3
+ * Validates that plugins conform to the ProseQLPlugin interface and
4
+ * detects conflicts between plugins.
5
+ */
6
+ import { Effect } from "effect";
7
+ import { PluginError } from "../errors/plugin-errors.js";
8
+ import type { DatabaseConfig } from "../types/database-config-types.js";
9
+ import type { CustomIdGenerator, ProseQLPlugin } from "./plugin-types.js";
10
+ /**
11
+ * Validates that a plugin conforms to the ProseQLPlugin interface.
12
+ *
13
+ * Checks:
14
+ * - `name` is a non-empty string
15
+ * - `codecs` entries have `name`, `extensions`, `encode`, and `decode`
16
+ * - `operators` entries have `name` starting with `$` and an `evaluate` function
17
+ * - `idGenerators` entries have `name` and `generate`
18
+ *
19
+ * @param plugin - The plugin to validate
20
+ * @returns Effect<void, PluginError> - Succeeds if valid, fails with PluginError if not
21
+ */
22
+ export declare const validatePlugin: (plugin: ProseQLPlugin) => Effect.Effect<void, PluginError>;
23
+ /**
24
+ * Validates that all plugin dependencies are satisfied.
25
+ * For each plugin with `dependencies`, verifies that every dependency name
26
+ * appears in the plugin array.
27
+ *
28
+ * @param plugins - Array of plugins to validate
29
+ * @returns Effect<void, PluginError> - Succeeds if all dependencies satisfied, fails with PluginError listing missing dependencies
30
+ */
31
+ export declare const validateDependencies: (plugins: ReadonlyArray<ProseQLPlugin>) => Effect.Effect<void, PluginError>;
32
+ /**
33
+ * Validates that no custom operators conflict with built-in operators
34
+ * and that no two plugins register operators with the same name.
35
+ *
36
+ * @param plugins - Array of plugins to validate
37
+ * @returns Effect<void, PluginError> - Succeeds if no conflicts, fails with PluginError listing the conflict
38
+ */
39
+ export declare const validateOperatorConflicts: (plugins: ReadonlyArray<ProseQLPlugin>) => Effect.Effect<void, PluginError>;
40
+ /**
41
+ * Validates that all collection-configured `idGenerator` names exist in the plugin registry.
42
+ * Called at init time to ensure fast failure with clear error messages.
43
+ *
44
+ * @param config - The database configuration with collection configs
45
+ * @param idGenerators - Map of ID generator names to generators from the plugin registry
46
+ * @returns Effect<void, PluginError> - Succeeds if all references are valid, fails with PluginError listing the missing generator
47
+ */
48
+ export declare const validateIdGeneratorReferences: (config: DatabaseConfig, idGenerators: Map<string, CustomIdGenerator>) => Effect.Effect<void, PluginError>;
49
+ //# sourceMappingURL=plugin-validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-validation.d.ts","sourceRoot":"","sources":["../../src/plugins/plugin-validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EACX,iBAAiB,EAEjB,aAAa,EACb,MAAM,mBAAmB,CAAC;AAM3B;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAC1B,QAAQ,aAAa,KACnB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAgDjC,CAAC;AA4HF;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAChC,SAAS,aAAa,CAAC,aAAa,CAAC,KACnC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAuCjC,CAAC;AA0BF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GACrC,SAAS,aAAa,CAAC,aAAa,CAAC,KACnC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAyCjC,CAAC;AAMF;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,GACzC,QAAQ,cAAc,EACtB,cAAc,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,KAC1C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAuBjC,CAAC"}
@@ -0,0 +1,295 @@
1
+ /**
2
+ * Plugin validation functions.
3
+ * Validates that plugins conform to the ProseQLPlugin interface and
4
+ * detects conflicts between plugins.
5
+ */
6
+ import { Effect } from "effect";
7
+ import { PluginError } from "../errors/plugin-errors.js";
8
+ // ============================================================================
9
+ // Plugin Validation
10
+ // ============================================================================
11
+ /**
12
+ * Validates that a plugin conforms to the ProseQLPlugin interface.
13
+ *
14
+ * Checks:
15
+ * - `name` is a non-empty string
16
+ * - `codecs` entries have `name`, `extensions`, `encode`, and `decode`
17
+ * - `operators` entries have `name` starting with `$` and an `evaluate` function
18
+ * - `idGenerators` entries have `name` and `generate`
19
+ *
20
+ * @param plugin - The plugin to validate
21
+ * @returns Effect<void, PluginError> - Succeeds if valid, fails with PluginError if not
22
+ */
23
+ export const validatePlugin = (plugin) => {
24
+ return Effect.gen(function* () {
25
+ // Validate name is a non-empty string
26
+ if (typeof plugin.name !== "string" || plugin.name.trim() === "") {
27
+ return yield* Effect.fail(new PluginError({
28
+ plugin: plugin.name ?? "(unnamed)",
29
+ reason: "invalid_name",
30
+ message: "Plugin name must be a non-empty string",
31
+ }));
32
+ }
33
+ const pluginName = plugin.name;
34
+ // Validate codecs
35
+ if (plugin.codecs !== undefined) {
36
+ for (let i = 0; i < plugin.codecs.length; i++) {
37
+ const codec = plugin.codecs[i];
38
+ const codecError = validateCodec(codec, i, pluginName);
39
+ if (codecError !== null) {
40
+ return yield* Effect.fail(codecError);
41
+ }
42
+ }
43
+ }
44
+ // Validate operators
45
+ if (plugin.operators !== undefined) {
46
+ for (let i = 0; i < plugin.operators.length; i++) {
47
+ const operator = plugin.operators[i];
48
+ const operatorError = validateOperator(operator, i, pluginName);
49
+ if (operatorError !== null) {
50
+ return yield* Effect.fail(operatorError);
51
+ }
52
+ }
53
+ }
54
+ // Validate idGenerators
55
+ if (plugin.idGenerators !== undefined) {
56
+ for (let i = 0; i < plugin.idGenerators.length; i++) {
57
+ const generator = plugin.idGenerators[i];
58
+ const generatorError = validateIdGenerator(generator, i, pluginName);
59
+ if (generatorError !== null) {
60
+ return yield* Effect.fail(generatorError);
61
+ }
62
+ }
63
+ }
64
+ });
65
+ };
66
+ /**
67
+ * Validates a FormatCodec entry.
68
+ * Returns null if valid, PluginError if invalid.
69
+ */
70
+ const validateCodec = (codec, index, pluginName) => {
71
+ if (typeof codec.name !== "string" || codec.name.trim() === "") {
72
+ return new PluginError({
73
+ plugin: pluginName,
74
+ reason: "invalid_codec",
75
+ message: `Codec at index ${index} must have a non-empty 'name' string`,
76
+ });
77
+ }
78
+ if (!Array.isArray(codec.extensions) || codec.extensions.length === 0) {
79
+ return new PluginError({
80
+ plugin: pluginName,
81
+ reason: "invalid_codec",
82
+ message: `Codec '${codec.name}' must have a non-empty 'extensions' array`,
83
+ });
84
+ }
85
+ for (const ext of codec.extensions) {
86
+ if (typeof ext !== "string" || ext.trim() === "") {
87
+ return new PluginError({
88
+ plugin: pluginName,
89
+ reason: "invalid_codec",
90
+ message: `Codec '${codec.name}' has an invalid extension (must be a non-empty string)`,
91
+ });
92
+ }
93
+ }
94
+ if (typeof codec.encode !== "function") {
95
+ return new PluginError({
96
+ plugin: pluginName,
97
+ reason: "invalid_codec",
98
+ message: `Codec '${codec.name}' must have an 'encode' function`,
99
+ });
100
+ }
101
+ if (typeof codec.decode !== "function") {
102
+ return new PluginError({
103
+ plugin: pluginName,
104
+ reason: "invalid_codec",
105
+ message: `Codec '${codec.name}' must have a 'decode' function`,
106
+ });
107
+ }
108
+ return null;
109
+ };
110
+ /**
111
+ * Validates a CustomOperator entry.
112
+ * Returns null if valid, PluginError if invalid.
113
+ */
114
+ const validateOperator = (operator, index, pluginName) => {
115
+ if (typeof operator.name !== "string" || operator.name.trim() === "") {
116
+ return new PluginError({
117
+ plugin: pluginName,
118
+ reason: "invalid_operator",
119
+ message: `Operator at index ${index} must have a non-empty 'name' string`,
120
+ });
121
+ }
122
+ if (!operator.name.startsWith("$")) {
123
+ return new PluginError({
124
+ plugin: pluginName,
125
+ reason: "invalid_operator",
126
+ message: `Operator '${operator.name}' name must start with '$'`,
127
+ });
128
+ }
129
+ if (typeof operator.evaluate !== "function") {
130
+ return new PluginError({
131
+ plugin: pluginName,
132
+ reason: "invalid_operator",
133
+ message: `Operator '${operator.name}' must have an 'evaluate' function`,
134
+ });
135
+ }
136
+ return null;
137
+ };
138
+ /**
139
+ * Validates a CustomIdGenerator entry.
140
+ * Returns null if valid, PluginError if invalid.
141
+ */
142
+ const validateIdGenerator = (generator, index, pluginName) => {
143
+ if (typeof generator.name !== "string" || generator.name.trim() === "") {
144
+ return new PluginError({
145
+ plugin: pluginName,
146
+ reason: "invalid_id_generator",
147
+ message: `ID generator at index ${index} must have a non-empty 'name' string`,
148
+ });
149
+ }
150
+ if (typeof generator.generate !== "function") {
151
+ return new PluginError({
152
+ plugin: pluginName,
153
+ reason: "invalid_id_generator",
154
+ message: `ID generator '${generator.name}' must have a 'generate' function`,
155
+ });
156
+ }
157
+ return null;
158
+ };
159
+ // ============================================================================
160
+ // Dependency Validation
161
+ // ============================================================================
162
+ /**
163
+ * Validates that all plugin dependencies are satisfied.
164
+ * For each plugin with `dependencies`, verifies that every dependency name
165
+ * appears in the plugin array.
166
+ *
167
+ * @param plugins - Array of plugins to validate
168
+ * @returns Effect<void, PluginError> - Succeeds if all dependencies satisfied, fails with PluginError listing missing dependencies
169
+ */
170
+ export const validateDependencies = (plugins) => {
171
+ return Effect.gen(function* () {
172
+ // Build a set of all available plugin names
173
+ const availablePlugins = new Set();
174
+ for (const plugin of plugins) {
175
+ availablePlugins.add(plugin.name);
176
+ }
177
+ // Check each plugin's dependencies
178
+ for (const plugin of plugins) {
179
+ if (plugin.dependencies === undefined ||
180
+ plugin.dependencies.length === 0) {
181
+ continue;
182
+ }
183
+ const missingDependencies = [];
184
+ for (const dependency of plugin.dependencies) {
185
+ if (!availablePlugins.has(dependency)) {
186
+ missingDependencies.push(dependency);
187
+ }
188
+ }
189
+ if (missingDependencies.length > 0) {
190
+ const missingList = missingDependencies.join(", ");
191
+ return yield* Effect.fail(new PluginError({
192
+ plugin: plugin.name,
193
+ reason: "missing_dependencies",
194
+ message: missingDependencies.length === 1
195
+ ? `Missing dependency: ${missingList}`
196
+ : `Missing dependencies: ${missingList}`,
197
+ }));
198
+ }
199
+ }
200
+ });
201
+ };
202
+ // ============================================================================
203
+ // Operator Conflict Validation
204
+ // ============================================================================
205
+ /**
206
+ * Built-in operator names that custom operators cannot use.
207
+ */
208
+ const BUILT_IN_OPERATORS = new Set([
209
+ "$eq",
210
+ "$ne",
211
+ "$in",
212
+ "$nin",
213
+ "$gt",
214
+ "$gte",
215
+ "$lt",
216
+ "$lte",
217
+ "$startsWith",
218
+ "$endsWith",
219
+ "$contains",
220
+ "$all",
221
+ "$size",
222
+ "$search",
223
+ ]);
224
+ /**
225
+ * Validates that no custom operators conflict with built-in operators
226
+ * and that no two plugins register operators with the same name.
227
+ *
228
+ * @param plugins - Array of plugins to validate
229
+ * @returns Effect<void, PluginError> - Succeeds if no conflicts, fails with PluginError listing the conflict
230
+ */
231
+ export const validateOperatorConflicts = (plugins) => {
232
+ return Effect.gen(function* () {
233
+ // Track which plugin registered which operator
234
+ const operatorRegistry = new Map();
235
+ for (const plugin of plugins) {
236
+ if (plugin.operators === undefined) {
237
+ continue;
238
+ }
239
+ for (const operator of plugin.operators) {
240
+ const operatorName = operator.name;
241
+ // Check for conflict with built-in operators
242
+ if (BUILT_IN_OPERATORS.has(operatorName)) {
243
+ return yield* Effect.fail(new PluginError({
244
+ plugin: plugin.name,
245
+ reason: "operator_conflict",
246
+ message: `Operator '${operatorName}' conflicts with built-in operator`,
247
+ }));
248
+ }
249
+ // Check for conflict with another plugin's operator
250
+ const existingPlugin = operatorRegistry.get(operatorName);
251
+ if (existingPlugin !== undefined) {
252
+ return yield* Effect.fail(new PluginError({
253
+ plugin: plugin.name,
254
+ reason: "operator_conflict",
255
+ message: `Operator '${operatorName}' conflicts with operator from plugin '${existingPlugin}'`,
256
+ }));
257
+ }
258
+ // Register this operator
259
+ operatorRegistry.set(operatorName, plugin.name);
260
+ }
261
+ }
262
+ });
263
+ };
264
+ // ============================================================================
265
+ // ID Generator Reference Validation
266
+ // ============================================================================
267
+ /**
268
+ * Validates that all collection-configured `idGenerator` names exist in the plugin registry.
269
+ * Called at init time to ensure fast failure with clear error messages.
270
+ *
271
+ * @param config - The database configuration with collection configs
272
+ * @param idGenerators - Map of ID generator names to generators from the plugin registry
273
+ * @returns Effect<void, PluginError> - Succeeds if all references are valid, fails with PluginError listing the missing generator
274
+ */
275
+ export const validateIdGeneratorReferences = (config, idGenerators) => {
276
+ return Effect.gen(function* () {
277
+ for (const collectionName of Object.keys(config)) {
278
+ const collectionConfig = config[collectionName];
279
+ const idGeneratorName = collectionConfig.idGenerator;
280
+ // Skip collections without idGenerator configured
281
+ if (idGeneratorName === undefined) {
282
+ continue;
283
+ }
284
+ // Check if the referenced generator exists in the registry
285
+ if (!idGenerators.has(idGeneratorName)) {
286
+ return yield* Effect.fail(new PluginError({
287
+ plugin: "(collection config)",
288
+ reason: "missing_id_generator",
289
+ message: `Collection '${collectionName}' references idGenerator '${idGeneratorName}' which is not registered by any plugin`,
290
+ }));
291
+ }
292
+ }
293
+ });
294
+ };
295
+ //# sourceMappingURL=plugin-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-validation.js","sourceRoot":"","sources":["../../src/plugins/plugin-validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AASzD,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC7B,MAAqB,EACc,EAAE;IACrC,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC1B,sCAAsC;QACtC,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAClE,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CACxB,IAAI,WAAW,CAAC;gBACf,MAAM,EAAE,MAAM,CAAC,IAAI,IAAI,WAAW;gBAClC,MAAM,EAAE,cAAc;gBACtB,OAAO,EAAE,wCAAwC;aACjD,CAAC,CACF,CAAC;QACH,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC;QAE/B,kBAAkB;QAClB,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACjC,KA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