convex-cms 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (379) hide show
  1. package/dist/cli/commands/admin.d.ts +16 -0
  2. package/dist/cli/commands/admin.d.ts.map +1 -0
  3. package/dist/cli/commands/admin.js +88 -0
  4. package/dist/cli/commands/admin.js.map +1 -0
  5. package/dist/cli/index.d.ts +3 -0
  6. package/dist/cli/index.d.ts.map +1 -0
  7. package/dist/cli/index.js +18 -0
  8. package/dist/cli/index.js.map +1 -0
  9. package/dist/cli/utils/detectConvexUrl.d.ts +13 -0
  10. package/dist/cli/utils/detectConvexUrl.d.ts.map +1 -0
  11. package/dist/cli/utils/detectConvexUrl.js +48 -0
  12. package/dist/cli/utils/detectConvexUrl.js.map +1 -0
  13. package/dist/cli/utils/openBrowser.d.ts +7 -0
  14. package/dist/cli/utils/openBrowser.d.ts.map +1 -0
  15. package/dist/cli/utils/openBrowser.js +17 -0
  16. package/dist/cli/utils/openBrowser.js.map +1 -0
  17. package/dist/client/admin-config.d.ts +126 -0
  18. package/dist/client/admin-config.d.ts.map +1 -0
  19. package/dist/client/admin-config.js +117 -0
  20. package/dist/client/admin-config.js.map +1 -0
  21. package/dist/client/adminApi.d.ts +2273 -0
  22. package/dist/client/adminApi.d.ts.map +1 -0
  23. package/dist/client/adminApi.js +716 -0
  24. package/dist/client/adminApi.js.map +1 -0
  25. package/dist/client/agentTools.d.ts +933 -0
  26. package/dist/client/agentTools.d.ts.map +1 -0
  27. package/dist/client/agentTools.js +1004 -0
  28. package/dist/client/agentTools.js.map +1 -0
  29. package/dist/client/argTypes.d.ts +212 -0
  30. package/dist/client/argTypes.d.ts.map +1 -0
  31. package/dist/client/argTypes.js +5 -0
  32. package/dist/client/argTypes.js.map +1 -0
  33. package/dist/client/field-types.d.ts +55 -0
  34. package/dist/client/field-types.d.ts.map +1 -0
  35. package/dist/client/field-types.js +152 -0
  36. package/dist/client/field-types.js.map +1 -0
  37. package/dist/client/index.d.ts +189 -0
  38. package/dist/client/index.d.ts.map +1 -0
  39. package/dist/client/index.js +668 -0
  40. package/dist/client/index.js.map +1 -0
  41. package/dist/client/queryBuilder.d.ts +765 -0
  42. package/dist/client/queryBuilder.d.ts.map +1 -0
  43. package/dist/client/queryBuilder.js +970 -0
  44. package/dist/client/queryBuilder.js.map +1 -0
  45. package/dist/client/schema/codegen.d.ts +128 -0
  46. package/dist/client/schema/codegen.d.ts.map +1 -0
  47. package/dist/client/schema/codegen.js +318 -0
  48. package/dist/client/schema/codegen.js.map +1 -0
  49. package/dist/client/schema/defineContentType.d.ts +221 -0
  50. package/dist/client/schema/defineContentType.d.ts.map +1 -0
  51. package/dist/client/schema/defineContentType.js +380 -0
  52. package/dist/client/schema/defineContentType.js.map +1 -0
  53. package/dist/client/schema/index.d.ts +85 -0
  54. package/dist/client/schema/index.d.ts.map +1 -0
  55. package/dist/client/schema/index.js +92 -0
  56. package/dist/client/schema/index.js.map +1 -0
  57. package/dist/client/schema/schemaDrift.d.ts +199 -0
  58. package/dist/client/schema/schemaDrift.d.ts.map +1 -0
  59. package/dist/client/schema/schemaDrift.js +340 -0
  60. package/dist/client/schema/schemaDrift.js.map +1 -0
  61. package/dist/client/schema/typedClient.d.ts +401 -0
  62. package/dist/client/schema/typedClient.d.ts.map +1 -0
  63. package/dist/client/schema/typedClient.js +269 -0
  64. package/dist/client/schema/typedClient.js.map +1 -0
  65. package/dist/client/schema/types.d.ts +477 -0
  66. package/dist/client/schema/types.d.ts.map +1 -0
  67. package/dist/client/schema/types.js +39 -0
  68. package/dist/client/schema/types.js.map +1 -0
  69. package/dist/client/types.d.ts +449 -0
  70. package/dist/client/types.d.ts.map +1 -0
  71. package/dist/client/types.js +149 -0
  72. package/dist/client/types.js.map +1 -0
  73. package/dist/client/workflows.d.ts +51 -0
  74. package/dist/client/workflows.d.ts.map +1 -0
  75. package/dist/client/workflows.js +103 -0
  76. package/dist/client/workflows.js.map +1 -0
  77. package/dist/client/wrapper.d.ts +2198 -0
  78. package/dist/client/wrapper.d.ts.map +1 -0
  79. package/dist/client/wrapper.js +2651 -0
  80. package/dist/client/wrapper.js.map +1 -0
  81. package/dist/component/_generated/api.d.ts +124 -0
  82. package/dist/component/_generated/api.d.ts.map +1 -0
  83. package/dist/component/_generated/api.js +31 -0
  84. package/dist/component/_generated/api.js.map +1 -0
  85. package/dist/component/_generated/component.d.ts +4321 -0
  86. package/dist/component/_generated/component.d.ts.map +1 -0
  87. package/dist/component/_generated/component.js +11 -0
  88. package/dist/component/_generated/component.js.map +1 -0
  89. package/dist/component/_generated/dataModel.d.ts +46 -0
  90. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  91. package/dist/component/_generated/dataModel.js +11 -0
  92. package/dist/component/_generated/dataModel.js.map +1 -0
  93. package/dist/component/_generated/server.d.ts +121 -0
  94. package/dist/component/_generated/server.d.ts.map +1 -0
  95. package/dist/component/_generated/server.js +78 -0
  96. package/dist/component/_generated/server.js.map +1 -0
  97. package/dist/component/auditLog.d.ts +410 -0
  98. package/dist/component/auditLog.d.ts.map +1 -0
  99. package/dist/component/auditLog.js +607 -0
  100. package/dist/component/auditLog.js.map +1 -0
  101. package/dist/component/authorization.d.ts +323 -0
  102. package/dist/component/authorization.d.ts.map +1 -0
  103. package/dist/component/authorization.js +464 -0
  104. package/dist/component/authorization.js.map +1 -0
  105. package/dist/component/authorizationHooks.d.ts +184 -0
  106. package/dist/component/authorizationHooks.d.ts.map +1 -0
  107. package/dist/component/authorizationHooks.js +521 -0
  108. package/dist/component/authorizationHooks.js.map +1 -0
  109. package/dist/component/bulkOperations.d.ts +200 -0
  110. package/dist/component/bulkOperations.d.ts.map +1 -0
  111. package/dist/component/bulkOperations.js +568 -0
  112. package/dist/component/bulkOperations.js.map +1 -0
  113. package/dist/component/contentEntries.d.ts +719 -0
  114. package/dist/component/contentEntries.d.ts.map +1 -0
  115. package/dist/component/contentEntries.js +1617 -0
  116. package/dist/component/contentEntries.js.map +1 -0
  117. package/dist/component/contentEntryMutations.d.ts +505 -0
  118. package/dist/component/contentEntryMutations.d.ts.map +1 -0
  119. package/dist/component/contentEntryMutations.js +1009 -0
  120. package/dist/component/contentEntryMutations.js.map +1 -0
  121. package/dist/component/contentEntryValidation.d.ts +115 -0
  122. package/dist/component/contentEntryValidation.d.ts.map +1 -0
  123. package/dist/component/contentEntryValidation.js +546 -0
  124. package/dist/component/contentEntryValidation.js.map +1 -0
  125. package/dist/component/contentLock.d.ts +328 -0
  126. package/dist/component/contentLock.d.ts.map +1 -0
  127. package/dist/component/contentLock.js +471 -0
  128. package/dist/component/contentLock.js.map +1 -0
  129. package/dist/component/contentTypeMigration.d.ts +411 -0
  130. package/dist/component/contentTypeMigration.d.ts.map +1 -0
  131. package/dist/component/contentTypeMigration.js +805 -0
  132. package/dist/component/contentTypeMigration.js.map +1 -0
  133. package/dist/component/contentTypeMutations.d.ts +975 -0
  134. package/dist/component/contentTypeMutations.d.ts.map +1 -0
  135. package/dist/component/contentTypeMutations.js +768 -0
  136. package/dist/component/contentTypeMutations.js.map +1 -0
  137. package/dist/component/contentTypes.d.ts +538 -0
  138. package/dist/component/contentTypes.d.ts.map +1 -0
  139. package/dist/component/contentTypes.js +304 -0
  140. package/dist/component/contentTypes.js.map +1 -0
  141. package/dist/component/convex.config.d.ts +42 -0
  142. package/dist/component/convex.config.d.ts.map +1 -0
  143. package/dist/component/convex.config.js +43 -0
  144. package/dist/component/convex.config.js.map +1 -0
  145. package/dist/component/documentTypes.d.ts +186 -0
  146. package/dist/component/documentTypes.d.ts.map +1 -0
  147. package/dist/component/documentTypes.js +23 -0
  148. package/dist/component/documentTypes.js.map +1 -0
  149. package/dist/component/eventEmitter.d.ts +281 -0
  150. package/dist/component/eventEmitter.d.ts.map +1 -0
  151. package/dist/component/eventEmitter.js +300 -0
  152. package/dist/component/eventEmitter.js.map +1 -0
  153. package/dist/component/exportImport.d.ts +1120 -0
  154. package/dist/component/exportImport.d.ts.map +1 -0
  155. package/dist/component/exportImport.js +931 -0
  156. package/dist/component/exportImport.js.map +1 -0
  157. package/dist/component/index.d.ts +28 -0
  158. package/dist/component/index.d.ts.map +1 -0
  159. package/dist/component/index.js +142 -0
  160. package/dist/component/index.js.map +1 -0
  161. package/dist/component/lib/deepReferenceResolver.d.ts +252 -0
  162. package/dist/component/lib/deepReferenceResolver.d.ts.map +1 -0
  163. package/dist/component/lib/deepReferenceResolver.js +601 -0
  164. package/dist/component/lib/deepReferenceResolver.js.map +1 -0
  165. package/dist/component/lib/errors.d.ts +306 -0
  166. package/dist/component/lib/errors.d.ts.map +1 -0
  167. package/dist/component/lib/errors.js +407 -0
  168. package/dist/component/lib/errors.js.map +1 -0
  169. package/dist/component/lib/index.d.ts +10 -0
  170. package/dist/component/lib/index.d.ts.map +1 -0
  171. package/dist/component/lib/index.js +33 -0
  172. package/dist/component/lib/index.js.map +1 -0
  173. package/dist/component/lib/mediaReferenceResolver.d.ts +217 -0
  174. package/dist/component/lib/mediaReferenceResolver.d.ts.map +1 -0
  175. package/dist/component/lib/mediaReferenceResolver.js +326 -0
  176. package/dist/component/lib/mediaReferenceResolver.js.map +1 -0
  177. package/dist/component/lib/metadataExtractor.d.ts +245 -0
  178. package/dist/component/lib/metadataExtractor.d.ts.map +1 -0
  179. package/dist/component/lib/metadataExtractor.js +548 -0
  180. package/dist/component/lib/metadataExtractor.js.map +1 -0
  181. package/dist/component/lib/mutationAuth.d.ts +95 -0
  182. package/dist/component/lib/mutationAuth.d.ts.map +1 -0
  183. package/dist/component/lib/mutationAuth.js +146 -0
  184. package/dist/component/lib/mutationAuth.js.map +1 -0
  185. package/dist/component/lib/queries.d.ts +17 -0
  186. package/dist/component/lib/queries.d.ts.map +1 -0
  187. package/dist/component/lib/queries.js +49 -0
  188. package/dist/component/lib/queries.js.map +1 -0
  189. package/dist/component/lib/ragContentChunker.d.ts +423 -0
  190. package/dist/component/lib/ragContentChunker.d.ts.map +1 -0
  191. package/dist/component/lib/ragContentChunker.js +897 -0
  192. package/dist/component/lib/ragContentChunker.js.map +1 -0
  193. package/dist/component/lib/referenceResolver.d.ts +175 -0
  194. package/dist/component/lib/referenceResolver.d.ts.map +1 -0
  195. package/dist/component/lib/referenceResolver.js +293 -0
  196. package/dist/component/lib/referenceResolver.js.map +1 -0
  197. package/dist/component/lib/slugGenerator.d.ts +71 -0
  198. package/dist/component/lib/slugGenerator.d.ts.map +1 -0
  199. package/dist/component/lib/slugGenerator.js +207 -0
  200. package/dist/component/lib/slugGenerator.js.map +1 -0
  201. package/dist/component/lib/slugUniqueness.d.ts +131 -0
  202. package/dist/component/lib/slugUniqueness.d.ts.map +1 -0
  203. package/dist/component/lib/slugUniqueness.js +229 -0
  204. package/dist/component/lib/slugUniqueness.js.map +1 -0
  205. package/dist/component/lib/softDelete.d.ts +18 -0
  206. package/dist/component/lib/softDelete.d.ts.map +1 -0
  207. package/dist/component/lib/softDelete.js +29 -0
  208. package/dist/component/lib/softDelete.js.map +1 -0
  209. package/dist/component/localeFallbackChain.d.ts +410 -0
  210. package/dist/component/localeFallbackChain.d.ts.map +1 -0
  211. package/dist/component/localeFallbackChain.js +467 -0
  212. package/dist/component/localeFallbackChain.js.map +1 -0
  213. package/dist/component/localeFields.d.ts +508 -0
  214. package/dist/component/localeFields.d.ts.map +1 -0
  215. package/dist/component/localeFields.js +592 -0
  216. package/dist/component/localeFields.js.map +1 -0
  217. package/dist/component/mediaAssetMutations.d.ts +235 -0
  218. package/dist/component/mediaAssetMutations.d.ts.map +1 -0
  219. package/dist/component/mediaAssetMutations.js +558 -0
  220. package/dist/component/mediaAssetMutations.js.map +1 -0
  221. package/dist/component/mediaAssets.d.ts +168 -0
  222. package/dist/component/mediaAssets.d.ts.map +1 -0
  223. package/dist/component/mediaAssets.js +618 -0
  224. package/dist/component/mediaAssets.js.map +1 -0
  225. package/dist/component/mediaFolderMutations.d.ts +642 -0
  226. package/dist/component/mediaFolderMutations.d.ts.map +1 -0
  227. package/dist/component/mediaFolderMutations.js +849 -0
  228. package/dist/component/mediaFolderMutations.js.map +1 -0
  229. package/dist/component/mediaUploadMutations.d.ts +136 -0
  230. package/dist/component/mediaUploadMutations.d.ts.map +1 -0
  231. package/dist/component/mediaUploadMutations.js +205 -0
  232. package/dist/component/mediaUploadMutations.js.map +1 -0
  233. package/dist/component/mediaVariantMutations.d.ts +468 -0
  234. package/dist/component/mediaVariantMutations.d.ts.map +1 -0
  235. package/dist/component/mediaVariantMutations.js +737 -0
  236. package/dist/component/mediaVariantMutations.js.map +1 -0
  237. package/dist/component/mediaVariants.d.ts +525 -0
  238. package/dist/component/mediaVariants.d.ts.map +1 -0
  239. package/dist/component/mediaVariants.js +661 -0
  240. package/dist/component/mediaVariants.js.map +1 -0
  241. package/dist/component/ragContentIndexer.d.ts +595 -0
  242. package/dist/component/ragContentIndexer.d.ts.map +1 -0
  243. package/dist/component/ragContentIndexer.js +794 -0
  244. package/dist/component/ragContentIndexer.js.map +1 -0
  245. package/dist/component/rateLimitHooks.d.ts +266 -0
  246. package/dist/component/rateLimitHooks.d.ts.map +1 -0
  247. package/dist/component/rateLimitHooks.js +412 -0
  248. package/dist/component/rateLimitHooks.js.map +1 -0
  249. package/dist/component/roles.d.ts +649 -0
  250. package/dist/component/roles.d.ts.map +1 -0
  251. package/dist/component/roles.js +884 -0
  252. package/dist/component/roles.js.map +1 -0
  253. package/dist/component/scheduledPublish.d.ts +182 -0
  254. package/dist/component/scheduledPublish.d.ts.map +1 -0
  255. package/dist/component/scheduledPublish.js +304 -0
  256. package/dist/component/scheduledPublish.js.map +1 -0
  257. package/dist/component/schema.d.ts +4114 -0
  258. package/dist/component/schema.d.ts.map +1 -0
  259. package/dist/component/schema.js +469 -0
  260. package/dist/component/schema.js.map +1 -0
  261. package/dist/component/taxonomies.d.ts +476 -0
  262. package/dist/component/taxonomies.d.ts.map +1 -0
  263. package/dist/component/taxonomies.js +785 -0
  264. package/dist/component/taxonomies.js.map +1 -0
  265. package/dist/component/taxonomyMutations.d.ts +206 -0
  266. package/dist/component/taxonomyMutations.d.ts.map +1 -0
  267. package/dist/component/taxonomyMutations.js +1001 -0
  268. package/dist/component/taxonomyMutations.js.map +1 -0
  269. package/dist/component/trash.d.ts +265 -0
  270. package/dist/component/trash.d.ts.map +1 -0
  271. package/dist/component/trash.js +621 -0
  272. package/dist/component/trash.js.map +1 -0
  273. package/dist/component/types.d.ts +4 -0
  274. package/dist/component/types.d.ts.map +1 -0
  275. package/dist/component/types.js +2 -0
  276. package/dist/component/types.js.map +1 -0
  277. package/dist/component/userContext.d.ts +508 -0
  278. package/dist/component/userContext.d.ts.map +1 -0
  279. package/dist/component/userContext.js +615 -0
  280. package/dist/component/userContext.js.map +1 -0
  281. package/dist/component/validation.d.ts +387 -0
  282. package/dist/component/validation.d.ts.map +1 -0
  283. package/dist/component/validation.js +1052 -0
  284. package/dist/component/validation.js.map +1 -0
  285. package/dist/component/validators.d.ts +4645 -0
  286. package/dist/component/validators.d.ts.map +1 -0
  287. package/dist/component/validators.js +641 -0
  288. package/dist/component/validators.js.map +1 -0
  289. package/dist/component/versionMutations.d.ts +216 -0
  290. package/dist/component/versionMutations.d.ts.map +1 -0
  291. package/dist/component/versionMutations.js +321 -0
  292. package/dist/component/versionMutations.js.map +1 -0
  293. package/dist/component/webhookTrigger.d.ts +770 -0
  294. package/dist/component/webhookTrigger.d.ts.map +1 -0
  295. package/dist/component/webhookTrigger.js +1413 -0
  296. package/dist/component/webhookTrigger.js.map +1 -0
  297. package/dist/react/index.d.ts +316 -0
  298. package/dist/react/index.d.ts.map +1 -0
  299. package/dist/react/index.js +558 -0
  300. package/dist/react/index.js.map +1 -0
  301. package/dist/test.d.ts +2230 -0
  302. package/dist/test.d.ts.map +1 -0
  303. package/dist/test.js +1107 -0
  304. package/dist/test.js.map +1 -0
  305. package/package.json +95 -0
  306. package/src/cli/commands/admin.ts +104 -0
  307. package/src/cli/index.ts +21 -0
  308. package/src/cli/utils/detectConvexUrl.ts +54 -0
  309. package/src/cli/utils/openBrowser.ts +16 -0
  310. package/src/client/admin-config.ts +138 -0
  311. package/src/client/adminApi.ts +942 -0
  312. package/src/client/agentTools.ts +1311 -0
  313. package/src/client/argTypes.ts +316 -0
  314. package/src/client/field-types.ts +187 -0
  315. package/src/client/index.ts +1301 -0
  316. package/src/client/queryBuilder.ts +1100 -0
  317. package/src/client/schema/codegen.ts +500 -0
  318. package/src/client/schema/defineContentType.ts +501 -0
  319. package/src/client/schema/index.ts +169 -0
  320. package/src/client/schema/schemaDrift.ts +574 -0
  321. package/src/client/schema/typedClient.ts +688 -0
  322. package/src/client/schema/types.ts +666 -0
  323. package/src/client/types.ts +723 -0
  324. package/src/client/workflows.ts +141 -0
  325. package/src/client/wrapper.ts +4304 -0
  326. package/src/component/_generated/api.ts +140 -0
  327. package/src/component/_generated/component.ts +5029 -0
  328. package/src/component/_generated/dataModel.ts +60 -0
  329. package/src/component/_generated/server.ts +156 -0
  330. package/src/component/authorization.ts +647 -0
  331. package/src/component/authorizationHooks.ts +668 -0
  332. package/src/component/bulkOperations.ts +687 -0
  333. package/src/component/contentEntries.ts +1976 -0
  334. package/src/component/contentEntryMutations.ts +1223 -0
  335. package/src/component/contentEntryValidation.ts +707 -0
  336. package/src/component/contentLock.ts +550 -0
  337. package/src/component/contentTypeMigration.ts +1064 -0
  338. package/src/component/contentTypeMutations.ts +969 -0
  339. package/src/component/contentTypes.ts +346 -0
  340. package/src/component/convex.config.ts +44 -0
  341. package/src/component/documentTypes.ts +240 -0
  342. package/src/component/eventEmitter.ts +485 -0
  343. package/src/component/exportImport.ts +1169 -0
  344. package/src/component/index.ts +491 -0
  345. package/src/component/lib/deepReferenceResolver.ts +999 -0
  346. package/src/component/lib/errors.ts +816 -0
  347. package/src/component/lib/index.ts +145 -0
  348. package/src/component/lib/mediaReferenceResolver.ts +495 -0
  349. package/src/component/lib/metadataExtractor.ts +792 -0
  350. package/src/component/lib/mutationAuth.ts +199 -0
  351. package/src/component/lib/queries.ts +79 -0
  352. package/src/component/lib/ragContentChunker.ts +1371 -0
  353. package/src/component/lib/referenceResolver.ts +430 -0
  354. package/src/component/lib/slugGenerator.ts +262 -0
  355. package/src/component/lib/slugUniqueness.ts +333 -0
  356. package/src/component/lib/softDelete.ts +44 -0
  357. package/src/component/localeFallbackChain.ts +673 -0
  358. package/src/component/localeFields.ts +896 -0
  359. package/src/component/mediaAssetMutations.ts +725 -0
  360. package/src/component/mediaAssets.ts +932 -0
  361. package/src/component/mediaFolderMutations.ts +1046 -0
  362. package/src/component/mediaUploadMutations.ts +224 -0
  363. package/src/component/mediaVariantMutations.ts +900 -0
  364. package/src/component/mediaVariants.ts +793 -0
  365. package/src/component/ragContentIndexer.ts +1067 -0
  366. package/src/component/rateLimitHooks.ts +572 -0
  367. package/src/component/roles.ts +1360 -0
  368. package/src/component/scheduledPublish.ts +358 -0
  369. package/src/component/schema.ts +617 -0
  370. package/src/component/taxonomies.ts +949 -0
  371. package/src/component/taxonomyMutations.ts +1210 -0
  372. package/src/component/trash.ts +724 -0
  373. package/src/component/userContext.ts +898 -0
  374. package/src/component/validation.ts +1388 -0
  375. package/src/component/validators.ts +949 -0
  376. package/src/component/versionMutations.ts +392 -0
  377. package/src/component/webhookTrigger.ts +1922 -0
  378. package/src/react/index.ts +898 -0
  379. package/src/test.ts +1580 -0
@@ -0,0 +1,615 @@
1
+ /**
2
+ * User Context Handler Module
3
+ *
4
+ * Functions to receive and validate user context passed from parent apps.
5
+ * Extracts user ID and roles for permission checks in the CMS authorization system.
6
+ *
7
+ * This module bridges the gap between external authentication systems and the
8
+ * CMS's internal RBAC (Role-Based Access Control) system. The CMS is auth-agnostic,
9
+ * meaning it doesn't own user authentication - instead, it relies on the parent
10
+ * application to provide user identification.
11
+ *
12
+ * Key concepts:
13
+ * - UserContext: The validated user information passed to CMS operations
14
+ * - User ID: A string identifier from your auth system (Clerk, Auth0, custom, etc.)
15
+ * - Role: The CMS role assigned to the user (admin, editor, author, viewer, or custom)
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { createUserContext, validateUserContext, extractUserId } from './userContext';
20
+ *
21
+ * // In your Convex function:
22
+ * export const createPost = mutation({
23
+ * handler: async (ctx, args) => {
24
+ * // Get user from your auth system
25
+ * const identity = await ctx.auth.getUserIdentity();
26
+ *
27
+ * // Create and validate user context
28
+ * const userContext = await createUserContext({
29
+ * userId: identity?.subject,
30
+ * getUserRole: config.getUserRole,
31
+ * });
32
+ *
33
+ * // Use in CMS operations
34
+ * const entry = await cms.contentEntries.create(ctx, {
35
+ * ...args,
36
+ * createdBy: userContext.userId,
37
+ * });
38
+ * },
39
+ * });
40
+ * ```
41
+ */
42
+ import { getRole } from "./roles.js";
43
+ // =============================================================================
44
+ // User Context Error Class
45
+ // =============================================================================
46
+ /**
47
+ * Error thrown when user context validation fails.
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * try {
52
+ * const context = await createUserContext({ input, getUserRole });
53
+ * } catch (error) {
54
+ * if (error instanceof UserContextError) {
55
+ * console.log(error.code); // 'ANONYMOUS_NOT_ALLOWED'
56
+ * console.log(error.message); // 'Anonymous users are not allowed'
57
+ * }
58
+ * }
59
+ * ```
60
+ */
61
+ export class UserContextError extends Error {
62
+ code;
63
+ details;
64
+ constructor(error) {
65
+ super(error.message);
66
+ this.name = "UserContextError";
67
+ this.code = error.code;
68
+ this.details = error.details;
69
+ if (Error.captureStackTrace) {
70
+ Error.captureStackTrace(this, UserContextError);
71
+ }
72
+ }
73
+ toJSON() {
74
+ return {
75
+ name: this.name,
76
+ code: this.code,
77
+ message: this.message,
78
+ details: this.details,
79
+ };
80
+ }
81
+ }
82
+ // =============================================================================
83
+ // Validation Functions
84
+ // =============================================================================
85
+ /**
86
+ * Validate a user ID string.
87
+ *
88
+ * @param userId - The user ID to validate
89
+ * @returns True if the user ID is valid
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * isValidUserId("user_123"); // true
94
+ * isValidUserId(""); // false
95
+ * isValidUserId(null); // false
96
+ * ```
97
+ */
98
+ export function isValidUserId(userId) {
99
+ return typeof userId === "string" && userId.trim().length > 0;
100
+ }
101
+ /**
102
+ * Validate that a role name exists in the role definitions.
103
+ *
104
+ * @param roleName - The role name to validate
105
+ * @param customRoles - Optional custom role definitions
106
+ * @returns True if the role exists
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * isValidRole("admin"); // true (built-in)
111
+ * isValidRole("blog-author", { "blog-author": {...} }); // true (custom)
112
+ * isValidRole("unknown"); // false
113
+ * ```
114
+ */
115
+ export function isValidRole(roleName, customRoles) {
116
+ if (roleName === null || roleName === undefined) {
117
+ return false;
118
+ }
119
+ // getRole returns undefined if role not found
120
+ return getRole(roleName, customRoles) !== undefined;
121
+ }
122
+ /**
123
+ * Validate user context input without creating the full context.
124
+ * Use this for quick validation before expensive operations.
125
+ *
126
+ * @param input - The user context input to validate
127
+ * @param options - Validation options
128
+ * @returns Validation result with errors if invalid
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const result = validateUserContextInput(
133
+ * { userId: "user_123" },
134
+ * { allowAnonymous: false }
135
+ * );
136
+ *
137
+ * if (!result.valid) {
138
+ * console.log(result.errors); // Validation errors
139
+ * }
140
+ * ```
141
+ */
142
+ export function validateUserContextInput(input, options = {}) {
143
+ const { allowAnonymous = true, requireRole = false, customRoles } = options;
144
+ const errors = [];
145
+ // Validate user ID format (if provided)
146
+ if (input.userId !== undefined && input.userId !== null) {
147
+ if (typeof input.userId !== "string") {
148
+ errors.push({
149
+ code: "INVALID_USER_ID",
150
+ message: "User ID must be a string",
151
+ details: { receivedType: typeof input.userId },
152
+ });
153
+ }
154
+ else if (input.userId.trim().length === 0) {
155
+ errors.push({
156
+ code: "INVALID_USER_ID",
157
+ message: "User ID cannot be empty",
158
+ });
159
+ }
160
+ }
161
+ // Check anonymous access
162
+ const isAuthenticated = isValidUserId(input.userId);
163
+ if (!allowAnonymous && !isAuthenticated) {
164
+ errors.push({
165
+ code: "ANONYMOUS_NOT_ALLOWED",
166
+ message: "Authentication is required for this operation",
167
+ });
168
+ }
169
+ // Validate role if provided
170
+ if (input.role !== undefined && input.role !== null) {
171
+ if (!isValidRole(input.role, customRoles)) {
172
+ errors.push({
173
+ code: "UNKNOWN_ROLE",
174
+ message: `Unknown role: ${input.role}`,
175
+ details: { role: input.role },
176
+ });
177
+ }
178
+ }
179
+ else if (requireRole) {
180
+ // Role is required but not provided
181
+ errors.push({
182
+ code: "ROLE_REQUIRED",
183
+ message: "A CMS role is required for this operation",
184
+ });
185
+ }
186
+ return {
187
+ valid: errors.length === 0,
188
+ errors: errors.length > 0 ? errors : undefined,
189
+ };
190
+ }
191
+ // =============================================================================
192
+ // User Context Creation Functions
193
+ // =============================================================================
194
+ /**
195
+ * Resolve the user's CMS role using the getUserRole hook.
196
+ *
197
+ * @param ctx - The CMS hook context (provides db and auth access)
198
+ * @param userId - The user ID to look up
199
+ * @param getUserRole - The getUserRole hook from configuration
200
+ * @returns The resolved role name or null
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * const role = await resolveUserRole(ctx, "user_123", config.getUserRole);
205
+ * console.log(role); // "editor" or null
206
+ * ```
207
+ */
208
+ export async function resolveUserRole(ctx, userId, getUserRole) {
209
+ if (!getUserRole) {
210
+ return null;
211
+ }
212
+ try {
213
+ const context = { userId };
214
+ return await getUserRole(ctx, context);
215
+ }
216
+ catch (error) {
217
+ // Re-throw with context for better error handling
218
+ const message = error instanceof Error ? error.message : "Unknown error";
219
+ throw new UserContextError({
220
+ code: "HOOK_ERROR",
221
+ message: `getUserRole hook failed: ${message}`,
222
+ details: { userId, originalError: message },
223
+ });
224
+ }
225
+ }
226
+ /**
227
+ * Create a validated user context from input.
228
+ *
229
+ * This is the main function for converting raw user input into a validated
230
+ * UserContext that can be used throughout CMS operations. It handles:
231
+ * - User ID validation
232
+ * - Role resolution via the getUserRole hook
233
+ * - Role validation against built-in and custom roles
234
+ * - Access control checks (anonymous, role requirements)
235
+ *
236
+ * @param options - Options including input and hooks
237
+ * @returns Validated UserContext
238
+ * @throws UserContextError if validation fails
239
+ *
240
+ * @example
241
+ * ```typescript
242
+ * // Basic usage with getUserRole hook
243
+ * const context = await createUserContext({
244
+ * input: { userId: identity?.subject },
245
+ * getUserRole: config.getUserRole,
246
+ * });
247
+ *
248
+ * // With pre-resolved role (skips hook)
249
+ * const context = await createUserContext({
250
+ * input: { userId: "user_123", role: "editor" },
251
+ * });
252
+ *
253
+ * // Require authentication
254
+ * const context = await createUserContext({
255
+ * input: { userId },
256
+ * allowAnonymous: false,
257
+ * });
258
+ * ```
259
+ */
260
+ export async function createUserContext(options) {
261
+ const { ctx, input, getUserRole, customRoles, allowAnonymous = true, requireRole = false, } = options;
262
+ // Validate input
263
+ const validation = validateUserContextInput(input, {
264
+ allowAnonymous,
265
+ requireRole: false, // We'll check this after resolving the role
266
+ customRoles,
267
+ });
268
+ if (!validation.valid && validation.errors) {
269
+ throw new UserContextError(validation.errors[0]);
270
+ }
271
+ // Normalize userId
272
+ const userId = isValidUserId(input.userId) ? input.userId : undefined;
273
+ const isAuthenticated = userId !== undefined;
274
+ // Resolve role
275
+ let role = null;
276
+ if (input.role !== undefined && input.role !== null) {
277
+ // Use pre-provided role
278
+ role = input.role;
279
+ }
280
+ else if (userId && getUserRole && ctx) {
281
+ // Resolve role via hook
282
+ role = await resolveUserRole(ctx, userId, getUserRole);
283
+ }
284
+ // Validate resolved role
285
+ const roleDefinition = role ? getRole(role, customRoles) ?? undefined : undefined;
286
+ const hasRole = roleDefinition !== undefined;
287
+ // Check role requirement
288
+ if (requireRole && !hasRole) {
289
+ throw new UserContextError({
290
+ code: "ROLE_REQUIRED",
291
+ message: isAuthenticated
292
+ ? `User ${userId} has no CMS role assigned`
293
+ : "Authentication and a CMS role are required",
294
+ details: { userId, resolvedRole: role },
295
+ });
296
+ }
297
+ // Warn about unknown roles (but don't fail if requireRole is false)
298
+ if (role !== null && !hasRole) {
299
+ // Role was provided but doesn't exist - this is logged but not an error
300
+ // unless requireRole is true (handled above)
301
+ console.warn(`Unknown CMS role "${role}" for user ${userId ?? "anonymous"}`);
302
+ }
303
+ return {
304
+ userId,
305
+ role,
306
+ isAuthenticated,
307
+ hasRole,
308
+ roleDefinition,
309
+ email: input.email,
310
+ displayName: input.displayName,
311
+ metadata: input.metadata,
312
+ };
313
+ }
314
+ /**
315
+ * Create a user context synchronously when the role is already known.
316
+ * Use this when you've already resolved the role or want to skip hook execution.
317
+ *
318
+ * @param input - User context input with role pre-resolved
319
+ * @param customRoles - Optional custom role definitions
320
+ * @returns Validated UserContext
321
+ *
322
+ * @example
323
+ * ```typescript
324
+ * // When role is already known
325
+ * const context = createUserContextSync({
326
+ * userId: "user_123",
327
+ * role: "editor",
328
+ * });
329
+ * ```
330
+ */
331
+ export function createUserContextSync(input, customRoles) {
332
+ const userId = isValidUserId(input.userId) ? input.userId : undefined;
333
+ const role = input.role ?? null;
334
+ const roleDefinition = role ? getRole(role, customRoles) ?? undefined : undefined;
335
+ return {
336
+ userId,
337
+ role,
338
+ isAuthenticated: userId !== undefined,
339
+ hasRole: roleDefinition !== undefined,
340
+ roleDefinition,
341
+ email: input.email,
342
+ displayName: input.displayName,
343
+ metadata: input.metadata,
344
+ };
345
+ }
346
+ // =============================================================================
347
+ // User ID Extraction Functions
348
+ // =============================================================================
349
+ /**
350
+ * Extract user ID from various input formats.
351
+ * Handles common patterns from different auth systems.
352
+ *
353
+ * @param input - The input to extract userId from
354
+ * @returns The extracted userId or undefined
355
+ *
356
+ * @example
357
+ * ```typescript
358
+ * // From Convex identity
359
+ * extractUserId(identity); // uses identity.subject
360
+ *
361
+ * // From string
362
+ * extractUserId("user_123"); // "user_123"
363
+ *
364
+ * // From object with common fields
365
+ * extractUserId({ sub: "user_123" }); // "user_123"
366
+ * extractUserId({ userId: "user_123" }); // "user_123"
367
+ * extractUserId({ id: "user_123" }); // "user_123"
368
+ * ```
369
+ */
370
+ export function extractUserId(input) {
371
+ if (input === null || input === undefined) {
372
+ return undefined;
373
+ }
374
+ // String input
375
+ if (typeof input === "string") {
376
+ return isValidUserId(input) ? input : undefined;
377
+ }
378
+ // Object input - try common fields in order of priority
379
+ const candidates = [
380
+ input.subject, // Convex identity
381
+ input.sub, // JWT standard
382
+ input.userId, // Common custom field
383
+ input.id, // Generic ID field
384
+ input._id, // MongoDB-style
385
+ ];
386
+ for (const candidate of candidates) {
387
+ if (isValidUserId(candidate)) {
388
+ return candidate;
389
+ }
390
+ }
391
+ return undefined;
392
+ }
393
+ /**
394
+ * Extract user ID from a Convex auth context.
395
+ * This is a convenience wrapper for extractUserId that works with ctx.auth.
396
+ *
397
+ * @param authContext - The auth context from ctx.auth
398
+ * @returns The user ID or undefined if not authenticated
399
+ *
400
+ * @example
401
+ * ```typescript
402
+ * export const myMutation = mutation({
403
+ * handler: async (ctx, args) => {
404
+ * const userId = await extractUserIdFromAuth(ctx.auth);
405
+ * if (!userId) {
406
+ * throw new Error("Authentication required");
407
+ * }
408
+ * // ... use userId
409
+ * },
410
+ * });
411
+ * ```
412
+ */
413
+ export async function extractUserIdFromAuth(authContext) {
414
+ const identity = await authContext.getUserIdentity();
415
+ return extractUserId(identity);
416
+ }
417
+ // =============================================================================
418
+ // Authorization Context Builders
419
+ // =============================================================================
420
+ /**
421
+ * Build an AuthorizationHookContext from a UserContext and operation details.
422
+ * This creates the context object used by authorization hooks.
423
+ *
424
+ * @param userContext - The validated user context
425
+ * @param operation - The CMS operation being performed
426
+ * @param resourceInfo - Additional resource information
427
+ * @returns AuthorizationHookContext for hook execution
428
+ *
429
+ * @example
430
+ * ```typescript
431
+ * const hookContext = buildAuthorizationContext(
432
+ * userContext,
433
+ * "contentEntries.update",
434
+ * {
435
+ * resourceId: entry._id,
436
+ * resourceOwnerId: entry.createdBy,
437
+ * contentTypeId: entry.contentTypeId,
438
+ * contentTypeName: contentType.name,
439
+ * }
440
+ * );
441
+ * ```
442
+ */
443
+ export function buildAuthorizationContext(userContext, operation, resourceInfo) {
444
+ return {
445
+ operation,
446
+ userId: userContext.userId,
447
+ role: userContext.role,
448
+ resourceId: resourceInfo?.resourceId,
449
+ resourceOwnerId: resourceInfo?.resourceOwnerId,
450
+ contentTypeId: resourceInfo?.contentTypeId,
451
+ contentTypeName: resourceInfo?.contentTypeName,
452
+ operationData: {
453
+ ...resourceInfo?.operationData,
454
+ // Include user context metadata for custom hooks
455
+ _userMetadata: userContext.metadata,
456
+ },
457
+ };
458
+ }
459
+ /**
460
+ * Create a minimal user context for anonymous operations.
461
+ * Use this for public read operations that don't require authentication.
462
+ *
463
+ * @returns A UserContext representing an anonymous user
464
+ *
465
+ * @example
466
+ * ```typescript
467
+ * // For public content queries
468
+ * const context = createAnonymousContext();
469
+ * // context.isAuthenticated === false
470
+ * // context.hasRole === false
471
+ * ```
472
+ */
473
+ export function createAnonymousContext() {
474
+ return {
475
+ userId: undefined,
476
+ role: null,
477
+ isAuthenticated: false,
478
+ hasRole: false,
479
+ };
480
+ }
481
+ /**
482
+ * Create a system context for internal operations.
483
+ * This bypasses normal user authentication for system-level operations.
484
+ * Use with caution - only for trusted internal operations.
485
+ *
486
+ * @param systemId - Optional identifier for the system operation
487
+ * @returns A UserContext representing a system operation
488
+ *
489
+ * @example
490
+ * ```typescript
491
+ * // For scheduled jobs or internal migrations
492
+ * const context = createSystemContext("scheduled-publisher");
493
+ * // context.userId === "_system:scheduled-publisher"
494
+ * // context.role === "admin" (full access)
495
+ * ```
496
+ */
497
+ export function createSystemContext(systemId) {
498
+ const userId = systemId ? `_system:${systemId}` : "_system";
499
+ return {
500
+ userId,
501
+ role: "admin",
502
+ isAuthenticated: true,
503
+ hasRole: true,
504
+ metadata: {
505
+ isSystemContext: true,
506
+ systemId,
507
+ },
508
+ };
509
+ }
510
+ // =============================================================================
511
+ // Utility Functions
512
+ // =============================================================================
513
+ /**
514
+ * Check if a user context represents an authenticated user.
515
+ *
516
+ * @param context - The user context to check
517
+ * @returns True if the user is authenticated
518
+ */
519
+ export function isAuthenticated(context) {
520
+ return context.isAuthenticated && context.userId !== undefined;
521
+ }
522
+ /**
523
+ * Check if a user context has a specific role.
524
+ *
525
+ * @param context - The user context to check
526
+ * @param roleName - The role name to check for
527
+ * @returns True if the user has the specified role
528
+ */
529
+ export function hasUserRole(context, roleName) {
530
+ return context.role === roleName && context.hasRole;
531
+ }
532
+ /**
533
+ * Check if a user context represents a system operation.
534
+ *
535
+ * @param context - The user context to check
536
+ * @returns True if this is a system context
537
+ */
538
+ export function isSystemContext(context) {
539
+ return context.metadata?.isSystemContext === true;
540
+ }
541
+ /**
542
+ * Get the display identifier for a user context.
543
+ * Useful for logging and audit trails.
544
+ *
545
+ * @param context - The user context
546
+ * @returns A human-readable identifier for the user
547
+ */
548
+ export function getUserDisplayId(context) {
549
+ if (context.displayName) {
550
+ return context.displayName;
551
+ }
552
+ if (context.email) {
553
+ return context.email;
554
+ }
555
+ if (context.userId) {
556
+ if (context.userId.startsWith("_system")) {
557
+ return `System (${context.userId.replace("_system:", "")})`;
558
+ }
559
+ return context.userId;
560
+ }
561
+ return "Anonymous";
562
+ }
563
+ /**
564
+ * Validate that a user context meets minimum requirements for an operation.
565
+ * Returns validation result with specific error messages.
566
+ *
567
+ * @param context - The user context to validate
568
+ * @param requirements - The requirements to check
569
+ * @returns Validation result
570
+ *
571
+ * @example
572
+ * ```typescript
573
+ * const result = validateUserContext(context, {
574
+ * requireAuthentication: true,
575
+ * requireRole: true,
576
+ * allowedRoles: ["admin", "editor"],
577
+ * });
578
+ *
579
+ * if (!result.valid) {
580
+ * throw new Error(result.errors[0].message);
581
+ * }
582
+ * ```
583
+ */
584
+ export function validateUserContext(context, requirements) {
585
+ const errors = [];
586
+ if (requirements.requireAuthentication && !context.isAuthenticated) {
587
+ errors.push({
588
+ code: "ANONYMOUS_NOT_ALLOWED",
589
+ message: "Authentication is required for this operation",
590
+ });
591
+ }
592
+ if (requirements.requireRole && !context.hasRole) {
593
+ errors.push({
594
+ code: "ROLE_REQUIRED",
595
+ message: "A valid CMS role is required for this operation",
596
+ });
597
+ }
598
+ if (requirements.allowedRoles && context.role) {
599
+ if (!requirements.allowedRoles.includes(context.role)) {
600
+ errors.push({
601
+ code: "UNKNOWN_ROLE",
602
+ message: `Role "${context.role}" is not allowed for this operation`,
603
+ details: {
604
+ allowedRoles: requirements.allowedRoles,
605
+ actualRole: context.role,
606
+ },
607
+ });
608
+ }
609
+ }
610
+ if (errors.length > 0) {
611
+ return { valid: false, errors };
612
+ }
613
+ return { valid: true, context };
614
+ }
615
+ //# sourceMappingURL=userContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userContext.js","sourceRoot":"","sources":["../../src/component/userContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAWH,OAAO,EAAE,OAAO,EAAuB,MAAM,YAAY,CAAC;AAuL1D,gFAAgF;AAChF,2BAA2B;AAC3B,gFAAgF;AAEhF;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,IAAI,CAAqC;IACzC,OAAO,CAA2B;IAE3C,YAAY,KAAiC;QAC3C,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAE7B,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF;AAED,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF;;;;;;;;;;;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