@vexcms/core 0.0.19 → 0.1.0-alpha.2

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 (323) hide show
  1. package/LICENSE +202 -0
  2. package/dist/.build +1 -0
  3. package/dist/access/buildChecks.d.ts +58 -0
  4. package/dist/access/buildChecks.d.ts.map +1 -0
  5. package/dist/access/canAccessAdminPanel.d.ts +53 -0
  6. package/dist/access/canAccessAdminPanel.d.ts.map +1 -0
  7. package/dist/access/compileConstraints.d.ts +155 -0
  8. package/dist/access/compileConstraints.d.ts.map +1 -0
  9. package/dist/access/config.d.ts +62 -0
  10. package/dist/access/config.d.ts.map +1 -0
  11. package/dist/access/constants.d.ts +95 -0
  12. package/dist/access/constants.d.ts.map +1 -0
  13. package/dist/access/constraintTypes.d.ts +337 -0
  14. package/dist/access/constraintTypes.d.ts.map +1 -0
  15. package/dist/access/createAccessQueryBuilder.d.ts +59 -0
  16. package/dist/access/createAccessQueryBuilder.d.ts.map +1 -0
  17. package/dist/access/createFilterConstraintBuilder.d.ts +26 -0
  18. package/dist/access/createFilterConstraintBuilder.d.ts.map +1 -0
  19. package/dist/access/createIndexConstraintBuilder.d.ts +40 -0
  20. package/dist/access/createIndexConstraintBuilder.d.ts.map +1 -0
  21. package/dist/access/hasPermission.d.ts +85 -0
  22. package/dist/access/hasPermission.d.ts.map +1 -0
  23. package/dist/access/index.d.ts +13 -0
  24. package/dist/access/index.d.ts.map +1 -0
  25. package/dist/access/pickQueryIndex.d.ts +42 -0
  26. package/dist/access/pickQueryIndex.d.ts.map +1 -0
  27. package/dist/access/resolveAccessRule.d.ts +85 -0
  28. package/dist/access/resolveAccessRule.d.ts.map +1 -0
  29. package/dist/access/types.d.ts +738 -0
  30. package/dist/access/types.d.ts.map +1 -0
  31. package/dist/access/validateAccessConstraints.d.ts +57 -0
  32. package/dist/access/validateAccessConstraints.d.ts.map +1 -0
  33. package/dist/api/client.d.ts +20 -0
  34. package/dist/api/client.d.ts.map +1 -0
  35. package/dist/api/client.js +117 -0
  36. package/dist/api/client.js.map +1 -0
  37. package/dist/api/convex.d.ts +296 -0
  38. package/dist/api/convex.d.ts.map +1 -0
  39. package/dist/api/create/client.d.ts +50 -0
  40. package/dist/api/create/client.d.ts.map +1 -0
  41. package/dist/api/create/server.d.ts +43 -0
  42. package/dist/api/create/server.d.ts.map +1 -0
  43. package/dist/api/depth.d.ts +39 -0
  44. package/dist/api/depth.d.ts.map +1 -0
  45. package/dist/api/find/client.d.ts +90 -0
  46. package/dist/api/find/client.d.ts.map +1 -0
  47. package/dist/api/find/server.d.ts +73 -0
  48. package/dist/api/find/server.d.ts.map +1 -0
  49. package/dist/api/get/client.d.ts +56 -0
  50. package/dist/api/get/client.d.ts.map +1 -0
  51. package/dist/api/get/server.d.ts +49 -0
  52. package/dist/api/get/server.d.ts.map +1 -0
  53. package/dist/api/globals/find.client.d.ts +20 -0
  54. package/dist/api/globals/find.client.d.ts.map +1 -0
  55. package/dist/api/globals/find.server.d.ts +29 -0
  56. package/dist/api/globals/find.server.d.ts.map +1 -0
  57. package/dist/api/globals/get.client.d.ts +46 -0
  58. package/dist/api/globals/get.client.d.ts.map +1 -0
  59. package/dist/api/globals/get.server.d.ts +55 -0
  60. package/dist/api/globals/get.server.d.ts.map +1 -0
  61. package/dist/api/globals/types.d.ts +65 -0
  62. package/dist/api/globals/types.d.ts.map +1 -0
  63. package/dist/api/globals/upsert.client.d.ts +24 -0
  64. package/dist/api/globals/upsert.client.d.ts.map +1 -0
  65. package/dist/api/globals/upsert.server.d.ts +47 -0
  66. package/dist/api/globals/upsert.server.d.ts.map +1 -0
  67. package/dist/api/populate.d.ts +23 -0
  68. package/dist/api/populate.d.ts.map +1 -0
  69. package/dist/api/remove/client.d.ts +58 -0
  70. package/dist/api/remove/client.d.ts.map +1 -0
  71. package/dist/api/remove/server.d.ts +65 -0
  72. package/dist/api/remove/server.d.ts.map +1 -0
  73. package/dist/api/search/client.d.ts +58 -0
  74. package/dist/api/search/client.d.ts.map +1 -0
  75. package/dist/api/search/server.d.ts +54 -0
  76. package/dist/api/search/server.d.ts.map +1 -0
  77. package/dist/api/server.d.ts +370 -0
  78. package/dist/api/server.d.ts.map +1 -0
  79. package/dist/api/server.js +33 -0
  80. package/dist/api/server.js.map +1 -0
  81. package/dist/api/types.d.ts +525 -0
  82. package/dist/api/types.d.ts.map +1 -0
  83. package/dist/api/update/client.d.ts +53 -0
  84. package/dist/api/update/client.d.ts.map +1 -0
  85. package/dist/api/update/server.d.ts +47 -0
  86. package/dist/api/update/server.d.ts.map +1 -0
  87. package/dist/api/utils.d.ts +57 -0
  88. package/dist/api/utils.d.ts.map +1 -0
  89. package/dist/auth/mergeCollections.d.ts +28 -0
  90. package/dist/auth/mergeCollections.d.ts.map +1 -0
  91. package/dist/auth/types.d.ts +84 -0
  92. package/dist/auth/types.d.ts.map +1 -0
  93. package/dist/chunk-2DU7JDEX.js +1877 -0
  94. package/dist/chunk-2DU7JDEX.js.map +1 -0
  95. package/dist/chunk-2IB2DCN7.js +75 -0
  96. package/dist/chunk-2IB2DCN7.js.map +1 -0
  97. package/dist/collections/config.d.ts +28 -0
  98. package/dist/collections/config.d.ts.map +1 -0
  99. package/dist/collections/constants.d.ts +27 -0
  100. package/dist/collections/constants.d.ts.map +1 -0
  101. package/dist/collections/index.d.ts +7 -0
  102. package/dist/collections/index.d.ts.map +1 -0
  103. package/dist/collections/indexFields.d.ts +20 -0
  104. package/dist/collections/indexFields.d.ts.map +1 -0
  105. package/dist/collections/interfaceGen.d.ts +59 -0
  106. package/dist/collections/interfaceGen.d.ts.map +1 -0
  107. package/dist/collections/internal/index.d.ts +2 -0
  108. package/dist/collections/internal/index.d.ts.map +1 -0
  109. package/dist/collections/types.d.ts +282 -0
  110. package/dist/collections/types.d.ts.map +1 -0
  111. package/dist/collections/utils.d.ts +71 -0
  112. package/dist/collections/utils.d.ts.map +1 -0
  113. package/dist/collections/validator.d.ts +73 -0
  114. package/dist/collections/validator.d.ts.map +1 -0
  115. package/dist/config/config.d.ts +43 -0
  116. package/dist/config/config.d.ts.map +1 -0
  117. package/dist/config/index.d.ts +5 -0
  118. package/dist/config/index.d.ts.map +1 -0
  119. package/dist/config/sanitizeConfig.d.ts +82 -0
  120. package/dist/config/sanitizeConfig.d.ts.map +1 -0
  121. package/dist/config/types.d.ts +316 -0
  122. package/dist/config/types.d.ts.map +1 -0
  123. package/dist/fields/array/config.d.ts +57 -0
  124. package/dist/fields/array/config.d.ts.map +1 -0
  125. package/dist/fields/array/index.d.ts +5 -0
  126. package/dist/fields/array/index.d.ts.map +1 -0
  127. package/dist/fields/array/inputSchema.d.ts +32 -0
  128. package/dist/fields/array/inputSchema.d.ts.map +1 -0
  129. package/dist/fields/array/types.d.ts +127 -0
  130. package/dist/fields/array/types.d.ts.map +1 -0
  131. package/dist/fields/array/validator.d.ts +30 -0
  132. package/dist/fields/array/validator.d.ts.map +1 -0
  133. package/dist/fields/baseTypes.d.ts +251 -0
  134. package/dist/fields/baseTypes.d.ts.map +1 -0
  135. package/dist/fields/blocks/config.d.ts +63 -0
  136. package/dist/fields/blocks/config.d.ts.map +1 -0
  137. package/dist/fields/blocks/index.d.ts +5 -0
  138. package/dist/fields/blocks/index.d.ts.map +1 -0
  139. package/dist/fields/blocks/inputSchema.d.ts +22 -0
  140. package/dist/fields/blocks/inputSchema.d.ts.map +1 -0
  141. package/dist/fields/blocks/types.d.ts +253 -0
  142. package/dist/fields/blocks/types.d.ts.map +1 -0
  143. package/dist/fields/blocks/validator.d.ts +32 -0
  144. package/dist/fields/blocks/validator.d.ts.map +1 -0
  145. package/dist/fields/checkbox/config.d.ts +46 -0
  146. package/dist/fields/checkbox/config.d.ts.map +1 -0
  147. package/dist/fields/checkbox/index.d.ts +5 -0
  148. package/dist/fields/checkbox/index.d.ts.map +1 -0
  149. package/dist/fields/checkbox/inputSchema.d.ts +27 -0
  150. package/dist/fields/checkbox/inputSchema.d.ts.map +1 -0
  151. package/dist/fields/checkbox/types.d.ts +67 -0
  152. package/dist/fields/checkbox/types.d.ts.map +1 -0
  153. package/dist/fields/checkbox/validator.d.ts +34 -0
  154. package/dist/fields/checkbox/validator.d.ts.map +1 -0
  155. package/dist/fields/color/config.d.ts +49 -0
  156. package/dist/fields/color/config.d.ts.map +1 -0
  157. package/dist/fields/color/convert.d.ts +72 -0
  158. package/dist/fields/color/convert.d.ts.map +1 -0
  159. package/dist/fields/color/formats.d.ts +38 -0
  160. package/dist/fields/color/formats.d.ts.map +1 -0
  161. package/dist/fields/color/index.d.ts +8 -0
  162. package/dist/fields/color/index.d.ts.map +1 -0
  163. package/dist/fields/color/inputSchema.d.ts +29 -0
  164. package/dist/fields/color/inputSchema.d.ts.map +1 -0
  165. package/dist/fields/color/types.d.ts +100 -0
  166. package/dist/fields/color/types.d.ts.map +1 -0
  167. package/dist/fields/color/utils.d.ts +100 -0
  168. package/dist/fields/color/utils.d.ts.map +1 -0
  169. package/dist/fields/color/validator.d.ts +27 -0
  170. package/dist/fields/color/validator.d.ts.map +1 -0
  171. package/dist/fields/constants.d.ts +108 -0
  172. package/dist/fields/constants.d.ts.map +1 -0
  173. package/dist/fields/date/config.d.ts +57 -0
  174. package/dist/fields/date/config.d.ts.map +1 -0
  175. package/dist/fields/date/index.d.ts +5 -0
  176. package/dist/fields/date/index.d.ts.map +1 -0
  177. package/dist/fields/date/inputSchema.d.ts +29 -0
  178. package/dist/fields/date/inputSchema.d.ts.map +1 -0
  179. package/dist/fields/date/types.d.ts +147 -0
  180. package/dist/fields/date/types.d.ts.map +1 -0
  181. package/dist/fields/date/validator.d.ts +34 -0
  182. package/dist/fields/date/validator.d.ts.map +1 -0
  183. package/dist/fields/group/config.d.ts +47 -0
  184. package/dist/fields/group/config.d.ts.map +1 -0
  185. package/dist/fields/group/index.d.ts +5 -0
  186. package/dist/fields/group/index.d.ts.map +1 -0
  187. package/dist/fields/group/inputSchema.d.ts +27 -0
  188. package/dist/fields/group/inputSchema.d.ts.map +1 -0
  189. package/dist/fields/group/types.d.ts +105 -0
  190. package/dist/fields/group/types.d.ts.map +1 -0
  191. package/dist/fields/group/validator.d.ts +41 -0
  192. package/dist/fields/group/validator.d.ts.map +1 -0
  193. package/dist/fields/index.d.ts +20 -0
  194. package/dist/fields/index.d.ts.map +1 -0
  195. package/dist/fields/inputSchemas/index.d.ts +23 -0
  196. package/dist/fields/inputSchemas/index.d.ts.map +1 -0
  197. package/dist/fields/inputSchemas/utils.d.ts +25 -0
  198. package/dist/fields/inputSchemas/utils.d.ts.map +1 -0
  199. package/dist/fields/interfaceGen.d.ts +15 -0
  200. package/dist/fields/interfaceGen.d.ts.map +1 -0
  201. package/dist/fields/number/config.d.ts +48 -0
  202. package/dist/fields/number/config.d.ts.map +1 -0
  203. package/dist/fields/number/index.d.ts +5 -0
  204. package/dist/fields/number/index.d.ts.map +1 -0
  205. package/dist/fields/number/inputSchema.d.ts +23 -0
  206. package/dist/fields/number/inputSchema.d.ts.map +1 -0
  207. package/dist/fields/number/types.d.ts +100 -0
  208. package/dist/fields/number/types.d.ts.map +1 -0
  209. package/dist/fields/number/validator.d.ts +39 -0
  210. package/dist/fields/number/validator.d.ts.map +1 -0
  211. package/dist/fields/relationship/config.d.ts +45 -0
  212. package/dist/fields/relationship/config.d.ts.map +1 -0
  213. package/dist/fields/relationship/index.d.ts +5 -0
  214. package/dist/fields/relationship/index.d.ts.map +1 -0
  215. package/dist/fields/relationship/inputSchema.d.ts +31 -0
  216. package/dist/fields/relationship/inputSchema.d.ts.map +1 -0
  217. package/dist/fields/relationship/types.d.ts +126 -0
  218. package/dist/fields/relationship/types.d.ts.map +1 -0
  219. package/dist/fields/relationship/validator.d.ts +27 -0
  220. package/dist/fields/relationship/validator.d.ts.map +1 -0
  221. package/dist/fields/select/config.d.ts +59 -0
  222. package/dist/fields/select/config.d.ts.map +1 -0
  223. package/dist/fields/select/index.d.ts +5 -0
  224. package/dist/fields/select/index.d.ts.map +1 -0
  225. package/dist/fields/select/inputSchema.d.ts +28 -0
  226. package/dist/fields/select/inputSchema.d.ts.map +1 -0
  227. package/dist/fields/select/types.d.ts +89 -0
  228. package/dist/fields/select/types.d.ts.map +1 -0
  229. package/dist/fields/select/validator.d.ts +31 -0
  230. package/dist/fields/select/validator.d.ts.map +1 -0
  231. package/dist/fields/text/config.d.ts +48 -0
  232. package/dist/fields/text/config.d.ts.map +1 -0
  233. package/dist/fields/text/index.d.ts +5 -0
  234. package/dist/fields/text/index.d.ts.map +1 -0
  235. package/dist/fields/text/inputSchema.d.ts +24 -0
  236. package/dist/fields/text/inputSchema.d.ts.map +1 -0
  237. package/dist/fields/text/types.d.ts +132 -0
  238. package/dist/fields/text/types.d.ts.map +1 -0
  239. package/dist/fields/text/validator.d.ts +39 -0
  240. package/dist/fields/text/validator.d.ts.map +1 -0
  241. package/dist/fields/types.d.ts +135 -0
  242. package/dist/fields/types.d.ts.map +1 -0
  243. package/dist/fields/upload/config.d.ts +24 -0
  244. package/dist/fields/upload/config.d.ts.map +1 -0
  245. package/dist/fields/upload/index.d.ts +5 -0
  246. package/dist/fields/upload/index.d.ts.map +1 -0
  247. package/dist/fields/upload/inputSchema.d.ts +17 -0
  248. package/dist/fields/upload/inputSchema.d.ts.map +1 -0
  249. package/dist/fields/upload/types.d.ts +78 -0
  250. package/dist/fields/upload/types.d.ts.map +1 -0
  251. package/dist/fields/upload/validator.d.ts +16 -0
  252. package/dist/fields/upload/validator.d.ts.map +1 -0
  253. package/dist/fields/url/config.d.ts +49 -0
  254. package/dist/fields/url/config.d.ts.map +1 -0
  255. package/dist/fields/url/index.d.ts +5 -0
  256. package/dist/fields/url/index.d.ts.map +1 -0
  257. package/dist/fields/url/inputSchema.d.ts +31 -0
  258. package/dist/fields/url/inputSchema.d.ts.map +1 -0
  259. package/dist/fields/url/types.d.ts +70 -0
  260. package/dist/fields/url/types.d.ts.map +1 -0
  261. package/dist/fields/url/validator.d.ts +37 -0
  262. package/dist/fields/url/validator.d.ts.map +1 -0
  263. package/dist/fields/utils.d.ts +47 -0
  264. package/dist/fields/utils.d.ts.map +1 -0
  265. package/dist/fields/validators/index.d.ts +23 -0
  266. package/dist/fields/validators/index.d.ts.map +1 -0
  267. package/dist/fields/validators/utils.d.ts +24 -0
  268. package/dist/fields/validators/utils.d.ts.map +1 -0
  269. package/dist/framework.d.ts +227 -0
  270. package/dist/framework.d.ts.map +1 -0
  271. package/dist/globals/config/config.d.ts +1 -0
  272. package/dist/globals/config/config.d.ts.map +1 -0
  273. package/dist/globals/config/types.d.ts +1 -0
  274. package/dist/globals/config/types.d.ts.map +1 -0
  275. package/dist/globals/config.d.ts +47 -0
  276. package/dist/globals/config.d.ts.map +1 -0
  277. package/dist/globals/index.d.ts +5 -0
  278. package/dist/globals/index.d.ts.map +1 -0
  279. package/dist/globals/interfaceGen.d.ts +33 -0
  280. package/dist/globals/interfaceGen.d.ts.map +1 -0
  281. package/dist/globals/types.d.ts +175 -0
  282. package/dist/globals/types.d.ts.map +1 -0
  283. package/dist/globals/utils.d.ts +37 -0
  284. package/dist/globals/utils.d.ts.map +1 -0
  285. package/dist/index.d.ts +15 -3165
  286. package/dist/index.d.ts.map +1 -0
  287. package/dist/index.js +2101 -3470
  288. package/dist/index.js.map +1 -1
  289. package/dist/media/api/index.d.ts +5 -0
  290. package/dist/media/api/index.d.ts.map +1 -0
  291. package/dist/media/api/mutations.d.ts +76 -0
  292. package/dist/media/api/mutations.d.ts.map +1 -0
  293. package/dist/media/api/queries.d.ts +28 -0
  294. package/dist/media/api/queries.d.ts.map +1 -0
  295. package/dist/media/api/server.d.ts +68 -0
  296. package/dist/media/api/server.d.ts.map +1 -0
  297. package/dist/media/api/types.d.ts +171 -0
  298. package/dist/media/api/types.d.ts.map +1 -0
  299. package/dist/media/config.d.ts +25 -0
  300. package/dist/media/config.d.ts.map +1 -0
  301. package/dist/media/index.d.ts +6 -0
  302. package/dist/media/index.d.ts.map +1 -0
  303. package/dist/media/types.d.ts +332 -0
  304. package/dist/media/types.d.ts.map +1 -0
  305. package/dist/media/utils.d.ts +35 -0
  306. package/dist/media/utils.d.ts.map +1 -0
  307. package/dist/media/validators.d.ts +61 -0
  308. package/dist/media/validators.d.ts.map +1 -0
  309. package/dist/schema/generateVexSchema.d.ts +36 -0
  310. package/dist/schema/generateVexSchema.d.ts.map +1 -0
  311. package/dist/schema/index.d.ts +3 -0
  312. package/dist/schema/index.d.ts.map +1 -0
  313. package/dist/schema/migrate.d.ts +73 -0
  314. package/dist/schema/migrate.d.ts.map +1 -0
  315. package/dist/types/generateVexTypes.d.ts +41 -0
  316. package/dist/types/generateVexTypes.d.ts.map +1 -0
  317. package/dist/types/generated.d.ts +382 -0
  318. package/dist/types/generated.d.ts.map +1 -0
  319. package/dist/types/index.d.ts +5 -0
  320. package/dist/types/index.d.ts.map +1 -0
  321. package/dist/utils.d.ts +57 -0
  322. package/dist/utils.d.ts.map +1 -0
  323. package/package.json +67 -24
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/dist/.build ADDED
@@ -0,0 +1 @@
1
+ 1788177820990
@@ -0,0 +1,58 @@
1
+ import type { AccessCheck, AccessDocFieldFor, AccessFieldValueFor, AccessIndexedFieldFor, AccessMutationCheck, AccessResourceRef } from "./types";
2
+ /**
3
+ * Builds a read check narrowed to `field === value`, pushed into that field's index.
4
+ *
5
+ * @typeParam S - Resource slug, inferred from `props.resource`.
6
+ * @typeParam F - Field name, constrained to `S`'s index-leading fields.
7
+ * @param props - Input props.
8
+ * @param props.resource - The resource this check governs.
9
+ * @param props.field - Field to compare, completed from `S`'s indexed fields.
10
+ * @param props.value - Value to match, typed from `S`'s document.
11
+ * @returns A check assignable to `permissions[role][S].read`.
12
+ */
13
+ export declare function indexedEqCheck<S extends string, F extends AccessIndexedFieldFor<S>>(props: {
14
+ field: F;
15
+ resource: AccessResourceRef<S>;
16
+ value: AccessFieldValueFor<S, F>;
17
+ }): AccessCheck<S>;
18
+ /**
19
+ * Builds a read check narrowed to rows the requesting user owns, pushed into the owner
20
+ * field's index.
21
+ *
22
+ * The comparison value is built per request from `user`, and its shape follows the
23
+ * field's declared type: a relationship column stores `Id[]`, so the value is
24
+ * `[user._id]`; anything else compares the id directly. That decision needs the
25
+ * resource config, which is why this is a distinct builder rather than a call to
26
+ * {@link indexedEqCheck}.
27
+ *
28
+ * @typeParam S - Resource slug, inferred from `props.resource`.
29
+ * @typeParam F - Owner field, constrained to `S`'s index-leading fields.
30
+ * @param props - Input props.
31
+ * @param props.resource - The resource this check governs.
32
+ * @param props.field - The owner field, e.g. `"authorId"`.
33
+ * @returns A check assignable to `permissions[role][S].read`.
34
+ */
35
+ export declare function indexedOwnerCheck<S extends string, F extends AccessIndexedFieldFor<S>>(props: {
36
+ field: F;
37
+ resource: AccessResourceRef<S>;
38
+ }): AccessCheck<S>;
39
+ /**
40
+ * Builds a single-document check that passes only when `field` names the requesting
41
+ * user.
42
+ *
43
+ * A per-document predicate rather than an index range: `create`/`update`/`delete`
44
+ * authorize one document, so there is nothing to narrow (DD 14). `field` is therefore
45
+ * any readable field, not only an indexed one.
46
+ *
47
+ * @typeParam S - Resource slug, inferred from `props.resource`.
48
+ * @typeParam F - Owner field on `S`.
49
+ * @param props - Input props.
50
+ * @param props.resource - The resource this check governs.
51
+ * @param props.field - The owner field, e.g. `"authorId"`.
52
+ * @returns A check assignable to a non-query action on `S`.
53
+ */
54
+ export declare function ownerPredicateCheck<S extends string, F extends AccessDocFieldFor<S>>(props: {
55
+ field: F;
56
+ resource: AccessResourceRef<S>;
57
+ }): AccessMutationCheck<S>;
58
+ //# sourceMappingURL=buildChecks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildChecks.d.ts","sourceRoot":"","sources":["../../src/access/buildChecks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EAEjB,mBAAmB,EACnB,qBAAqB,EAErB,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAuEjB;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,qBAAqB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE;IAC1F,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC/B,KAAK,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAClC,GAAG,WAAW,CAAC,CAAC,CAAC,CAMjB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,qBAAqB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE;IAC7F,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;CAChC,GAAG,WAAW,CAAC,CAAC,CAAC,CAiBjB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,iBAAiB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE;IAC3F,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;CAChC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAKzB"}
@@ -0,0 +1,53 @@
1
+ import type { VexAccessConfig } from "./types";
2
+ /**
3
+ * Props for {@link canAccessAdminPanel}.
4
+ */
5
+ export interface CanAccessAdminPanelProps {
6
+ /**
7
+ * The resolved config from `defineAccess()`. `undefined` means RBAC is not
8
+ * configured, which grants access — the same escape hatch `hasPermission`
9
+ * uses, so a project without an access matrix keeps working.
10
+ */
11
+ access?: VexAccessConfig;
12
+ /**
13
+ * The authenticated caller. `null`/`{}` (unauthenticated) resolves to an empty
14
+ * role list and therefore denies.
15
+ */
16
+ user: Record<string, unknown> | null;
17
+ /** The caller's active organization, forwarded to permission callbacks. */
18
+ organization?: Record<string, unknown>;
19
+ }
20
+ /**
21
+ * Answers whether a caller may open the admin panel at all — the
22
+ * `adminPanel.access` gate.
23
+ *
24
+ * This is the coarse entry check. It is deliberately separate from the
25
+ * per-collection checks: a caller who fails this should never reach the panel,
26
+ * whereas a caller who passes it may still be denied individual collections.
27
+ *
28
+ * Call it in the host app's admin route (a server component, layout, or
29
+ * middleware) and redirect on `false`. It never throws: the `adminPanel.access`
30
+ * subject carries no document, so it is evaluated with
31
+ * `scope: "any"` — a permission callback that only reads `user`/`organization`
32
+ * resolves normally, and one that reaches for a document resolves to `true`
33
+ * rather than throwing, since "can this caller use the panel" is inherently a
34
+ * subject-level question.
35
+ *
36
+ * Prefer this over hand-writing `hasPermission({ resource: "adminPanel", … })`
37
+ * so the subject key and action are never spelled by hand.
38
+ *
39
+ * @param props - The access config plus the resolved caller.
40
+ * @returns `true` when the caller may open the admin panel; `false` to deny.
41
+ * Also `true` when `access` is `undefined` (RBAC not configured).
42
+ * @example
43
+ * ```tsx
44
+ * // app/admin/[[...path]]/page.tsx
45
+ * const auth = await fetchAuthQuery(api.auth.api.getUserOrg, {});
46
+ * if (!canAccessAdminPanel({ access, user: auth.user, organization: auth.organization })) {
47
+ * redirect("/unauthorized");
48
+ * }
49
+ * ```
50
+ * @see {@link hasPermission} for the general check this delegates to
51
+ */
52
+ export declare function canAccessAdminPanel(props: CanAccessAdminPanelProps): boolean;
53
+ //# sourceMappingURL=canAccessAdminPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canAccessAdminPanel.d.ts","sourceRoot":"","sources":["../../src/access/canAccessAdminPanel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACrC,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAS5E"}
@@ -0,0 +1,155 @@
1
+ import type { DocumentByInfo, Expression, FilterBuilder, GenericDocument, GenericTableInfo } from "convex/server";
2
+ import type { AccessFilterConstraint, AccessIndexConstraint } from "./constraintTypes";
3
+ import type { IndexRangeFn } from "./types";
4
+ /**
5
+ * Structural equality over Convex values.
6
+ *
7
+ * Convex compares values by CONTENT, both in an index range and in a `.filter()`
8
+ * expression. JS `===` compares arrays and objects by REFERENCE, so using it for the
9
+ * predicate made the two compile targets disagree for every array-valued field —
10
+ * which is every `relationship` and `select` field, since both store `v.array(...)`.
11
+ *
12
+ * The divergence was not symmetric, and one direction was unsafe: `eq` produced a
13
+ * false NEGATIVE (the query returned a row the predicate then rejected, so a client
14
+ * denied access the server had granted), while `neq` produced a false POSITIVE (the
15
+ * predicate admitted a row the query had excluded). The second is the dangerous one,
16
+ * and it is why this is content equality rather than a special case for `eq`.
17
+ *
18
+ * `undefined` equals `undefined`, which keeps "field missing" and "field explicitly
19
+ * undefined" indistinguishable — matching how a document read through bracket access
20
+ * behaves, and matching Convex, which stores neither.
21
+ *
22
+ * @param a - Left value.
23
+ * @param b - Right value.
24
+ * @returns `true` when the two values are structurally equal.
25
+ */
26
+ declare function convexValuesEqual(a: unknown, b: unknown): boolean;
27
+ /**
28
+ * JS-side comparator per {@link IndexOp}, used by `constraintsToPredicate`.
29
+ * `as never` narrows past `unknown` for the ordering operators only —
30
+ * `eq` never needs it. Exported so a caller building its own predicate logic
31
+ * (or a future compile target) reuses the same five comparisons rather than
32
+ * re-deriving them.
33
+ *
34
+ * The ordering operators are left as JS relational comparisons: they are only ever
35
+ * recorded against a single field of one type, where JS and Convex agree. Convex's
36
+ * cross-type total order is deliberately not reimplemented here.
37
+ */
38
+ export declare const CONSTRAINT_COMPARATORS: {
39
+ readonly eq: typeof convexValuesEqual;
40
+ readonly gt: (a: unknown, b: unknown) => boolean;
41
+ readonly gte: (a: unknown, b: unknown) => boolean;
42
+ readonly lt: (a: unknown, b: unknown) => boolean;
43
+ readonly lte: (a: unknown, b: unknown) => boolean;
44
+ };
45
+ /**
46
+ * Compiles a recorded constraint list to a `withIndex` range function.
47
+ *
48
+ * @param props - Input props.
49
+ * @param props.constraints - The rule's recorded constraints, in the order
50
+ * they were built. May be empty — an unrestricted range.
51
+ * @returns A function usable directly as `find`'s `withIndex` range: applies
52
+ * each constraint's operator to the builder in order and returns the
53
+ * result as an `IndexRange`.
54
+ */
55
+ export declare function accessConstraintsToIndexRange<TDocument extends GenericDocument = GenericDocument>(props: {
56
+ constraints: readonly AccessIndexConstraint<string, TDocument>[];
57
+ }): IndexRangeFn;
58
+ /**
59
+ * Compiles a recorded constraint list to a single `FilterBuilder` expression,
60
+ * `and`-ing multiple constraints together.
61
+ *
62
+ * @param props - Input props.
63
+ * @param props.constraints - The rule's recorded constraints, in the order
64
+ * they were built. Must be non-empty.
65
+ * @param props.q - The query's own `FilterBuilder`, from `.filter((q) => …)`.
66
+ * @returns A boolean expression usable directly as (or `and`-ed into) a
67
+ * `.filter()` predicate. A single constraint returns its own expression
68
+ * unwrapped; two or more are combined with `and`.
69
+ * @throws {Error} When `props.constraints` is empty — a caller contract
70
+ * violation, not a config-authoring mistake. An unrestricted rule resolves to
71
+ * its boolean shorthand upstream and never reaches a compile target.
72
+ */
73
+ export declare function accessConstraintsToFilter<TTableInfo extends GenericTableInfo, TDocument extends DocumentByInfo<TTableInfo> = DocumentByInfo<TTableInfo>>(props: {
74
+ constraints: readonly AccessIndexConstraint<string, TDocument>[];
75
+ q: FilterBuilder<TTableInfo>;
76
+ }): Expression<boolean>;
77
+ /**
78
+ * Compiles a recorded constraint list to a JS predicate, for interpreting
79
+ * constraints against an already-fetched document (`hasPermission`,
80
+ * client-side `usePermission`).
81
+ *
82
+ * The third compile target for the SAME recorded list, and it agrees with
83
+ * `accessConstraintsToFilter` by construction: both walk the constraints in order
84
+ * and both dispatch on the operator set {@link CONSTRAINT_COMPARATORS} defines, one
85
+ * in JS and one as a Convex expression. `compileConstraints.test.ts` asserts that
86
+ * agreement on a matching and a non-matching document.
87
+ *
88
+ * @param props - Input props.
89
+ * @param props.constraints - The rule's recorded constraints, in the order
90
+ * they were built. May be empty — an unrestricted predicate.
91
+ * @returns A function returning `true` when `doc` satisfies every constraint.
92
+ */
93
+ export declare function accessConstraintsToPredicate<TDoc extends GenericDocument>(props: {
94
+ constraints: readonly AccessIndexConstraint<string, TDoc>[];
95
+ }): (doc: TDoc) => boolean;
96
+ /**
97
+ * JS-side comparator per {@link FilterOp} — {@link CONSTRAINT_COMPARATORS} plus
98
+ * `neq`, which `FilterBuilder` has and `IndexRangeBuilder` does not.
99
+ *
100
+ * Used by {@link accessFilterTreeToPredicate}. Kept as an extension of the index
101
+ * map rather than a parallel one so the two algebras cannot drift on a shared
102
+ * operator: change `gte` once and both compile targets follow.
103
+ */
104
+ export declare const FILTER_COMPARATORS: {
105
+ readonly neq: (a: unknown, b: unknown) => boolean;
106
+ readonly eq: typeof convexValuesEqual;
107
+ readonly gt: (a: unknown, b: unknown) => boolean;
108
+ readonly gte: (a: unknown, b: unknown) => boolean;
109
+ readonly lt: (a: unknown, b: unknown) => boolean;
110
+ readonly lte: (a: unknown, b: unknown) => boolean;
111
+ };
112
+ /**
113
+ * Compiles a recorded constraint TREE to a single `FilterBuilder` expression.
114
+ *
115
+ * The tree counterpart of {@link accessConstraintsToFilter}: that one walks the
116
+ * flat positional list an indexed rule records, this one walks the recursive
117
+ * `compare`/`and`/`or`/`not` shape an unindexed rule records. Both target the
118
+ * same `.filter()` slot.
119
+ *
120
+ * There is no empty-tree case to guard. A rule that recorded nothing leaves
121
+ * `AccessCondition.filter` as `undefined`, so absence is represented by
122
+ * the field being missing rather than by an empty node — unlike the flat list,
123
+ * where `[]` is representable and has to be rejected.
124
+ *
125
+ * @typeParam TTableInfo - Convex table info for the query being filtered.
126
+ * @typeParam TDoc - Document shape the recorded values are typed against.
127
+ * @param props - Input props.
128
+ * @param props.node - Root of the recorded tree.
129
+ * @param props.q - The query's own `FilterBuilder`, from `.filter((q) => …)`.
130
+ * @returns A boolean expression usable directly as (or `and`-ed into) a
131
+ * `.filter()` predicate.
132
+ */
133
+ export declare function accessFilterTreeToFilter<TTableInfo extends GenericTableInfo, TDoc extends DocumentByInfo<TTableInfo> = DocumentByInfo<TTableInfo>>(props: {
134
+ node: AccessFilterConstraint<TDoc>;
135
+ q: FilterBuilder<TTableInfo>;
136
+ }): Expression<boolean>;
137
+ /**
138
+ * Compiles a recorded constraint TREE to a JS predicate, for interpreting an
139
+ * unindexed rule against an already-fetched document.
140
+ *
141
+ * The tree counterpart of {@link accessConstraintsToPredicate}, and it agrees with
142
+ * {@link accessFilterTreeToFilter} by construction: both walk the same nodes in the
143
+ * same order and both dispatch comparisons through {@link FILTER_COMPARATORS}, one
144
+ * in JS and one as a Convex expression.
145
+ *
146
+ * @typeParam TDoc - Document shape the recorded values are typed against.
147
+ * @param props - Input props.
148
+ * @param props.node - Root of the recorded tree.
149
+ * @returns A function returning `true` when `doc` satisfies the tree.
150
+ */
151
+ export declare function accessFilterTreeToPredicate<TDoc extends GenericDocument>(props: {
152
+ node: AccessFilterConstraint<TDoc>;
153
+ }): (doc: TDoc) => boolean;
154
+ export {};
155
+ //# sourceMappingURL=compileConstraints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compileConstraints.d.ts","sourceRoot":"","sources":["../../src/access/compileConstraints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAEjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EAGtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CA2B1D;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB;;qBAEzB,OAAO,KAAK,OAAO;sBAClB,OAAO,KAAK,OAAO;qBACpB,OAAO,KAAK,OAAO;sBAClB,OAAO,KAAK,OAAO;CAC2C,CAAC;AAE1E;;;;;;;;;GASG;AACH,wBAAgB,6BAA6B,CAC3C,SAAS,SAAS,eAAe,GAAG,eAAe,EACnD,KAAK,EAAE;IAAE,WAAW,EAAE,SAAS,qBAAqB,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAA;CAAE,GAAG,YAAY,CAkB3F;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,SAAS,gBAAgB,EACnC,SAAS,SAAS,cAAc,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,EACzE,KAAK,EAAE;IACP,WAAW,EAAE,SAAS,qBAAqB,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC;IACjE,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CAC9B,GAAG,UAAU,CAAC,OAAO,CAAC,CA+BtB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,SAAS,eAAe,EAAE,KAAK,EAAE;IAChF,WAAW,EAAE,SAAS,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;CAC7D,GAAG,CAAC,GAAG,EAAE,IAAI,KAAK,OAAO,CAMzB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;sBAEpB,OAAO,KAAK,OAAO;;qBAhIpB,OAAO,KAAK,OAAO;sBAClB,OAAO,KAAK,OAAO;qBACpB,OAAO,KAAK,OAAO;sBAClB,OAAO,KAAK,OAAO;CA8H4C,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,SAAS,gBAAgB,EACnC,IAAI,SAAS,cAAc,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,EACpE,KAAK,EAAE;IAAE,IAAI,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAAC,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;CAAE,GAAG,UAAU,CAAC,OAAO,CAAC,CAkClG;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,SAAS,eAAe,EAAE,KAAK,EAAE;IAC/E,IAAI,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAC;CACpC,GAAG,CAAC,GAAG,EAAE,IAAI,KAAK,OAAO,CA2BzB"}
@@ -0,0 +1,62 @@
1
+ import { CollectionSlug } from "../types/generated";
2
+ import { CustomActionsInput, type AccessResource, type CustomResourceInput, type SubjectMap, type VexAccessConfig, type VexAccessConfigInput } from "./types";
3
+ /**
4
+ * Defines the RBAC configuration for a VexCMS project.
5
+ *
6
+ * Builder in the `defineCollection`/`defineGlobal` family: infers the
7
+ * per-subject action/data/field registry (`SubjectMap`) from `resources` and
8
+ * `customResources` so `hasPermission()` calls against the returned config are
9
+ * fully typed; validates the matrix in dev; returns a frozen `VexAccessConfig`
10
+ * for `defineConfig({ access })`.
11
+ *
12
+ * @typeParam TRoles - Tuple of role name literals.
13
+ * @typeParam TResources - Tuple of collection/global configs contributing subjects.
14
+ * @typeParam TCustomResources - Custom subject declarations (`{ actions, data? }`).
15
+ * @typeParam TUserSlug - Slug literal of the user collection; drives the callback
16
+ * `user` type via the generated registry.
17
+ * @typeParam TOrgSlug - Slug literal of the organization collection, when
18
+ * multi-tenant. Presence gates the `organization` callback key; `undefined`
19
+ * when single-tenant.
20
+ * @param props - The access configuration.
21
+ * @param props.roles - All role names the matrix may reference.
22
+ * @param props.resources - Collections/globals to expose as subjects, keyed by slug.
23
+ * @param props.customResources - Non-resource subjects, keyed by name.
24
+ * @param props.userCollectionSlug - Slug of the collection whose documents are
25
+ * `user` in callbacks. A plain string — the merged user collection
26
+ * (auth-adapter fields included) does not exist yet at authoring time; the
27
+ * document type resolves from the generated registry by slug.
28
+ * @param props.userRolesField - Field on the user document holding role(s)
29
+ * (`string` or `string[]` value); `hasPermission` reads roles from it.
30
+ * @param props.orgCollectionSlug - Optional org collection slug enabling
31
+ * org-scoped callbacks.
32
+ * @param props.permissions - Role → subject → check matrix (see `RolePermissions`).
33
+ * @returns Frozen `VexAccessConfig` carrying the `SubjectMap` phantom for inference.
34
+ * @throws {VexAccessConfigError} When `userCollectionSlug` or `userRolesField` is
35
+ * empty, when a `customResources` key collides with a resource slug, or when a
36
+ * `customResources` entry declares an empty `actions` array. Also when a rule's
37
+ * recorded constraints are not an in-order prefix of a declared index or violate
38
+ * Convex's operator rule (see `validateAccessConstraints`), and when a
39
+ * `constraints` callback throws while being recorded — every rule's callback runs
40
+ * once here, at module load, so a rule that reached past its types surfaces as a
41
+ * config error naming the role, resource and action rather than as a bare
42
+ * `TypeError` from whichever method was missing.
43
+ * @example
44
+ * ```ts
45
+ * export const access = defineAccess({
46
+ * roles: ["admin", "editor"],
47
+ * resources: [pages, users],
48
+ * customResources: { apiKeys: { actions: ["create", "revoke"] } },
49
+ * userCollectionSlug: "users",
50
+ * userRolesField: "roles",
51
+ * permissions: {
52
+ * admin: { [WILDCARD_KEY]: true },
53
+ * editor: { pages: { read: true, update: true }, apiKeys: false },
54
+ * },
55
+ * });
56
+ * ```
57
+ *
58
+ * @see {@link VexAccessConfigInput} for the input type
59
+ * @see {@link VexAccessConfig} for the resolved return type
60
+ */
61
+ export declare function defineAccess<const TRoles extends readonly string[], const TResources extends readonly AccessResource[], const TCustomResources extends Record<string, CustomResourceInput> = {}, const TUserSlug extends CollectionSlug = CollectionSlug, const TOrgSlug extends CollectionSlug | undefined = undefined, const TCustomActions extends Partial<Record<TResources[number]["slug"] | TUserSlug | Extract<TOrgSlug, string>, CustomActionsInput>> = {}>(props: VexAccessConfigInput<TRoles, TResources, TCustomResources, TUserSlug, TOrgSlug, TCustomActions>): VexAccessConfig<SubjectMap<TResources, TCustomResources, TUserSlug, TOrgSlug, TCustomActions>, TResources, TUserSlug, TOrgSlug, TCustomActions>;
62
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/access/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EACL,kBAAkB,EAElB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,wBAAgB,YAAY,CAC1B,KAAK,CAAC,MAAM,SAAS,SAAS,MAAM,EAAE,EACtC,KAAK,CAAC,UAAU,SAAS,SAAS,cAAc,EAAE,EAClD,KAAK,CAAC,gBAAgB,SAAS,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,EAAE,EACvE,KAAK,CAAC,SAAS,SAAS,cAAc,GAAG,cAAc,EACvD,KAAK,CAAC,QAAQ,SAAS,cAAc,GAAG,SAAS,GAAG,SAAS,EAC7D,KAAK,CAAC,cAAc,SAAS,OAAO,CAClC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,kBAAkB,CAAC,CAC/F,GAAG,EAAE,EAEN,KAAK,EAAE,oBAAoB,CACzB,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,cAAc,CACf,GACA,eAAe,CAChB,UAAU,CAAC,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,CAAC,EAC7E,UAAU,EACV,SAAS,EACT,QAAQ,EACR,cAAc,CACf,CA4EA"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * CRUD actions available on every resource subject (collections and globals).
3
+ *
4
+ * Draft actions ({@link DRAFT_ACTIONS}) are added conditionally when a resource
5
+ * declares `versions.drafts: true`.
6
+ */
7
+ export declare const CRUD_ACTIONS: {
8
+ readonly create: "create";
9
+ readonly read: "read";
10
+ readonly update: "update";
11
+ readonly delete: "delete";
12
+ };
13
+ /** CRUD action union, derived from {@link CRUD_ACTIONS}. */
14
+ export type CrudAction = (typeof CRUD_ACTIONS)[keyof typeof CRUD_ACTIONS];
15
+ /**
16
+ * Draft workflow actions — present on a resource subject only when its config
17
+ * declares `versions.drafts: true` (globals today; collections with Spec 36).
18
+ */
19
+ export declare const DRAFT_ACTIONS: {
20
+ readonly readDrafts: "readDrafts";
21
+ readonly saveDraft: "saveDraft";
22
+ readonly publish: "publish";
23
+ readonly unpublish: "unpublish";
24
+ };
25
+ /** Draft action union, derived from {@link DRAFT_ACTIONS}. */
26
+ export type DraftAction = (typeof DRAFT_ACTIONS)[keyof typeof DRAFT_ACTIONS];
27
+ /**
28
+ * Actions whose read shape is a query rather than a single-document check —
29
+ * the only actions an indexed `{ filter, withIndex }` permission check may
30
+ * target (design doc §3: `withIndex` on `create`/`update`/`delete` would
31
+ * narrow nothing, since those authorize one document, not a range).
32
+ */
33
+ export declare const QUERY_ACTIONS: {
34
+ readonly read: "read";
35
+ readonly readDrafts: "readDrafts";
36
+ };
37
+ /** Query-shaped action union, derived from {@link QUERY_ACTIONS}. */
38
+ export type QueryAction = (typeof QUERY_ACTIONS)[keyof typeof QUERY_ACTIONS];
39
+ /**
40
+ * Field-mode object modes: `allow` = only the listed fields, `deny` = all but
41
+ * the listed fields.
42
+ */
43
+ export declare const PERMISSION_MODES: {
44
+ readonly allow: "allow";
45
+ readonly deny: "deny";
46
+ };
47
+ /** Field-mode object mode, derived from {@link PERMISSION_MODES}. */
48
+ export type PermissionMode = (typeof PERMISSION_MODES)[keyof typeof PERMISSION_MODES];
49
+ /**
50
+ * How `hasPermission` answers a *quantified* question: when no `data` is
51
+ * supplied and a role's check is a callback that needs the document, the scope
52
+ * decides what "yes" would even mean.
53
+ *
54
+ * - `doc` — "may they do this to THIS document?" `data` is required; a callback
55
+ * that needs it and does not get it throws {@link VexAccessError}. Opt into
56
+ * this in edit views and row actions, where a silent `false` would surface as
57
+ * a permanently disabled control and read like a misconfigured matrix.
58
+ * - `any` — "may they do this to AT LEAST ONE document?" Resolves such a callback
59
+ * to `true` without invoking it. Use for nav/sidebar/list gating; per-document
60
+ * filtering still happens downstream in `find`/`get`.
61
+ * - `all` (default) — "may they do this to EVERY document?" Resolves such a
62
+ * callback to `false`: a per-document condition cannot hold for all of them.
63
+ * Fail-closed, so omitting `scope` never throws and never over-permits.
64
+ *
65
+ * Static boolean checks are unaffected by scope, and any scope evaluates the
66
+ * callback normally once `data` is supplied.
67
+ */
68
+ export declare const PERMISSION_SCOPES: {
69
+ readonly doc: "doc";
70
+ readonly any: "any";
71
+ readonly all: "all";
72
+ };
73
+ /** Permission evaluation scope, derived from {@link PERMISSION_SCOPES}. */
74
+ export type PermissionScope = (typeof PERMISSION_SCOPES)[keyof typeof PERMISSION_SCOPES];
75
+ /**
76
+ * Wildcard key usable at two matrix levels: role level (`admin: { [WILDCARD_KEY]:
77
+ * true }`, boolean only) and action level inside a per-action map (any
78
+ * `PermissionCheck`). Precedence: explicit action > subject wildcard > role
79
+ * wildcard > `defaults`.
80
+ */
81
+ export declare const WILDCARD_KEY: "*";
82
+ /**
83
+ * Built-in non-resource subjects contributed by core. Every entry becomes a
84
+ * subject in the {@link SubjectMap} exactly like a user-declared custom
85
+ * resource (no data, no fields).
86
+ */
87
+ export declare const ADMIN_CUSTOM_SUBJECTS: {
88
+ readonly adminPanel: {
89
+ readonly key: "adminPanel";
90
+ readonly actions: readonly ["access", "impersonate"];
91
+ };
92
+ };
93
+ /** Union of built-in subject slugs (currently `"adminPanel"`). */
94
+ export type AdminCustomSubjectSlug = keyof typeof ADMIN_CUSTOM_SUBJECTS;
95
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/access/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AACX,4DAA4D;AAC5D,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE1E;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AACX,8DAA8D;AAC9D,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;CAGhB,CAAC;AACX,qEAAqE;AACrE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;CAGnB,CAAC;AACX,qEAAqE;AACrE,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAEtF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC;AACX,2EAA2E;AAC3E,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAEzF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAG,GAAY,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;;;;CAKxB,CAAC;AAEX,kEAAkE;AAClE,MAAM,MAAM,sBAAsB,GAAG,MAAM,OAAO,qBAAqB,CAAC"}