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,2198 @@
1
+ /** CMS Client Wrapper with typed method APIs */
2
+ import type { GenericDataModel, GenericMutationCtx } from "convex/server";
3
+ import type { ComponentApi as GeneratedComponentApi } from "../component/_generated/component.js";
4
+ import type { ComponentConfig, ResolvedComponentConfig, FeatureFlags, LocaleCode, ContentType, ContentEntry, ContentVersion, MediaAsset, MediaFolder, PaginationResult, PaginationOpts, GetUserRoleResult, AuthorizationHookContext, CmsOperation, VersionComparison, MediaVariant, MediaVariantWithUrl } from "./types.js";
5
+ import { ContentQueryBuilder } from "./queryBuilder.js";
6
+ import { type AuthorizationResult } from "../component/authorizationHooks.js";
7
+ import { type RateLimitResult } from "../component/rateLimitHooks.js";
8
+ import { type Resource, type Action, type OwnershipScope, type RoleDefinition } from "../component/roles.js";
9
+ import { type LocaleFallbackConfig, type ResolvedFallbackChain } from "../component/localeFallbackChain.js";
10
+ import { type LocaleResolvedEntry, type ResolveLocaleOptions } from "../component/localeFields.js";
11
+ /**
12
+ * Options for resolving locale content in client wrapper methods.
13
+ * Extends ResolveLocaleOptions but makes fields required since
14
+ * they are needed for proper locale resolution.
15
+ */
16
+ export type ResolveLocaleContentOptions = ResolveLocaleOptions;
17
+ /**
18
+ * Authorization helper interface passed to API classes.
19
+ * This allows API methods to perform authorization checks before mutations.
20
+ *
21
+ * When authorization is not configured (getUserRole not provided), the helper
22
+ * will be undefined and authorization checks will be skipped.
23
+ */
24
+ export interface AuthorizationHelper {
25
+ /**
26
+ * Get the user's CMS role.
27
+ * @param ctx - The Convex context (provides database and auth access to hooks)
28
+ * @param userId - The user ID to look up
29
+ * @returns The role name or null if user has no role
30
+ */
31
+ getUserRole(ctx: ConvexContext, userId: string): Promise<string | null>;
32
+ /**
33
+ * Perform authorization check and throw if denied.
34
+ * @param ctx - The Convex context (provides database and auth access to hooks)
35
+ * @param context - The authorization context
36
+ * @throws UnauthorizedError if the operation is not allowed
37
+ */
38
+ requireAuthorization(ctx: ConvexContext, context: Omit<AuthorizationHookContext, 'ctx'>): Promise<AuthorizationResult>;
39
+ /**
40
+ * Whether RBAC should be skipped (from config.skipRbac).
41
+ */
42
+ skipRbac: boolean;
43
+ }
44
+ /**
45
+ * Rate limit helper interface passed to API classes.
46
+ * This allows API methods to enforce rate limits before mutations.
47
+ *
48
+ * When rate limiting is not configured (no rateLimitHooks provided), the helper
49
+ * will be undefined and rate limiting checks will be skipped.
50
+ */
51
+ export interface RateLimitHelper {
52
+ /**
53
+ * Get the user's CMS role for rate limit context.
54
+ * @param ctx - The Convex context (for database access)
55
+ * @param userId - The user ID to look up
56
+ * @returns The role name or null if user has no role
57
+ */
58
+ getUserRole(ctx: ConvexContext, userId: string): Promise<string | null>;
59
+ /**
60
+ * Enforce rate limit for an operation. Throws RateLimitedError if rate limited.
61
+ * @param operation - The CMS operation being performed
62
+ * @param options - Additional context for rate limiting
63
+ * @throws RateLimitedError if the operation is rate limited
64
+ */
65
+ requireRateLimit(operation: CmsOperation, options: {
66
+ userId?: string;
67
+ role?: string | null;
68
+ contentTypeId?: string;
69
+ contentTypeName?: string;
70
+ metadata?: Record<string, unknown>;
71
+ }): Promise<RateLimitResult>;
72
+ }
73
+ /** Convex context for CMS operations - includes db/auth for authorization hooks */
74
+ export type ConvexContext = Pick<GenericMutationCtx<GenericDataModel>, "runMutation" | "runQuery" | "db" | "auth">;
75
+ /** Component API type from `components.convexCms` */
76
+ export type TypedComponentApi = GeneratedComponentApi;
77
+ /**
78
+ * Partial component API type for testing purposes.
79
+ *
80
+ * This type allows partial/mock implementations of the component API
81
+ * for unit testing without requiring full type conformance.
82
+ * In production, use TypedComponentApi instead.
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * // In test files
87
+ * const mockApi: MockComponentApi = {
88
+ * contentEntries: {
89
+ * list: { _type: "query" } ,
90
+ * },
91
+ * } as MockComponentApi;
92
+ * ```
93
+ */
94
+ export type MockComponentApi = Partial<{
95
+ [K in keyof TypedComponentApi]: Partial<TypedComponentApi[K]>;
96
+ }>;
97
+ export type { CreateContentTypeArgs, UpdateContentTypeArgs, DeleteContentTypeArgs, GetContentTypeArgs, ListContentTypesArgs, CreateContentEntryArgs, UpdateContentEntryArgs, DeleteContentEntryArgs, GetContentEntryArgs, GetContentEntryBySlugArgs, ListContentEntriesArgs, PublishEntryArgs, UnpublishEntryArgs, ScheduleEntryArgs, RestoreEntryArgs, DuplicateEntryArgs, BulkPublishArgs, BulkUnpublishArgs, BulkDeleteArgs, BulkUpdateArgs, BulkRestoreArgs, GetVersionArgs, GetVersionHistoryArgs, RollbackVersionArgs, CompareVersionsArgs, CreateMediaAssetArgs, UpdateMediaAssetArgs, DeleteMediaAssetArgs, GetMediaAssetArgs, ListMediaAssetsArgs, RestoreMediaAssetArgs, FindMediaAssetReferencesArgs, CreateMediaFolderArgs, UpdateMediaFolderArgs, DeleteMediaFolderArgs, GetMediaFolderArgs, ListMediaFoldersArgs, MoveFolderArgs, RestoreMediaFolderArgs, GetMediaFolderByPathArgs, GetFolderTreeArgs, MoveMediaAssetsArgs, CreateMediaVariantArgs, RequestVariantGenerationArgs, DeleteMediaVariantArgs, DeleteAssetVariantsArgs, GetMediaVariantArgs, ListMediaVariantsArgs, GetBestVariantArgs, GenerateFromPresetsArgs, GenerateUploadUrlArgs, BreakingChange, UpdateContentTypeResult, DeleteContentTypeResult, BulkOperationItemResult, BulkOperationResult, GenerateUploadUrlResult, MediaAssetReference, GenerateVariantsResult, SrcsetEntry, ResponsiveSrcsetResult, VariantPreset, AssetWithVariants, } from "./argTypes.js";
98
+ import type { CreateContentTypeArgs, UpdateContentTypeArgs, DeleteContentTypeArgs, GetContentTypeArgs, ListContentTypesArgs, CreateContentEntryArgs, UpdateContentEntryArgs, DeleteContentEntryArgs, GetContentEntryArgs, GetContentEntryBySlugArgs, ListContentEntriesArgs, PublishEntryArgs, UnpublishEntryArgs, ScheduleEntryArgs, RestoreEntryArgs, DuplicateEntryArgs, BulkPublishArgs, BulkUnpublishArgs, BulkDeleteArgs, BulkUpdateArgs, BulkRestoreArgs, GetVersionArgs, GetVersionHistoryArgs, RollbackVersionArgs, CompareVersionsArgs, CreateMediaAssetArgs, UpdateMediaAssetArgs, DeleteMediaAssetArgs, GetMediaAssetArgs, ListMediaAssetsArgs, RestoreMediaAssetArgs, FindMediaAssetReferencesArgs, CreateMediaFolderArgs, UpdateMediaFolderArgs, DeleteMediaFolderArgs, GetMediaFolderArgs, ListMediaFoldersArgs, MoveFolderArgs, RestoreMediaFolderArgs, GetMediaFolderByPathArgs, GetFolderTreeArgs, CreateMediaVariantArgs, RequestVariantGenerationArgs, DeleteMediaVariantArgs, DeleteAssetVariantsArgs, ListMediaVariantsArgs, GetBestVariantArgs, GenerateFromPresetsArgs, GenerateUploadUrlArgs, UpdateContentTypeResult, DeleteContentTypeResult, BulkOperationResult, GenerateUploadUrlResult, MediaAssetReference, GenerateVariantsResult, ResponsiveSrcsetResult, VariantPreset, AssetWithVariants } from "./argTypes.js";
99
+ /** Content type CRUD operations */
100
+ export declare class ContentTypesApi {
101
+ private readonly api;
102
+ private readonly config;
103
+ private readonly authHelper?;
104
+ private readonly rateLimitHelper?;
105
+ constructor(api: TypedComponentApi, config: ResolvedComponentConfig, authHelper?: AuthorizationHelper | undefined, rateLimitHelper?: RateLimitHelper | undefined);
106
+ /** @throws AuthorizationNotConfiguredError if not configured and not in permissiveMode */
107
+ private authorize;
108
+ private rateLimit;
109
+ create(ctx: ConvexContext, args: CreateContentTypeArgs): Promise<ContentType>;
110
+ /** Detects breaking changes; fails unless force:true is specified */
111
+ update(ctx: ConvexContext, args: UpdateContentTypeArgs): Promise<UpdateContentTypeResult>;
112
+ /** Soft delete by default; use hardDelete:true for permanent, cascade:true to delete entries */
113
+ delete(ctx: ConvexContext, args: DeleteContentTypeArgs): Promise<DeleteContentTypeResult>;
114
+ /**
115
+ * Get a content type by ID or name.
116
+ *
117
+ * @param ctx - Convex query context
118
+ * @param args - Get arguments (id or name)
119
+ * @returns The content type or null if not found
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * // Get by ID (fastest - direct document lookup)
124
+ * const type = await cms.contentTypes.get(ctx, { id: typeId });
125
+ *
126
+ * // Get by name (uses index)
127
+ * const type = await cms.contentTypes.get(ctx, { name: "blog_post" });
128
+ *
129
+ * // Include soft-deleted types
130
+ * const type = await cms.contentTypes.get(ctx, {
131
+ * name: "archived_type",
132
+ * includeDeleted: true,
133
+ * });
134
+ * ```
135
+ */
136
+ get(ctx: ConvexContext, args: GetContentTypeArgs): Promise<ContentType | null>;
137
+ /**
138
+ * Get a content type by name.
139
+ *
140
+ * Convenience method that wraps `get()` for name-based lookup.
141
+ *
142
+ * @param ctx - Convex query context
143
+ * @param name - The machine-readable name of the content type
144
+ * @param includeDeleted - Whether to include soft-deleted types
145
+ * @returns The content type or null if not found
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * const blogType = await cms.contentTypes.getByName(ctx, "blog_post");
150
+ * if (blogType) {
151
+ * console.log("Fields:", blogType.fields);
152
+ * }
153
+ * ```
154
+ */
155
+ getByName(ctx: ConvexContext, name: string, includeDeleted?: boolean): Promise<ContentType | null>;
156
+ getById(ctx: ConvexContext, id: string, includeDeleted?: boolean): Promise<ContentType | null>;
157
+ exists(ctx: ConvexContext, name: string, includeDeleted?: boolean): Promise<boolean>;
158
+ list(ctx: ConvexContext, args?: ListContentTypesArgs): Promise<PaginationResult<ContentType>>;
159
+ listActive(ctx: ConvexContext, paginationOpts?: PaginationOpts): Promise<PaginationResult<ContentType>>;
160
+ getAll(ctx: ConvexContext, includeInactive?: boolean): Promise<ContentType[]>;
161
+ /**
162
+ * @example
163
+ * ```typescript
164
+ * const count = await cms.contentTypes.count(ctx);
165
+ * console.log(`You have ${count} content types`);
166
+ * ```
167
+ */
168
+ count(ctx: ConvexContext, includeInactive?: boolean): Promise<number>;
169
+ /**
170
+ * Deactivate a content type without deleting it.
171
+ *
172
+ * Deactivated types remain in the database but are filtered out by default
173
+ * when listing content types. Existing content entries remain accessible.
174
+ *
175
+ * @param ctx - Convex mutation context
176
+ * @param id - The content type ID to deactivate
177
+ * @param updatedBy - User ID making the change
178
+ * @returns The updated content type
179
+ *
180
+ * @example
181
+ * ```typescript
182
+ * await cms.contentTypes.deactivate(ctx, contentTypeId, currentUserId);
183
+ * ```
184
+ */
185
+ deactivate(ctx: ConvexContext, id: string, updatedBy?: string): Promise<UpdateContentTypeResult>;
186
+ /**
187
+ * Reactivate a previously deactivated content type.
188
+ *
189
+ * @param ctx - Convex mutation context
190
+ * @param id - The content type ID to reactivate
191
+ * @param updatedBy - User ID making the change
192
+ * @returns The updated content type
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * await cms.contentTypes.reactivate(ctx, contentTypeId, currentUserId);
197
+ * ```
198
+ */
199
+ reactivate(ctx: ConvexContext, id: string, updatedBy?: string): Promise<UpdateContentTypeResult>;
200
+ }
201
+ /** Content entry CRUD and workflow operations */
202
+ export declare class ContentEntriesApi {
203
+ private readonly api;
204
+ private readonly config;
205
+ private readonly authHelper?;
206
+ private readonly rateLimitHelper?;
207
+ constructor(api: TypedComponentApi, config: ResolvedComponentConfig, authHelper?: AuthorizationHelper | undefined, rateLimitHelper?: RateLimitHelper | undefined);
208
+ /** @throws AuthorizationNotConfiguredError if not configured and not in permissiveMode */
209
+ private authorize;
210
+ private rateLimit;
211
+ create(ctx: ConvexContext, args: CreateContentEntryArgs): Promise<ContentEntry>;
212
+ update(ctx: ConvexContext, args: UpdateContentEntryArgs): Promise<ContentEntry>;
213
+ delete(ctx: ConvexContext, args: DeleteContentEntryArgs): Promise<ContentEntry>;
214
+ get(ctx: ConvexContext, args: GetContentEntryArgs): Promise<ContentEntry | null>;
215
+ /** Looks up by contentTypeId+slug or contentTypeName+slug */
216
+ getBySlug(ctx: ConvexContext, args: GetContentEntryBySlugArgs): Promise<ContentEntry | null>;
217
+ /** Standard Convex pagination format compatible with usePaginatedQuery */
218
+ list(ctx: ConvexContext, args: ListContentEntriesArgs): Promise<PaginationResult<ContentEntry>>;
219
+ /**
220
+ * Publish a content entry.
221
+ *
222
+ * @param ctx - Convex mutation context
223
+ * @param args - Publish arguments
224
+ * @returns The published entry
225
+ */
226
+ publish(ctx: ConvexContext, args: PublishEntryArgs): Promise<ContentEntry>;
227
+ /**
228
+ * Unpublish a content entry (revert to draft).
229
+ *
230
+ * @param ctx - Convex mutation context
231
+ * @param args - Unpublish arguments
232
+ * @returns The unpublished entry
233
+ */
234
+ unpublish(ctx: ConvexContext, args: UnpublishEntryArgs): Promise<ContentEntry>;
235
+ /**
236
+ * Schedule a content entry for future publication.
237
+ *
238
+ * @param ctx - Convex mutation context
239
+ * @param args - Schedule arguments
240
+ * @returns The scheduled entry
241
+ *
242
+ * @example
243
+ * ```typescript
244
+ * await cms.contentEntries.schedule(ctx, {
245
+ * id: entryId,
246
+ * publishAt: Date.now() + 24 * 60 * 60 * 1000, // Tomorrow
247
+ * });
248
+ * ```
249
+ */
250
+ schedule(ctx: ConvexContext, args: ScheduleEntryArgs): Promise<ContentEntry>;
251
+ /**
252
+ * Restore a soft-deleted content entry.
253
+ *
254
+ * Removes the deletedAt timestamp from a soft-deleted entry,
255
+ * making it active again. Only works for soft-deleted entries;
256
+ * hard-deleted entries cannot be recovered.
257
+ *
258
+ * @param ctx - Convex mutation context
259
+ * @param args - Restore arguments
260
+ * @returns The restored entry
261
+ *
262
+ * @example
263
+ * ```typescript
264
+ * // Restore a soft-deleted entry
265
+ * const restored = await cms.contentEntries.restore(ctx, {
266
+ * id: entryId,
267
+ * restoredBy: currentUserId,
268
+ * });
269
+ * console.log(restored.deletedAt); // undefined
270
+ * ```
271
+ */
272
+ restore(ctx: ConvexContext, args: RestoreEntryArgs): Promise<ContentEntry>;
273
+ /**
274
+ * Create a fluent query builder for constructing complex content queries.
275
+ *
276
+ * The query builder provides a chainable API for building queries with:
277
+ * - Content type filtering
278
+ * - Status filtering (single or multiple)
279
+ * - Field-level filters with various operators
280
+ * - Full-text search
281
+ * - Locale filtering
282
+ * - Cursor-based pagination
283
+ * - Sort direction
284
+ *
285
+ * @returns A new ContentQueryBuilder instance
286
+ *
287
+ * @example
288
+ * ```typescript
289
+ * // Simple query
290
+ * const posts = await cms.contentEntries
291
+ * .query()
292
+ * .contentType("blog_post")
293
+ * .status("published")
294
+ * .limit(10)
295
+ * .execute(ctx);
296
+ *
297
+ * // Complex query with field filters
298
+ * const featured = await cms.contentEntries
299
+ * .query()
300
+ * .contentType("blog_post")
301
+ * .where("category", "eq", "technology")
302
+ * .whereContains("tags", "featured")
303
+ * .whereGreaterThan("views", 100)
304
+ * .newestFirst()
305
+ * .limit(5)
306
+ * .execute(ctx);
307
+ *
308
+ * // Pagination
309
+ * const page1 = await cms.contentEntries
310
+ * .query()
311
+ * .contentType("blog_post")
312
+ * .limit(20)
313
+ * .execute(ctx);
314
+ *
315
+ * const page2 = await cms.contentEntries
316
+ * .query()
317
+ * .contentType("blog_post")
318
+ * .limit(20)
319
+ * .cursor(page1.continueCursor)
320
+ * .execute(ctx);
321
+ *
322
+ * // Get first result only
323
+ * const latest = await cms.contentEntries
324
+ * .query()
325
+ * .contentType("blog_post")
326
+ * .published()
327
+ * .newestFirst()
328
+ * .first(ctx);
329
+ *
330
+ * // Check if results exist
331
+ * const hasPublished = await cms.contentEntries
332
+ * .query()
333
+ * .contentType("blog_post")
334
+ * .published()
335
+ * .exists(ctx);
336
+ * ```
337
+ */
338
+ query(): ContentQueryBuilder;
339
+ /**
340
+ * Resolve locale content for a single content entry.
341
+ *
342
+ * Takes a content entry with potentially localized field values and resolves
343
+ * all localized fields to single values based on the requested locale and
344
+ * fallback chain. This merges localized and default field values.
345
+ *
346
+ * Resolution order for each localized field:
347
+ * 1. Try the requested locale
348
+ * 2. Try each locale in the fallback chain (in order)
349
+ * 3. Try the default locale
350
+ * 4. Return first available locale as last resort
351
+ *
352
+ * @param entry - The content entry to resolve (with raw localized data)
353
+ * @param options - Locale resolution options
354
+ * @returns The entry with resolved data and metadata about resolution
355
+ *
356
+ * @example
357
+ * ```typescript
358
+ * // Get an entry
359
+ * const entry = await cms.contentEntries.get(ctx, { id: entryId });
360
+ *
361
+ * // Resolve to Spanish with English fallback
362
+ * const resolved = cms.contentEntries.resolveLocale(entry, {
363
+ * locale: "es-ES",
364
+ * fallbackChain: ["en-US"],
365
+ * defaultLocale: "en-US",
366
+ * fields: contentType.fields,
367
+ * });
368
+ *
369
+ * // Access resolved data
370
+ * console.log(resolved.data.title); // "Hola" (Spanish) or "Hello" (English fallback)
371
+ *
372
+ * // Check which fields used fallback
373
+ * if (resolved.localeResolution.fieldsFromFallback.includes("title")) {
374
+ * console.log("Title was not translated to Spanish");
375
+ * }
376
+ *
377
+ * // See which locale each field was resolved from
378
+ * console.log(resolved.localeResolution.fieldResolutions);
379
+ * // { content: "en-US" } - content was resolved from English
380
+ * ```
381
+ */
382
+ resolveLocale<T extends ContentEntry>(entry: T, options: ResolveLocaleContentOptions): T & LocaleResolvedEntry;
383
+ /**
384
+ * Resolve locale content for multiple content entries.
385
+ *
386
+ * Convenience method for batch-resolving a list of entries.
387
+ * Useful after fetching a paginated list of content entries.
388
+ *
389
+ * @param entries - Array of content entries to resolve
390
+ * @param options - Locale resolution options (applied to all entries)
391
+ * @returns Array of entries with resolved locale data
392
+ *
393
+ * @example
394
+ * ```typescript
395
+ * // Fetch published blog posts
396
+ * const { page } = await cms.contentEntries.list(ctx, {
397
+ * contentTypeName: "blog_post",
398
+ * status: "published",
399
+ * paginationOpts: { numItems: 10 },
400
+ * });
401
+ *
402
+ * // Resolve all entries to Spanish
403
+ * const resolvedPosts = cms.contentEntries.resolveLocaleBatch(page, {
404
+ * locale: "es-ES",
405
+ * fallbackChain: cms.getLocaleFallbackChain("es-ES"),
406
+ * defaultLocale: cms.config.defaultLocale,
407
+ * fields: blogPostType.fields,
408
+ * });
409
+ *
410
+ * // Use resolved data
411
+ * for (const post of resolvedPosts) {
412
+ * console.log(post.data.title); // Resolved title in Spanish or fallback
413
+ * }
414
+ * ```
415
+ */
416
+ resolveLocaleBatch<T extends ContentEntry>(entries: T[], options: ResolveLocaleContentOptions): Array<T & LocaleResolvedEntry>;
417
+ /**
418
+ * List content entries with automatic locale resolution.
419
+ *
420
+ * This is a convenience method that combines `list()` and `resolveLocaleBatch()`
421
+ * into a single call. It fetches content entries and automatically resolves
422
+ * all localized fields to the requested locale with fallback support.
423
+ *
424
+ * Note: This method requires the content type's field definitions to properly
425
+ * resolve localized fields. You can either pass them explicitly or let the
426
+ * method fetch them automatically (requires an extra query).
427
+ *
428
+ * @param ctx - Convex query context
429
+ * @param args - Query options with pagination
430
+ * @param localeOptions - Locale resolution options
431
+ * @returns Paginated result with locale-resolved entries
432
+ *
433
+ * @example
434
+ * ```typescript
435
+ * // List with locale resolution
436
+ * const { page, continueCursor, isDone } = await cms.contentEntries.listWithLocale(
437
+ * ctx,
438
+ * {
439
+ * contentTypeName: "blog_post",
440
+ * status: "published",
441
+ * paginationOpts: { numItems: 10 },
442
+ * },
443
+ * {
444
+ * locale: "es-ES",
445
+ * fields: blogPostType.fields, // Required for resolution
446
+ * }
447
+ * );
448
+ *
449
+ * // All entries have resolved locale data
450
+ * for (const post of page) {
451
+ * console.log(post.data.title); // Resolved title
452
+ * console.log(post.localeResolution.fieldsFromFallback); // Which fields used fallback
453
+ * }
454
+ * ```
455
+ */
456
+ listWithLocale(ctx: ConvexContext, args: ListContentEntriesArgs, localeOptions: ResolveLocaleContentOptions): Promise<PaginationResult<ContentEntry & LocaleResolvedEntry>>;
457
+ /**
458
+ * Get a content entry by ID with automatic locale resolution.
459
+ *
460
+ * Fetches the entry and resolves all localized fields to the requested locale.
461
+ *
462
+ * @param ctx - Convex query context
463
+ * @param args - Get arguments
464
+ * @param localeOptions - Locale resolution options
465
+ * @returns The entry with resolved locale data, or null if not found
466
+ *
467
+ * @example
468
+ * ```typescript
469
+ * const post = await cms.contentEntries.getWithLocale(
470
+ * ctx,
471
+ * { id: entryId },
472
+ * {
473
+ * locale: "es-ES",
474
+ * fallbackChain: ["en-US"],
475
+ * defaultLocale: "en-US",
476
+ * fields: blogPostType.fields,
477
+ * }
478
+ * );
479
+ *
480
+ * if (post) {
481
+ * console.log(post.data.title); // Resolved title
482
+ * }
483
+ * ```
484
+ */
485
+ getWithLocale(ctx: ConvexContext, args: GetContentEntryArgs, localeOptions: ResolveLocaleContentOptions): Promise<(ContentEntry & LocaleResolvedEntry) | null>;
486
+ /**
487
+ * Get a content entry by slug with automatic locale resolution.
488
+ *
489
+ * Fetches the entry by slug and resolves all localized fields to the requested locale.
490
+ *
491
+ * @param ctx - Convex query context
492
+ * @param args - Get by slug arguments
493
+ * @param localeOptions - Locale resolution options
494
+ * @returns The entry with resolved locale data, or null if not found
495
+ *
496
+ * @example
497
+ * ```typescript
498
+ * const post = await cms.contentEntries.getBySlugWithLocale(
499
+ * ctx,
500
+ * {
501
+ * contentTypeName: "blog_post",
502
+ * slug: "hello-world",
503
+ * },
504
+ * {
505
+ * locale: "es-ES",
506
+ * fields: blogPostType.fields,
507
+ * }
508
+ * );
509
+ * ```
510
+ */
511
+ getBySlugWithLocale(ctx: ConvexContext, args: GetContentEntryBySlugArgs, localeOptions: ResolveLocaleContentOptions): Promise<(ContentEntry & LocaleResolvedEntry) | null>;
512
+ /**
513
+ * Duplicate a content entry.
514
+ *
515
+ * Creates a copy of an existing content entry with a new unique slug.
516
+ * The duplicate always starts as a draft, regardless of the source entry's status.
517
+ * Media references are copied by default but can be cleared.
518
+ *
519
+ * @param ctx - Convex mutation context
520
+ * @param args - Duplicate arguments
521
+ * @returns The duplicated entry
522
+ *
523
+ * @example
524
+ * ```typescript
525
+ * // Simple duplication with auto-generated slug
526
+ * const copy = await cms.contentEntries.duplicate(ctx, {
527
+ * sourceEntryId: originalPost._id,
528
+ * createdBy: currentUserId,
529
+ * });
530
+ *
531
+ * // Duplicate with custom slug
532
+ * const copy = await cms.contentEntries.duplicate(ctx, {
533
+ * sourceEntryId: templateId,
534
+ * slug: "new-post-from-template",
535
+ * createdBy: currentUserId,
536
+ * });
537
+ *
538
+ * // Duplicate without media references (for a fresh start)
539
+ * const copy = await cms.contentEntries.duplicate(ctx, {
540
+ * sourceEntryId: originalPost._id,
541
+ * copyMediaReferences: false,
542
+ * createdBy: currentUserId,
543
+ * });
544
+ * ```
545
+ */
546
+ duplicate(ctx: ConvexContext, args: DuplicateEntryArgs): Promise<ContentEntry>;
547
+ /**
548
+ * Publish multiple content entries in a single transaction.
549
+ *
550
+ * This is more efficient than publishing entries one by one. Each entry that
551
+ * is already published will be skipped (idempotent behavior). Deleted or
552
+ * archived entries will fail with an error message.
553
+ *
554
+ * @param ctx - Convex mutation context
555
+ * @param args - Bulk publish arguments
556
+ * @returns Bulk operation result with success/failure details for each entry
557
+ *
558
+ * @example
559
+ * ```typescript
560
+ * const result = await cms.contentEntries.bulkPublish(ctx, {
561
+ * ids: [entry1._id, entry2._id, entry3._id],
562
+ * changeDescription: "Publishing launch content",
563
+ * updatedBy: currentUserId,
564
+ * });
565
+ * console.log(`Published ${result.succeeded} of ${result.total} entries`);
566
+ * if (result.failed > 0) {
567
+ * result.results.filter(r => !r.success).forEach(r => {
568
+ * console.error(`Failed to publish ${r.id}: ${r.error}`);
569
+ * });
570
+ * }
571
+ * ```
572
+ */
573
+ bulkPublish(ctx: ConvexContext, args: BulkPublishArgs): Promise<BulkOperationResult>;
574
+ /**
575
+ * Unpublish multiple content entries in a single transaction.
576
+ *
577
+ * Reverts published entries to draft status. Non-published entries are
578
+ * skipped (idempotent behavior).
579
+ *
580
+ * @param ctx - Convex mutation context
581
+ * @param args - Bulk unpublish arguments
582
+ * @returns Bulk operation result with success/failure details for each entry
583
+ *
584
+ * @example
585
+ * ```typescript
586
+ * const result = await cms.contentEntries.bulkUnpublish(ctx, {
587
+ * ids: [entry1._id, entry2._id],
588
+ * updatedBy: currentUserId,
589
+ * });
590
+ * ```
591
+ */
592
+ bulkUnpublish(ctx: ConvexContext, args: BulkUnpublishArgs): Promise<BulkOperationResult>;
593
+ /**
594
+ * Delete multiple content entries in a single transaction.
595
+ *
596
+ * By default, performs soft delete (entries can be restored later).
597
+ * When hardDelete is true, permanently removes entries and all their versions.
598
+ *
599
+ * @param ctx - Convex mutation context
600
+ * @param args - Bulk delete arguments
601
+ * @returns Bulk operation result with success/failure details for each entry
602
+ *
603
+ * @example
604
+ * ```typescript
605
+ * // Soft delete (default)
606
+ * const result = await cms.contentEntries.bulkDelete(ctx, {
607
+ * ids: [entry1._id, entry2._id],
608
+ * deletedBy: currentUserId,
609
+ * });
610
+ *
611
+ * // Hard delete (permanent)
612
+ * const result = await cms.contentEntries.bulkDelete(ctx, {
613
+ * ids: [entry1._id, entry2._id],
614
+ * deletedBy: currentUserId,
615
+ * hardDelete: true,
616
+ * });
617
+ * ```
618
+ */
619
+ bulkDelete(ctx: ConvexContext, args: BulkDeleteArgs): Promise<BulkOperationResult>;
620
+ /**
621
+ * Update multiple content entries with the same changes in a single transaction.
622
+ *
623
+ * Applies the same data updates and/or status change to all specified entries.
624
+ * Data is merged with existing data for each entry (partial updates).
625
+ * Each entry is validated against its content type schema.
626
+ *
627
+ * @param ctx - Convex mutation context
628
+ * @param args - Bulk update arguments
629
+ * @returns Bulk operation result with success/failure details for each entry
630
+ *
631
+ * @example
632
+ * ```typescript
633
+ * // Update data for multiple entries
634
+ * const result = await cms.contentEntries.bulkUpdate(ctx, {
635
+ * ids: [entry1._id, entry2._id, entry3._id],
636
+ * data: { featured: true, category: "news" },
637
+ * updatedBy: currentUserId,
638
+ * });
639
+ *
640
+ * // Change status for multiple entries
641
+ * const result = await cms.contentEntries.bulkUpdate(ctx, {
642
+ * ids: [entry1._id, entry2._id],
643
+ * status: "archived",
644
+ * updatedBy: currentUserId,
645
+ * });
646
+ * ```
647
+ */
648
+ bulkUpdate(ctx: ConvexContext, args: BulkUpdateArgs): Promise<BulkOperationResult>;
649
+ /**
650
+ * Restore multiple soft-deleted content entries in a single transaction.
651
+ *
652
+ * Removes the deletedAt marker from entries, making them active again.
653
+ * Only works for soft-deleted entries. Non-deleted entries are skipped
654
+ * (idempotent behavior).
655
+ *
656
+ * @param ctx - Convex mutation context
657
+ * @param args - Bulk restore arguments
658
+ * @returns Bulk operation result with success/failure details for each entry
659
+ *
660
+ * @example
661
+ * ```typescript
662
+ * const result = await cms.contentEntries.bulkRestore(ctx, {
663
+ * ids: [deletedEntry1._id, deletedEntry2._id],
664
+ * restoredBy: currentUserId,
665
+ * });
666
+ * ```
667
+ */
668
+ bulkRestore(ctx: ConvexContext, args: BulkRestoreArgs): Promise<BulkOperationResult>;
669
+ }
670
+ /**
671
+ * Wrapper for content version operations.
672
+ *
673
+ * Provides comprehensive version management including:
674
+ * - Version history retrieval with pagination
675
+ * - Getting specific versions by ID or number
676
+ * - Version comparison and diff generation
677
+ * - Rollback functionality
678
+ * - Finding latest and published versions
679
+ *
680
+ * @example
681
+ * ```typescript
682
+ * // Get version history for an entry
683
+ * const history = await cms.versions.getHistory(ctx, {
684
+ * entryId: entry._id,
685
+ * paginationOpts: { numItems: 10 },
686
+ * });
687
+ *
688
+ * // Compare two versions
689
+ * const diff = await cms.versions.compare(ctx, {
690
+ * entryId: entry._id,
691
+ * fromVersionNumber: 1,
692
+ * toVersionNumber: 5,
693
+ * });
694
+ *
695
+ * // Rollback to a previous version
696
+ * await cms.versions.rollback(ctx, {
697
+ * entryId: entry._id,
698
+ * versionNumber: 3,
699
+ * });
700
+ * ```
701
+ */
702
+ export declare class VersionsApi {
703
+ private readonly api;
704
+ private readonly config;
705
+ private readonly authHelper?;
706
+ private readonly rateLimitHelper?;
707
+ constructor(api: TypedComponentApi, config: ResolvedComponentConfig, authHelper?: AuthorizationHelper | undefined, rateLimitHelper?: RateLimitHelper | undefined);
708
+ /**
709
+ * Check if versioning feature is enabled.
710
+ * @throws Error if versioning is not enabled
711
+ */
712
+ private ensureVersioningEnabled;
713
+ /**
714
+ * Perform authorization check for version operations.
715
+ * @param ctx - The Convex context (passed to authorization hooks for database access)
716
+ * @param operation - The CMS operation being performed
717
+ * @param userId - The user performing the operation
718
+ * @param resourceId - Optional resource ID (entry ID for version operations)
719
+ * @throws AuthorizationNotConfiguredError if authorization is not configured and permissiveMode is false
720
+ */
721
+ private authorize;
722
+ /**
723
+ * Enforce rate limit for version operations.
724
+ * @param ctx - The Convex context (for database access)
725
+ * @param operation - The CMS operation being performed
726
+ * @param userId - The user performing the operation
727
+ */
728
+ private rateLimit;
729
+ /**
730
+ * Get version history with standard Convex pagination.
731
+ *
732
+ * Returns versions in reverse chronological order (newest first).
733
+ * Compatible with `usePaginatedQuery` React hook.
734
+ *
735
+ * @param ctx - Convex query context
736
+ * @param args - History query arguments with pagination
737
+ * @returns Paginated version history or null if entry not found
738
+ *
739
+ * @example
740
+ * ```typescript
741
+ * // Get first page of version history
742
+ * const { page, continueCursor, isDone } = await cms.versions.getHistory(ctx, {
743
+ * entryId: entry._id,
744
+ * paginationOpts: { numItems: 10 },
745
+ * });
746
+ *
747
+ * // Get next page
748
+ * if (!isDone && continueCursor) {
749
+ * const nextPage = await cms.versions.getHistory(ctx, {
750
+ * entryId: entry._id,
751
+ * paginationOpts: { numItems: 10, cursor: continueCursor },
752
+ * });
753
+ * }
754
+ * ```
755
+ */
756
+ getHistory(ctx: ConvexContext, args: GetVersionHistoryArgs): Promise<PaginationResult<ContentVersion> | null>;
757
+ /**
758
+ * Get a specific version by ID or version number.
759
+ *
760
+ * @param ctx - Convex query context
761
+ * @param args - Get arguments (entryId required, plus versionId or versionNumber)
762
+ * @returns The version or null if not found
763
+ *
764
+ * @example
765
+ * ```typescript
766
+ * // Get by version number
767
+ * const version = await cms.versions.get(ctx, {
768
+ * entryId: entry._id,
769
+ * versionNumber: 3,
770
+ * });
771
+ *
772
+ * // Get by version ID
773
+ * const version = await cms.versions.get(ctx, {
774
+ * entryId: entry._id,
775
+ * versionId: "abc123",
776
+ * });
777
+ * ```
778
+ */
779
+ get(ctx: ConvexContext, args: GetVersionArgs): Promise<ContentVersion | null>;
780
+ /**
781
+ * Get a version by its version number (convenience method).
782
+ *
783
+ * @param ctx - Convex query context
784
+ * @param entryId - The content entry ID
785
+ * @param versionNumber - The version number to retrieve
786
+ * @returns The version or null if not found
787
+ *
788
+ * @example
789
+ * ```typescript
790
+ * const version3 = await cms.versions.getByNumber(ctx, entry._id, 3);
791
+ * ```
792
+ */
793
+ getByNumber(ctx: ConvexContext, entryId: string, versionNumber: number): Promise<ContentVersion | null>;
794
+ /**
795
+ * Get a version by its document ID (convenience method).
796
+ *
797
+ * @param ctx - Convex query context
798
+ * @param entryId - The content entry ID
799
+ * @param versionId - The version document ID
800
+ * @returns The version or null if not found
801
+ *
802
+ * @example
803
+ * ```typescript
804
+ * const version = await cms.versions.getById(ctx, entry._id, versionDocId);
805
+ * ```
806
+ */
807
+ getById(ctx: ConvexContext, entryId: string, versionId: string): Promise<ContentVersion | null>;
808
+ /**
809
+ * Get the latest (most recent) version snapshot for an entry.
810
+ *
811
+ * @param ctx - Convex query context
812
+ * @param entryId - The content entry ID
813
+ * @returns The latest version or null if no versions exist
814
+ *
815
+ * @example
816
+ * ```typescript
817
+ * const latest = await cms.versions.getLatest(ctx, entry._id);
818
+ * console.log(`Current version: ${latest?.versionNumber}`);
819
+ * ```
820
+ */
821
+ getLatest(ctx: ConvexContext, entryId: string): Promise<ContentVersion | null>;
822
+ /**
823
+ * Get the latest published version for an entry.
824
+ *
825
+ * Searches through version history to find the most recent version
826
+ * that was published (wasPublished = true).
827
+ *
828
+ * @param ctx - Convex query context
829
+ * @param entryId - The content entry ID
830
+ * @returns The latest published version or null if none published
831
+ *
832
+ * @example
833
+ * ```typescript
834
+ * const published = await cms.versions.getLatestPublished(ctx, entry._id);
835
+ * if (published) {
836
+ * console.log(`Published at: ${new Date(published.publishedAt!)}`);
837
+ * }
838
+ * ```
839
+ */
840
+ getLatestPublished(ctx: ConvexContext, entryId: string): Promise<ContentVersion | null>;
841
+ /**
842
+ * Get all published versions for an entry.
843
+ *
844
+ * @param ctx - Convex query context
845
+ * @param entryId - The content entry ID
846
+ * @param limit - Maximum number of published versions to return (default: 10)
847
+ * @returns Array of published versions (newest first)
848
+ *
849
+ * @example
850
+ * ```typescript
851
+ * const publishedVersions = await cms.versions.getPublishedHistory(ctx, entry._id, 5);
852
+ * console.log(`Found ${publishedVersions.length} published versions`);
853
+ * ```
854
+ */
855
+ getPublishedHistory(ctx: ConvexContext, entryId: string, limit?: number): Promise<ContentVersion[]>;
856
+ /**
857
+ * Compare two versions and generate a detailed diff.
858
+ *
859
+ * Analyzes field-level changes between two versions, identifying:
860
+ * - Added fields (present in toVersion but not fromVersion)
861
+ * - Removed fields (present in fromVersion but not toVersion)
862
+ * - Modified fields (present in both but with different values)
863
+ *
864
+ * @param ctx - Convex query context
865
+ * @param args - Comparison arguments
866
+ * @returns Detailed version comparison or null if versions not found
867
+ *
868
+ * @example
869
+ * ```typescript
870
+ * const diff = await cms.versions.compare(ctx, {
871
+ * entryId: entry._id,
872
+ * fromVersionNumber: 1,
873
+ * toVersionNumber: 5,
874
+ * });
875
+ *
876
+ * if (diff) {
877
+ * console.log(`${diff.summary.totalChanges} changes detected`);
878
+ * for (const change of diff.changes) {
879
+ * console.log(`${change.field}: ${change.changeType}`);
880
+ * }
881
+ * }
882
+ * ```
883
+ */
884
+ compare(ctx: ConvexContext, args: CompareVersionsArgs): Promise<VersionComparison | null>;
885
+ /**
886
+ * Compare the current entry state with a specific version.
887
+ *
888
+ * Useful for seeing what has changed since a particular point in time.
889
+ *
890
+ * @param ctx - Convex query context
891
+ * @param entryId - The content entry ID
892
+ * @param versionNumber - The version number to compare against
893
+ * @returns Comparison between the version and current state, or null
894
+ *
895
+ * @example
896
+ * ```typescript
897
+ * // See what changed since version 3
898
+ * const diff = await cms.versions.compareWithCurrent(ctx, entry._id, 3);
899
+ * ```
900
+ */
901
+ compareWithCurrent(ctx: ConvexContext, entryId: string, versionNumber: number): Promise<VersionComparison | null>;
902
+ /**
903
+ * Check if a specific version exists.
904
+ *
905
+ * @param ctx - Convex query context
906
+ * @param entryId - The content entry ID
907
+ * @param versionNumber - The version number to check
908
+ * @returns true if the version exists
909
+ *
910
+ * @example
911
+ * ```typescript
912
+ * if (await cms.versions.exists(ctx, entry._id, 5)) {
913
+ * // Version 5 exists
914
+ * }
915
+ * ```
916
+ */
917
+ exists(ctx: ConvexContext, entryId: string, versionNumber: number): Promise<boolean>;
918
+ /**
919
+ * Count total number of versions for an entry.
920
+ *
921
+ * @param ctx - Convex query context
922
+ * @param entryId - The content entry ID
923
+ * @returns Total number of version snapshots
924
+ *
925
+ * @example
926
+ * ```typescript
927
+ * const count = await cms.versions.count(ctx, entry._id);
928
+ * console.log(`Entry has ${count} versions`);
929
+ * ```
930
+ */
931
+ count(ctx: ConvexContext, entryId: string): Promise<number>;
932
+ /**
933
+ * Rollback a content entry to a previous version.
934
+ *
935
+ * This is a non-destructive operation that:
936
+ * 1. Creates a snapshot of the current state (for undo capability)
937
+ * 2. Restores data and slug from the target version
938
+ * 3. Increments the version number
939
+ * 4. Creates a new snapshot documenting the rollback
940
+ *
941
+ * The entry's status, scheduled publish time, and publishing timestamps
942
+ * are preserved (not restored from the target version).
943
+ *
944
+ * @param ctx - Convex mutation context
945
+ * @param args - Rollback arguments
946
+ * @returns The updated entry with rolled back content
947
+ *
948
+ * @example
949
+ * ```typescript
950
+ * // Rollback to version 3
951
+ * const entry = await cms.versions.rollback(ctx, {
952
+ * entryId: entry._id,
953
+ * versionNumber: 3,
954
+ * updatedBy: currentUserId,
955
+ * });
956
+ *
957
+ * // The entry is now at a new version number (e.g., 7)
958
+ * // but with content from version 3
959
+ * console.log(`Rolled back, now at version ${entry.version}`);
960
+ * ```
961
+ */
962
+ rollback(ctx: ConvexContext, args: RollbackVersionArgs): Promise<ContentEntry>;
963
+ /**
964
+ * Generate a detailed comparison between two versions.
965
+ */
966
+ private generateComparison;
967
+ /**
968
+ * Deep equality check for comparing field values.
969
+ */
970
+ private deepEqual;
971
+ }
972
+ /**
973
+ * Wrapper for media asset operations.
974
+ */
975
+ export declare class MediaAssetsApi {
976
+ private readonly api;
977
+ private readonly config;
978
+ private readonly authHelper?;
979
+ private readonly rateLimitHelper?;
980
+ constructor(api: TypedComponentApi, config: ResolvedComponentConfig, authHelper?: AuthorizationHelper | undefined, rateLimitHelper?: RateLimitHelper | undefined);
981
+ /**
982
+ * Perform authorization check for media asset operations.
983
+ * @param ctx - The Convex context (passed to authorization hooks for database access)
984
+ * @param operation - The CMS operation being performed
985
+ * @param userId - The user performing the operation
986
+ * @param resourceId - Optional resource ID (for update/delete operations)
987
+ * @param resourceOwnerId - Optional owner ID for ownership-based permissions
988
+ * @throws AuthorizationNotConfiguredError if authorization is not configured and permissiveMode is false
989
+ */
990
+ private authorize;
991
+ /**
992
+ * Enforce rate limit for media asset operations.
993
+ * @param ctx - The Convex context (for database access)
994
+ * @param operation - The CMS operation being performed
995
+ * @param userId - The user performing the operation
996
+ */
997
+ private rateLimit;
998
+ /**
999
+ * Create a new media asset record.
1000
+ *
1001
+ * @param ctx - Convex mutation context
1002
+ * @param args - Asset creation arguments
1003
+ * @returns The created asset
1004
+ *
1005
+ * @example
1006
+ * ```typescript
1007
+ * // After uploading to Convex storage
1008
+ * const asset = await cms.mediaAssets.create(ctx, {
1009
+ * storageId: storageId,
1010
+ * filename: "photo.jpg",
1011
+ * mimeType: "image/jpeg",
1012
+ * size: 102400,
1013
+ * type: "image",
1014
+ * width: 1920,
1015
+ * height: 1080,
1016
+ * });
1017
+ * ```
1018
+ */
1019
+ create(ctx: ConvexContext, args: CreateMediaAssetArgs): Promise<MediaAsset>;
1020
+ /**
1021
+ * Update media asset metadata.
1022
+ *
1023
+ * @param ctx - Convex mutation context
1024
+ * @param args - Asset update arguments
1025
+ * @returns The updated asset
1026
+ */
1027
+ update(ctx: ConvexContext, args: UpdateMediaAssetArgs): Promise<MediaAsset>;
1028
+ /**
1029
+ * Soft delete a media asset.
1030
+ *
1031
+ * @param ctx - Convex mutation context
1032
+ * @param args - Delete arguments
1033
+ * @returns The deleted asset
1034
+ */
1035
+ delete(ctx: ConvexContext, args: DeleteMediaAssetArgs): Promise<MediaAsset>;
1036
+ /**
1037
+ * Get a media asset by ID.
1038
+ *
1039
+ * @param ctx - Convex query context
1040
+ * @param args - Get arguments
1041
+ * @returns The asset or null if not found
1042
+ */
1043
+ get(ctx: ConvexContext, args: GetMediaAssetArgs): Promise<MediaAsset | null>;
1044
+ /**
1045
+ * List media assets with optional filters.
1046
+ *
1047
+ * @param ctx - Convex query context
1048
+ * @param args - Query options
1049
+ * @returns Paginated list of assets
1050
+ */
1051
+ list(ctx: ConvexContext, args?: ListMediaAssetsArgs): Promise<PaginationResult<MediaAsset>>;
1052
+ /**
1053
+ * Generate a temporary upload URL for client-side file uploads.
1054
+ *
1055
+ * The upload flow works as follows:
1056
+ * 1. Call this method to get a temporary upload URL
1057
+ * 2. POST the file to the URL with Content-Type header set to the file's MIME type
1058
+ * 3. The response contains a `storageId` that references the uploaded file
1059
+ * 4. Call create() to save metadata and link the storageId
1060
+ *
1061
+ * @param ctx - Convex mutation context
1062
+ * @param args - Upload configuration options
1063
+ * @returns Upload URL and constraints
1064
+ *
1065
+ * @example
1066
+ * ```typescript
1067
+ * // Generate URL for image uploads
1068
+ * const { uploadUrl, expiresAt, maxFileSize } = await cms.mediaAssets.generateUploadUrl(ctx, {
1069
+ * maxFileSize: 10 * 1024 * 1024, // 10 MB
1070
+ * allowedMimeTypes: ["image/jpeg", "image/png", "image/webp"],
1071
+ * });
1072
+ *
1073
+ * // Client-side upload:
1074
+ * const response = await fetch(uploadUrl, {
1075
+ * method: "POST",
1076
+ * headers: { "Content-Type": file.type },
1077
+ * body: file,
1078
+ * });
1079
+ * const { storageId } = await response.json();
1080
+ *
1081
+ * // Then save metadata
1082
+ * const asset = await cms.mediaAssets.create(ctx, {
1083
+ * storageId,
1084
+ * filename: file.name,
1085
+ * mimeType: file.type,
1086
+ * size: file.size,
1087
+ * type: "image",
1088
+ * });
1089
+ * ```
1090
+ */
1091
+ generateUploadUrl(ctx: ConvexContext, args?: GenerateUploadUrlArgs): Promise<GenerateUploadUrlResult>;
1092
+ /**
1093
+ * Restore a soft-deleted media asset.
1094
+ *
1095
+ * @param ctx - Convex mutation context
1096
+ * @param args - Restore arguments
1097
+ * @returns The restored asset
1098
+ *
1099
+ * @example
1100
+ * ```typescript
1101
+ * // Restore a previously deleted asset
1102
+ * const restoredAsset = await cms.mediaAssets.restore(ctx, {
1103
+ * id: assetId,
1104
+ * });
1105
+ * ```
1106
+ */
1107
+ restore(ctx: ConvexContext, args: RestoreMediaAssetArgs): Promise<MediaAsset>;
1108
+ /**
1109
+ * Find content entries that reference a media asset.
1110
+ *
1111
+ * Useful for checking references before deletion or for understanding asset usage.
1112
+ *
1113
+ * @param ctx - Convex query context
1114
+ * @param args - Query arguments
1115
+ * @returns Array of references with entry and field information
1116
+ *
1117
+ * @example
1118
+ * ```typescript
1119
+ * // Check if asset is used before deleting
1120
+ * const references = await cms.mediaAssets.findReferences(ctx, {
1121
+ * id: assetId,
1122
+ * });
1123
+ *
1124
+ * if (references.length > 0) {
1125
+ * console.log(`Asset is used in ${references.length} entries`);
1126
+ * // Maybe show a warning to the user
1127
+ * }
1128
+ * ```
1129
+ */
1130
+ findReferences(ctx: ConvexContext, args: FindMediaAssetReferencesArgs): Promise<MediaAssetReference[]>;
1131
+ /**
1132
+ * Get taxonomy terms associated with a media asset.
1133
+ *
1134
+ * @param ctx - Convex query context
1135
+ * @param args - Query arguments
1136
+ * @returns Array of terms associated with the media asset
1137
+ *
1138
+ * @example
1139
+ * ```typescript
1140
+ * const tags = await cms.mediaAssets.getTerms(ctx, {
1141
+ * mediaId: imageId,
1142
+ * });
1143
+ * ```
1144
+ */
1145
+ getTerms(ctx: ConvexContext, args: {
1146
+ mediaId: string;
1147
+ taxonomyId?: string;
1148
+ }): Promise<unknown[]>;
1149
+ /**
1150
+ * Set terms for a media asset in a taxonomy (replaces existing terms).
1151
+ *
1152
+ * @param ctx - Convex mutation context
1153
+ * @param args - Mutation arguments
1154
+ *
1155
+ * @example
1156
+ * ```typescript
1157
+ * await cms.mediaAssets.setTerms(ctx, {
1158
+ * mediaId: imageId,
1159
+ * taxonomyId: categoriesTaxonomyId,
1160
+ * termIds: [landscapeId, natureId],
1161
+ * userId: currentUserId,
1162
+ * });
1163
+ * ```
1164
+ */
1165
+ setTerms(ctx: ConvexContext, args: {
1166
+ mediaId: string;
1167
+ taxonomyId: string;
1168
+ termIds: string[];
1169
+ userId?: string;
1170
+ }): Promise<void>;
1171
+ /**
1172
+ * Add a single term to a media asset.
1173
+ *
1174
+ * @param ctx - Convex mutation context
1175
+ * @param args - Mutation arguments
1176
+ *
1177
+ * @example
1178
+ * ```typescript
1179
+ * await cms.mediaAssets.addTerm(ctx, {
1180
+ * mediaId: imageId,
1181
+ * termId: landscapeId,
1182
+ * userId: currentUserId,
1183
+ * });
1184
+ * ```
1185
+ */
1186
+ addTerm(ctx: ConvexContext, args: {
1187
+ mediaId: string;
1188
+ termId: string;
1189
+ userId?: string;
1190
+ }): Promise<void>;
1191
+ /**
1192
+ * Remove a term from a media asset.
1193
+ *
1194
+ * @param ctx - Convex mutation context
1195
+ * @param args - Mutation arguments
1196
+ *
1197
+ * @example
1198
+ * ```typescript
1199
+ * await cms.mediaAssets.removeTerm(ctx, {
1200
+ * mediaId: imageId,
1201
+ * termId: landscapeId,
1202
+ * userId: currentUserId,
1203
+ * });
1204
+ * ```
1205
+ */
1206
+ removeTerm(ctx: ConvexContext, args: {
1207
+ mediaId: string;
1208
+ termId: string;
1209
+ userId?: string;
1210
+ }): Promise<void>;
1211
+ /**
1212
+ * Create a term inline and add it to a media asset.
1213
+ *
1214
+ * @param ctx - Convex mutation context
1215
+ * @param args - Mutation arguments
1216
+ * @returns The created or existing term ID
1217
+ *
1218
+ * @example
1219
+ * ```typescript
1220
+ * const termId = await cms.mediaAssets.createAndAddTerm(ctx, {
1221
+ * taxonomyId: tagsTaxonomyId,
1222
+ * name: "Nature",
1223
+ * mediaId: imageId,
1224
+ * userId: currentUserId,
1225
+ * });
1226
+ * ```
1227
+ */
1228
+ createAndAddTerm(ctx: ConvexContext, args: {
1229
+ taxonomyId: string;
1230
+ name: string;
1231
+ mediaId: string;
1232
+ userId?: string;
1233
+ }): Promise<string>;
1234
+ }
1235
+ /**
1236
+ * Wrapper for media folder operations.
1237
+ */
1238
+ export declare class MediaFoldersApi {
1239
+ private readonly api;
1240
+ private readonly config;
1241
+ private readonly authHelper?;
1242
+ private readonly rateLimitHelper?;
1243
+ constructor(api: TypedComponentApi, config: ResolvedComponentConfig, authHelper?: AuthorizationHelper | undefined, rateLimitHelper?: RateLimitHelper | undefined);
1244
+ /**
1245
+ * Perform authorization check for media folder operations.
1246
+ * @param ctx - The Convex context (passed to authorization hooks for database access)
1247
+ * @param operation - The CMS operation being performed
1248
+ * @param userId - The user performing the operation
1249
+ * @param resourceId - Optional resource ID (for update/delete operations)
1250
+ * @param resourceOwnerId - Optional owner ID for ownership-based permissions
1251
+ */
1252
+ private authorize;
1253
+ /**
1254
+ * Enforce rate limit for media folder operations.
1255
+ * @param ctx - The Convex context (for database access)
1256
+ * @param operation - The CMS operation being performed
1257
+ * @param userId - The user performing the operation
1258
+ */
1259
+ private rateLimit;
1260
+ /**
1261
+ * Create a new media folder.
1262
+ *
1263
+ * @param ctx - Convex mutation context
1264
+ * @param args - Folder creation arguments
1265
+ * @returns The created folder
1266
+ */
1267
+ create(ctx: ConvexContext, args: CreateMediaFolderArgs): Promise<MediaFolder>;
1268
+ /**
1269
+ * Update a media folder.
1270
+ *
1271
+ * @param ctx - Convex mutation context
1272
+ * @param args - Folder update arguments
1273
+ * @returns The updated folder
1274
+ */
1275
+ update(ctx: ConvexContext, args: UpdateMediaFolderArgs): Promise<MediaFolder>;
1276
+ /**
1277
+ * Soft delete a media folder.
1278
+ *
1279
+ * @param ctx - Convex mutation context
1280
+ * @param args - Delete arguments
1281
+ * @returns The deleted folder
1282
+ */
1283
+ delete(ctx: ConvexContext, args: DeleteMediaFolderArgs): Promise<MediaFolder>;
1284
+ /**
1285
+ * Get a media folder by ID.
1286
+ *
1287
+ * @param ctx - Convex query context
1288
+ * @param args - Get arguments
1289
+ * @returns The folder or null if not found
1290
+ */
1291
+ get(ctx: ConvexContext, args: GetMediaFolderArgs): Promise<MediaFolder | null>;
1292
+ /**
1293
+ * List media folders.
1294
+ *
1295
+ * @param ctx - Convex query context
1296
+ * @param args - Optional filter arguments
1297
+ * @returns Array of folders
1298
+ */
1299
+ list(ctx: ConvexContext, args?: ListMediaFoldersArgs): Promise<MediaFolder[]>;
1300
+ /**
1301
+ * Move a folder to a new parent.
1302
+ *
1303
+ * @param ctx - Convex mutation context
1304
+ * @param args - Move arguments
1305
+ * @returns The moved folder with updated path
1306
+ */
1307
+ move(ctx: ConvexContext, args: MoveFolderArgs): Promise<MediaFolder>;
1308
+ /**
1309
+ * Restore a soft-deleted media folder.
1310
+ *
1311
+ * @param ctx - Convex mutation context
1312
+ * @param args - Restore arguments
1313
+ * @returns The restored folder
1314
+ *
1315
+ * @example
1316
+ * ```typescript
1317
+ * // Restore a folder and all its contents
1318
+ * const restoredFolder = await cms.mediaFolders.restore(ctx, {
1319
+ * id: folderId,
1320
+ * recursive: true,
1321
+ * });
1322
+ * ```
1323
+ */
1324
+ restore(ctx: ConvexContext, args: RestoreMediaFolderArgs): Promise<MediaFolder>;
1325
+ /**
1326
+ * Get a folder by its path.
1327
+ *
1328
+ * @param ctx - Convex query context
1329
+ * @param args - Query arguments with path
1330
+ * @returns The folder or null if not found
1331
+ *
1332
+ * @example
1333
+ * ```typescript
1334
+ * // Find folder by path
1335
+ * const folder = await cms.mediaFolders.getByPath(ctx, {
1336
+ * path: "/Images/Blog/2026",
1337
+ * });
1338
+ * ```
1339
+ */
1340
+ getByPath(ctx: ConvexContext, args: GetMediaFolderByPathArgs): Promise<MediaFolder | null>;
1341
+ /**
1342
+ * Get the entire folder tree as a flat list sorted by path.
1343
+ *
1344
+ * Useful for building folder navigation or selectors.
1345
+ *
1346
+ * @param ctx - Convex query context
1347
+ * @param args - Optional filter arguments
1348
+ * @returns Array of all folders sorted hierarchically by path
1349
+ *
1350
+ * @example
1351
+ * ```typescript
1352
+ * // Get all folders for a tree view
1353
+ * const folders = await cms.mediaFolders.getTree(ctx, {});
1354
+ *
1355
+ * // Build a nested structure
1356
+ * const rootFolders = folders.filter(f => !f.parentId);
1357
+ * ```
1358
+ */
1359
+ getTree(ctx: ConvexContext, args?: GetFolderTreeArgs): Promise<MediaFolder[]>;
1360
+ }
1361
+ /**
1362
+ * Wrapper for media variant operations.
1363
+ *
1364
+ * Media variants are optimized versions of media assets (thumbnails, responsive
1365
+ * sizes, format conversions). This API provides methods for creating, listing,
1366
+ * and managing variants.
1367
+ *
1368
+ * @example
1369
+ * ```typescript
1370
+ * // Get all variants for an asset
1371
+ * const variants = await cms.mediaVariants.list(ctx, {
1372
+ * assetId: assetId,
1373
+ * status: "completed",
1374
+ * });
1375
+ *
1376
+ * // Get responsive srcset for an image
1377
+ * const srcset = await cms.mediaVariants.getResponsiveSrcset(ctx, {
1378
+ * assetId: assetId,
1379
+ * format: "webp",
1380
+ * });
1381
+ * // Use: <img src={srcset.src} srcset={srcset.srcset} sizes="100vw" />
1382
+ * ```
1383
+ */
1384
+ export declare class MediaVariantsApi {
1385
+ private readonly api;
1386
+ private readonly config;
1387
+ constructor(api: TypedComponentApi, config: ResolvedComponentConfig);
1388
+ /**
1389
+ * Create a media variant after external processing.
1390
+ *
1391
+ * Use this when variant processing happens externally (e.g., in a serverless
1392
+ * function or image processing service) and you need to register the
1393
+ * completed variant.
1394
+ *
1395
+ * @param ctx - Convex mutation context
1396
+ * @param args - Variant creation arguments
1397
+ * @returns The created variant with URL
1398
+ *
1399
+ * @example
1400
+ * ```typescript
1401
+ * // After processing image externally and uploading result
1402
+ * const variant = await cms.mediaVariants.create(ctx, {
1403
+ * assetId: assetId,
1404
+ * storageId: processedStorageId,
1405
+ * variantType: "responsive",
1406
+ * width: 480,
1407
+ * height: 320,
1408
+ * format: "webp",
1409
+ * mimeType: "image/webp",
1410
+ * size: 25600,
1411
+ * quality: 80,
1412
+ * preset: "small",
1413
+ * });
1414
+ * ```
1415
+ */
1416
+ create(ctx: ConvexContext, args: CreateMediaVariantArgs): Promise<MediaVariantWithUrl>;
1417
+ /**
1418
+ * Request async generation of a variant.
1419
+ *
1420
+ * Creates a variant record with "pending" status. An external processing
1421
+ * system should pick up pending variants, process them, and update the status.
1422
+ *
1423
+ * @param ctx - Convex mutation context
1424
+ * @param args - Generation request arguments
1425
+ * @returns The pending variant
1426
+ */
1427
+ requestGeneration(ctx: ConvexContext, args: RequestVariantGenerationArgs): Promise<MediaVariant>;
1428
+ /**
1429
+ * Get a variant by ID.
1430
+ *
1431
+ * @param ctx - Convex query context
1432
+ * @param args - Query arguments
1433
+ * @returns The variant with URL or null
1434
+ */
1435
+ get(ctx: ConvexContext, args: {
1436
+ id: string;
1437
+ includeDeleted?: boolean;
1438
+ }): Promise<MediaVariantWithUrl | null>;
1439
+ /**
1440
+ * List variants for an asset.
1441
+ *
1442
+ * @param ctx - Convex query context
1443
+ * @param args - Query arguments with filters
1444
+ * @returns Array of variants with URLs
1445
+ *
1446
+ * @example
1447
+ * ```typescript
1448
+ * // Get all completed responsive variants
1449
+ * const variants = await cms.mediaVariants.list(ctx, {
1450
+ * assetId: assetId,
1451
+ * variantType: "responsive",
1452
+ * status: "completed",
1453
+ * });
1454
+ * ```
1455
+ */
1456
+ list(ctx: ConvexContext, args: ListMediaVariantsArgs): Promise<MediaVariantWithUrl[]>;
1457
+ /**
1458
+ * Find the best matching variant for target dimensions.
1459
+ *
1460
+ * @param ctx - Convex query context
1461
+ * @param args - Target size and preferences
1462
+ * @returns Best matching variant or null
1463
+ *
1464
+ * @example
1465
+ * ```typescript
1466
+ * // Get best variant for 400px wide container
1467
+ * const variant = await cms.mediaVariants.getBestVariant(ctx, {
1468
+ * assetId: assetId,
1469
+ * targetWidth: 400,
1470
+ * preferredFormat: "webp",
1471
+ * });
1472
+ * ```
1473
+ */
1474
+ getBestVariant(ctx: ConvexContext, args: GetBestVariantArgs): Promise<(MediaVariantWithUrl & {
1475
+ isOriginal: boolean;
1476
+ }) | null>;
1477
+ /**
1478
+ * Get responsive srcset data for HTML img/picture tags.
1479
+ *
1480
+ * @param ctx - Convex query context
1481
+ * @param args - Asset ID and optional format filter
1482
+ * @returns Srcset data for responsive images
1483
+ *
1484
+ * @example
1485
+ * ```typescript
1486
+ * const srcset = await cms.mediaVariants.getResponsiveSrcset(ctx, {
1487
+ * assetId: assetId,
1488
+ * format: "webp",
1489
+ * });
1490
+ *
1491
+ * // In React:
1492
+ * <img src={srcset.src} srcset={srcset.srcset} sizes="100vw" />
1493
+ * ```
1494
+ */
1495
+ getResponsiveSrcset(ctx: ConvexContext, args: {
1496
+ assetId: string;
1497
+ format?: string;
1498
+ }): Promise<ResponsiveSrcsetResult>;
1499
+ /**
1500
+ * Get an asset with all its variants organized by type.
1501
+ *
1502
+ * @param ctx - Convex query context
1503
+ * @param args - Asset ID
1504
+ * @returns Asset with variants or null
1505
+ */
1506
+ getAssetWithVariants(ctx: ConvexContext, args: {
1507
+ assetId: string;
1508
+ }): Promise<AssetWithVariants | null>;
1509
+ /**
1510
+ * Get available variant presets.
1511
+ *
1512
+ * @param ctx - Convex query context
1513
+ * @returns Array of preset configurations
1514
+ */
1515
+ getPresets(ctx: ConvexContext): Promise<VariantPreset[]>;
1516
+ /**
1517
+ * Generate variants from preset configurations.
1518
+ *
1519
+ * Queues multiple variants for async processing.
1520
+ *
1521
+ * @param ctx - Convex mutation context
1522
+ * @param args - Asset ID and preset names
1523
+ * @returns Summary of created variant requests
1524
+ *
1525
+ * @example
1526
+ * ```typescript
1527
+ * // Generate standard responsive set
1528
+ * const result = await cms.mediaVariants.generateFromPresets(ctx, {
1529
+ * assetId: assetId,
1530
+ * presets: ["thumbnail", "small", "medium", "large"],
1531
+ * });
1532
+ * console.log(`Queued ${result.succeeded} variants`);
1533
+ * ```
1534
+ */
1535
+ generateFromPresets(ctx: ConvexContext, args: GenerateFromPresetsArgs): Promise<GenerateVariantsResult>;
1536
+ /**
1537
+ * Delete a variant.
1538
+ *
1539
+ * @param ctx - Convex mutation context
1540
+ * @param args - Delete arguments
1541
+ * @returns The deleted variant
1542
+ */
1543
+ delete(ctx: ConvexContext, args: DeleteMediaVariantArgs): Promise<MediaVariant>;
1544
+ /**
1545
+ * Delete all variants for an asset.
1546
+ *
1547
+ * @param ctx - Convex mutation context
1548
+ * @param args - Asset ID and delete options
1549
+ * @returns Summary of deleted variants
1550
+ */
1551
+ deleteAllForAsset(ctx: ConvexContext, args: DeleteAssetVariantsArgs): Promise<{
1552
+ deleted: number;
1553
+ assetId: string;
1554
+ }>;
1555
+ /**
1556
+ * Restore a soft-deleted variant.
1557
+ *
1558
+ * @param ctx - Convex mutation context
1559
+ * @param args - Variant ID to restore
1560
+ * @returns The restored variant
1561
+ */
1562
+ restore(ctx: ConvexContext, args: {
1563
+ id: string;
1564
+ restoredBy?: string;
1565
+ }): Promise<MediaVariant>;
1566
+ }
1567
+ /**
1568
+ * Enhanced CMS client with typed method wrappers for all component operations.
1569
+ *
1570
+ * This client provides an ergonomic, type-safe API for interacting with the
1571
+ * Convex CMS component. All methods accept a Convex context and return
1572
+ * properly typed results.
1573
+ *
1574
+ * @example
1575
+ * ```typescript
1576
+ * import { createCmsClient } from "@convex-cms/core";
1577
+ * import { components } from "./_generated/api";
1578
+ *
1579
+ * export const cms = createCmsClient(components.convexCms, {
1580
+ * defaultLocale: "en-US",
1581
+ * features: {
1582
+ * versioning: true,
1583
+ * localization: true,
1584
+ * },
1585
+ * });
1586
+ *
1587
+ * // In a mutation:
1588
+ * export const createBlogPost = mutation({
1589
+ * args: { title: v.string(), content: v.string() },
1590
+ * handler: async (ctx, args) => {
1591
+ * return await cms.contentEntries.create(ctx, {
1592
+ * contentTypeId: "blog_post_type_id",
1593
+ * data: { title: args.title, content: args.content },
1594
+ * });
1595
+ * },
1596
+ * });
1597
+ * ```
1598
+ */
1599
+ /**
1600
+ * Options for permission checks.
1601
+ */
1602
+ export interface PermissionCheckOptions {
1603
+ /**
1604
+ * Custom role definitions to check in addition to built-in roles.
1605
+ * Use this when you have defined custom roles beyond the defaults.
1606
+ */
1607
+ customRoles?: Record<string, RoleDefinition>;
1608
+ }
1609
+ /**
1610
+ * Result from checking user permissions.
1611
+ */
1612
+ export interface UserPermissionResult {
1613
+ /**
1614
+ * Whether the user has the requested permission.
1615
+ */
1616
+ allowed: boolean;
1617
+ /**
1618
+ * The role that was resolved for the user.
1619
+ * Null if the getUserRole hook returned null.
1620
+ */
1621
+ role: string | null;
1622
+ /**
1623
+ * The permission that was checked.
1624
+ */
1625
+ permission: {
1626
+ resource: Resource;
1627
+ action: Action;
1628
+ scope?: OwnershipScope;
1629
+ };
1630
+ }
1631
+ export interface CmsClient {
1632
+ /**
1633
+ * The resolved configuration for this client instance.
1634
+ */
1635
+ readonly config: ResolvedComponentConfig;
1636
+ /**
1637
+ * The underlying component API reference.
1638
+ */
1639
+ readonly api: TypedComponentApi;
1640
+ /**
1641
+ * Content type management operations.
1642
+ */
1643
+ readonly contentTypes: ContentTypesApi;
1644
+ /**
1645
+ * Content entry CRUD and workflow operations.
1646
+ */
1647
+ readonly contentEntries: ContentEntriesApi;
1648
+ /**
1649
+ * Content version history operations.
1650
+ */
1651
+ readonly versions: VersionsApi;
1652
+ /**
1653
+ * Media asset management operations.
1654
+ */
1655
+ readonly mediaAssets: MediaAssetsApi;
1656
+ /**
1657
+ * Media folder organization operations.
1658
+ */
1659
+ readonly mediaFolders: MediaFoldersApi;
1660
+ /**
1661
+ * Media variant operations (thumbnails, responsive sizes, format conversions).
1662
+ */
1663
+ readonly mediaVariants: MediaVariantsApi;
1664
+ /**
1665
+ * Check if a specific feature is enabled.
1666
+ * @param feature - The feature flag to check
1667
+ * @returns true if the feature is enabled
1668
+ */
1669
+ isFeatureEnabled(feature: keyof FeatureFlags): boolean;
1670
+ /**
1671
+ * Check if a locale is supported by this configuration.
1672
+ * @param locale - The locale code to check
1673
+ * @returns true if the locale is in the supported locales list
1674
+ */
1675
+ isLocaleSupported(locale: LocaleCode): boolean;
1676
+ /**
1677
+ * Get the CMS role for a user.
1678
+ *
1679
+ * Uses the getUserRole hook configured in ComponentConfig to map
1680
+ * user IDs from your auth system to CMS roles.
1681
+ *
1682
+ * @param ctx - Convex context (passed to getUserRole hook for database access)
1683
+ * @param userId - The user ID to look up
1684
+ * @returns The role name or null if the user has no CMS role
1685
+ * @throws Error if no getUserRole hook is configured
1686
+ *
1687
+ * @example
1688
+ * ```typescript
1689
+ * const role = await cms.getUserRole(ctx, "user_123");
1690
+ * if (role === "admin") {
1691
+ * // Allow admin-only operations
1692
+ * }
1693
+ * ```
1694
+ */
1695
+ getUserRole(ctx: ConvexContext, userId: string): Promise<GetUserRoleResult>;
1696
+ /**
1697
+ * Check if a user has a specific permission.
1698
+ *
1699
+ * This is a convenience method that combines getUserRole + hasPermission
1700
+ * into a single call. It first resolves the user's role using the
1701
+ * configured getUserRole hook, then checks if that role has the
1702
+ * requested permission.
1703
+ *
1704
+ * @param ctx - Convex context (passed to getUserRole hook for database access)
1705
+ * @param userId - The user ID to check
1706
+ * @param permission - The permission to check (resource + action + optional scope)
1707
+ * @param options - Optional configuration like custom roles
1708
+ * @returns UserPermissionResult with allowed status and resolved role
1709
+ * @throws Error if no getUserRole hook is configured
1710
+ *
1711
+ * @example
1712
+ * ```typescript
1713
+ * // Check if user can create content entries
1714
+ * const result = await cms.hasPermissionForUser(ctx, "user_123", {
1715
+ * resource: "contentEntries",
1716
+ * action: "create",
1717
+ * });
1718
+ *
1719
+ * if (!result.allowed) {
1720
+ * throw new Error(`User with role ${result.role} cannot create content entries`);
1721
+ * }
1722
+ * ```
1723
+ *
1724
+ * @example
1725
+ * ```typescript
1726
+ * // Check with ownership scope
1727
+ * const canUpdateOwn = await cms.hasPermissionForUser(ctx, "user_123", {
1728
+ * resource: "contentEntries",
1729
+ * action: "update",
1730
+ * scope: "own",
1731
+ * });
1732
+ * ```
1733
+ */
1734
+ hasPermissionForUser(ctx: ConvexContext, userId: string, permission: {
1735
+ resource: Resource;
1736
+ action: Action;
1737
+ scope?: OwnershipScope;
1738
+ }, options?: PermissionCheckOptions): Promise<UserPermissionResult>;
1739
+ /**
1740
+ * Check if the getUserRole hook is configured.
1741
+ *
1742
+ * Use this to conditionally enable RBAC features in your application.
1743
+ *
1744
+ * @returns true if a getUserRole hook is configured
1745
+ *
1746
+ * @example
1747
+ * ```typescript
1748
+ * if (cms.hasUserRoleHook()) {
1749
+ * const allowed = await cms.hasPermissionForUser(userId, permission);
1750
+ * if (!allowed.allowed) throw new Error("Unauthorized");
1751
+ * }
1752
+ * ```
1753
+ */
1754
+ hasUserRoleHook(): boolean;
1755
+ /**
1756
+ * Check if authorization hooks are configured.
1757
+ *
1758
+ * @returns true if any authorization hooks are configured
1759
+ */
1760
+ hasAuthorizationHooks(): boolean;
1761
+ /**
1762
+ * Execute authorization for a CMS operation.
1763
+ *
1764
+ * This method runs the full authorization chain including:
1765
+ * 1. beforeRbac hook (if configured)
1766
+ * 2. Built-in RBAC checks (unless skipRbac is true)
1767
+ * 3. afterRbac hook (if configured)
1768
+ * 4. Operation-specific hooks (if configured)
1769
+ * 5. onDeny hook for denied operations (if configured)
1770
+ *
1771
+ * Use this method to check authorization before performing operations,
1772
+ * especially when you need custom authorization logic beyond RBAC.
1773
+ *
1774
+ * @param context - The authorization context (operation, user, resource info)
1775
+ * @returns AuthorizationResult with allowed status and any modified data
1776
+ *
1777
+ * @example
1778
+ * ```typescript
1779
+ * // Check authorization before publishing
1780
+ * const authResult = await cms.authorize({
1781
+ * operation: "contentEntries.publish",
1782
+ * userId: currentUser,
1783
+ * role: await cms.getUserRole(currentUser),
1784
+ * resourceId: entryId,
1785
+ * resourceOwnerId: entry.createdBy,
1786
+ * contentTypeId: entry.contentTypeId,
1787
+ * operationData: { id: entryId },
1788
+ * });
1789
+ *
1790
+ * if (!authResult.allowed) {
1791
+ * throw new Error(authResult.reason ?? "Not authorized to publish");
1792
+ * }
1793
+ *
1794
+ * // Proceed with operation
1795
+ * await cms.contentEntries.publish(ctx, { id: entryId });
1796
+ * ```
1797
+ *
1798
+ * @example
1799
+ * ```typescript
1800
+ * // With modified data from hooks
1801
+ * const authResult = await cms.authorize({
1802
+ * operation: "contentEntries.create",
1803
+ * userId: currentUser,
1804
+ * role: userRole,
1805
+ * operationData: entryData,
1806
+ * });
1807
+ *
1808
+ * if (authResult.allowed && authResult.modifiedData) {
1809
+ * // Use the modified data from hooks
1810
+ * await cms.contentEntries.create(ctx, authResult.modifiedData);
1811
+ * }
1812
+ * ```
1813
+ */
1814
+ authorize(context: AuthorizationHookContext): Promise<AuthorizationResult>;
1815
+ /**
1816
+ * Execute authorization and throw if denied.
1817
+ *
1818
+ * Convenience method that calls `authorize()` and throws an UnauthorizedError
1819
+ * if the operation is not allowed.
1820
+ *
1821
+ * @param context - The authorization context
1822
+ * @throws UnauthorizedError if the operation is denied
1823
+ * @returns The authorization result (if allowed)
1824
+ *
1825
+ * @example
1826
+ * ```typescript
1827
+ * // Will throw if not authorized
1828
+ * await cms.requireAuthorization({
1829
+ * operation: "contentEntries.delete",
1830
+ * userId: currentUser,
1831
+ * role: userRole,
1832
+ * resourceId: entryId,
1833
+ * resourceOwnerId: entry.createdBy,
1834
+ * });
1835
+ *
1836
+ * // Only reached if authorized
1837
+ * await cms.contentEntries.delete(ctx, { id: entryId });
1838
+ * ```
1839
+ */
1840
+ requireAuthorization(context: AuthorizationHookContext): Promise<AuthorizationResult>;
1841
+ /**
1842
+ * Consolidated locale API with simplified methods.
1843
+ *
1844
+ * @example
1845
+ * ```typescript
1846
+ * // Get locale configuration
1847
+ * const config = cms.locale.getConfig();
1848
+ *
1849
+ * // Get fallback chain for a locale
1850
+ * const chain = cms.locale.getFallbackChain("es-MX");
1851
+ *
1852
+ * // Resolve locale with full metadata
1853
+ * const resolved = cms.locale.resolve("es-MX");
1854
+ * ```
1855
+ */
1856
+ readonly locale: {
1857
+ /**
1858
+ * Get the full locale configuration.
1859
+ */
1860
+ getConfig(): LocaleFallbackConfig;
1861
+ /**
1862
+ * Get the fallback chain for a locale.
1863
+ */
1864
+ getFallbackChain(locale: LocaleCode): LocaleCode[];
1865
+ /**
1866
+ * Resolve a locale with full metadata.
1867
+ */
1868
+ resolve(locale: LocaleCode): ResolvedFallbackChain;
1869
+ };
1870
+ /**
1871
+ * Get all configured custom roles.
1872
+ *
1873
+ * Returns a record of custom role definitions that were configured when
1874
+ * creating the CMS client. Does not include built-in roles.
1875
+ *
1876
+ * @returns Record of custom role name to definition
1877
+ *
1878
+ * @example
1879
+ * ```typescript
1880
+ * const customRoles = cms.getCustomRoles();
1881
+ * for (const [name, role] of Object.entries(customRoles)) {
1882
+ * console.log(`${name}: ${role.displayName}`);
1883
+ * }
1884
+ * ```
1885
+ */
1886
+ getCustomRoles(): Record<string, import("./types.js").CustomRoleDefinition>;
1887
+ /**
1888
+ * Get a specific custom role by name.
1889
+ *
1890
+ * @param roleName - The name of the custom role to get
1891
+ * @returns The custom role definition, or undefined if not found
1892
+ *
1893
+ * @example
1894
+ * ```typescript
1895
+ * const blogAuthor = cms.getCustomRole("blog-author");
1896
+ * if (blogAuthor) {
1897
+ * console.log(blogAuthor.displayName); // "Blog Author"
1898
+ * }
1899
+ * ```
1900
+ */
1901
+ getCustomRole(roleName: string): import("./types.js").CustomRoleDefinition | undefined;
1902
+ /**
1903
+ * Check if a custom role exists.
1904
+ *
1905
+ * @param roleName - The name of the role to check
1906
+ * @returns True if the role is a custom role (not built-in)
1907
+ *
1908
+ * @example
1909
+ * ```typescript
1910
+ * cms.isCustomRole("blog-author"); // true (if configured)
1911
+ * cms.isCustomRole("admin"); // false (built-in)
1912
+ * cms.isCustomRole("unknown"); // false
1913
+ * ```
1914
+ */
1915
+ isCustomRole(roleName: string): boolean;
1916
+ /**
1917
+ * Check if a user can perform an action on a specific content type.
1918
+ *
1919
+ * This is similar to `hasPermissionForUser` but additionally checks
1920
+ * content-type-specific permission restrictions that may be configured
1921
+ * on custom roles.
1922
+ *
1923
+ * @param userId - The user ID to check
1924
+ * @param permission - The permission to check
1925
+ * @param contentTypeName - The content type to check permissions for
1926
+ * @returns UserPermissionResult with allowed status
1927
+ *
1928
+ * @example
1929
+ * ```typescript
1930
+ * // Check if user can create blog posts (may be restricted by custom role)
1931
+ * const result = await cms.hasContentTypePermissionForUser(
1932
+ * ctx,
1933
+ * "user_123",
1934
+ * { resource: "contentEntries", action: "create" },
1935
+ * "blog_post"
1936
+ * );
1937
+ *
1938
+ * if (result.allowed) {
1939
+ * // User can create blog posts
1940
+ * }
1941
+ * ```
1942
+ */
1943
+ hasContentTypePermissionForUser(ctx: ConvexContext, userId: string, permission: {
1944
+ resource: Resource;
1945
+ action: Action;
1946
+ scope?: OwnershipScope;
1947
+ }, contentTypeName: string): Promise<UserPermissionResult>;
1948
+ /**
1949
+ * Get all content types a user can perform an action on.
1950
+ *
1951
+ * Returns an array of content type names that the user has permission to
1952
+ * perform the specified action on, based on their role's permissions.
1953
+ *
1954
+ * @param userId - The user ID to check
1955
+ * @param action - The action to check (e.g., "create", "update", "publish")
1956
+ * @returns Array of content type names, ["*"] if unrestricted, or [] if no permission
1957
+ *
1958
+ * @example
1959
+ * ```typescript
1960
+ * // Get content types the user can create
1961
+ * const types = await cms.getPermittedContentTypesForUser(ctx, "user_123", "create");
1962
+ *
1963
+ * if (types.includes("*")) {
1964
+ * // User can create any content type
1965
+ * } else if (types.includes("blog_post")) {
1966
+ * // User can create blog posts
1967
+ * }
1968
+ * ```
1969
+ */
1970
+ getPermittedContentTypesForUser(ctx: ConvexContext, userId: string, action: Action): Promise<string[]>;
1971
+ /**
1972
+ * Get all roles (built-in and custom) merged together.
1973
+ *
1974
+ * Returns a record containing both the default built-in roles and
1975
+ * any custom roles configured on this client. Useful for UI rendering
1976
+ * or iterating over all available roles.
1977
+ *
1978
+ * @returns Record of all role names to definitions
1979
+ *
1980
+ * @example
1981
+ * ```typescript
1982
+ * const allRoles = cms.getAllRoles();
1983
+ * // Includes: admin, editor, author, viewer, blog-author, etc.
1984
+ *
1985
+ * // Render role selector
1986
+ * Object.entries(allRoles).map(([name, role]) => (
1987
+ * <option key={name} value={name}>{role.displayName}</option>
1988
+ * ));
1989
+ * ```
1990
+ */
1991
+ getAllRoles(): Record<string, RoleDefinition | import("./types.js").CustomRoleDefinition>;
1992
+ /**
1993
+ * Check if a user can perform an action on a specific resource, with ownership verification.
1994
+ *
1995
+ * This is the most comprehensive permission check method. It:
1996
+ * 1. Resolves the user's role via the getUserRole hook
1997
+ * 2. Checks if the role has the required permission
1998
+ * 3. For "own" scope permissions, verifies that the user owns the resource
1999
+ *
2000
+ * Use this when you need to check authorization for a specific resource that may
2001
+ * have ownership-based restrictions (e.g., "can this author update THIS entry?").
2002
+ *
2003
+ * @param userId - The user ID performing the action
2004
+ * @param resource - The resource type (e.g., "contentEntries", "mediaAssets")
2005
+ * @param action - The action being performed (e.g., "update", "delete", "publish")
2006
+ * @param resourceOwnerId - The ID of the user who created/owns the resource
2007
+ * @returns Permission result with ownership verification details
2008
+ *
2009
+ * @example
2010
+ * ```typescript
2011
+ * // Check if an author can update a specific content entry
2012
+ * const entry = await ctx.db.get(entryId);
2013
+ * const result = await cms.canUserPerformOnResource(
2014
+ * ctx,
2015
+ * currentUserId,
2016
+ * "contentEntries",
2017
+ * "update",
2018
+ * entry.createdBy // The owner's user ID
2019
+ * );
2020
+ *
2021
+ * if (!result.allowed) {
2022
+ * if (result.ownershipRequired) {
2023
+ * throw new Error("You can only update your own entries");
2024
+ * }
2025
+ * throw new Error(`Role '${result.role}' cannot update content entries`);
2026
+ * }
2027
+ *
2028
+ * // Proceed with update...
2029
+ * ```
2030
+ *
2031
+ * @example
2032
+ * ```typescript
2033
+ * // Check if user can delete a media asset they uploaded
2034
+ * const asset = await ctx.db.get(assetId);
2035
+ * const result = await cms.canUserPerformOnResource(
2036
+ * ctx,
2037
+ * userId,
2038
+ * "mediaAssets",
2039
+ * "delete",
2040
+ * asset.createdBy
2041
+ * );
2042
+ *
2043
+ * if (result.allowed && result.grantedScope === "own") {
2044
+ * console.log("User can delete only because they own this asset");
2045
+ * }
2046
+ * ```
2047
+ */
2048
+ canUserPerformOnResource(ctx: ConvexContext, userId: string, resource: Resource, action: Action, resourceOwnerId?: string): Promise<ResourcePermissionResult>;
2049
+ /**
2050
+ * Require that a user can perform an action on a specific resource.
2051
+ *
2052
+ * This is the throwing version of `canUserPerformOnResource`. If the permission
2053
+ * check fails, it throws an UnauthorizedError with detailed context.
2054
+ *
2055
+ * Use this at the start of mutation handlers to enforce ownership-based access control.
2056
+ *
2057
+ * @param userId - The user ID performing the action
2058
+ * @param resource - The resource type
2059
+ * @param action - The action being performed
2060
+ * @param resourceOwnerId - The ID of the resource owner
2061
+ * @throws UnauthorizedError if permission is denied or ownership verification fails
2062
+ * @returns Permission granted details
2063
+ *
2064
+ * @example
2065
+ * ```typescript
2066
+ * // In a mutation handler - will throw if not authorized
2067
+ * export const deleteEntry = mutation({
2068
+ * args: { id: v.id("contentEntries"), userId: v.string() },
2069
+ * handler: async (ctx, args) => {
2070
+ * const entry = await ctx.db.get(args.id);
2071
+ * if (!entry) throw new Error("Entry not found");
2072
+ *
2073
+ * // Throws UnauthorizedError if user can't delete this entry
2074
+ * await cms.requireUserCanPerformOnResource(
2075
+ * ctx,
2076
+ * args.userId,
2077
+ * "contentEntries",
2078
+ * "delete",
2079
+ * entry.createdBy
2080
+ * );
2081
+ *
2082
+ * // Safe to proceed - user is authorized
2083
+ * await ctx.db.delete(args.id);
2084
+ * },
2085
+ * });
2086
+ * ```
2087
+ */
2088
+ requireUserCanPerformOnResource(ctx: ConvexContext, userId: string, resource: Resource, action: Action, resourceOwnerId?: string): Promise<ResourcePermissionGranted>;
2089
+ /**
2090
+ * Check if a user owns a specific resource.
2091
+ *
2092
+ * Simple helper that compares user ID with resource owner ID.
2093
+ * Does not check permissions - just ownership.
2094
+ *
2095
+ * @param userId - The user ID to check
2096
+ * @param resourceOwnerId - The ID of the resource owner
2097
+ * @returns true if the user owns the resource
2098
+ *
2099
+ * @example
2100
+ * ```typescript
2101
+ * const entry = await ctx.db.get(entryId);
2102
+ * if (cms.isOwner(currentUserId, entry.createdBy)) {
2103
+ * // User owns this entry
2104
+ * }
2105
+ * ```
2106
+ */
2107
+ isOwner(userId: string | undefined, resourceOwnerId: string | undefined): boolean;
2108
+ }
2109
+ /**
2110
+ * Result from checking resource permission with ownership verification.
2111
+ */
2112
+ export interface ResourcePermissionResult {
2113
+ /**
2114
+ * Whether the user is allowed to perform the action.
2115
+ */
2116
+ allowed: boolean;
2117
+ /**
2118
+ * The user's role (null if no role assigned).
2119
+ */
2120
+ role: string | null;
2121
+ /**
2122
+ * The scope that was granted (if allowed).
2123
+ * "all" means the user can access any resource.
2124
+ * "own" means the user can only access resources they created.
2125
+ */
2126
+ grantedScope?: OwnershipScope;
2127
+ /**
2128
+ * Whether ownership was verified (true if resourceOwnerId was provided and matched userId).
2129
+ */
2130
+ ownershipVerified?: boolean;
2131
+ /**
2132
+ * If denied, indicates whether the denial was due to ownership requirements.
2133
+ * true when the user has "own" scope but doesn't own the resource.
2134
+ */
2135
+ ownershipRequired?: boolean;
2136
+ /**
2137
+ * The reason for denial (if not allowed).
2138
+ */
2139
+ reason?: string;
2140
+ /**
2141
+ * Error code for programmatic handling (if not allowed).
2142
+ */
2143
+ code?: string;
2144
+ }
2145
+ /**
2146
+ * Result from a successful resource permission check.
2147
+ */
2148
+ export interface ResourcePermissionGranted {
2149
+ /**
2150
+ * Always true for granted permissions.
2151
+ */
2152
+ allowed: true;
2153
+ /**
2154
+ * The user's role.
2155
+ */
2156
+ role: string;
2157
+ /**
2158
+ * The scope that was granted.
2159
+ */
2160
+ grantedScope: OwnershipScope;
2161
+ /**
2162
+ * Whether ownership was verified.
2163
+ */
2164
+ ownershipVerified: boolean;
2165
+ }
2166
+ /**
2167
+ * Creates an enhanced CMS client with typed method wrappers.
2168
+ *
2169
+ * This is the main entry point for using the Convex CMS component.
2170
+ * The returned client provides typed methods for all CMS operations.
2171
+ *
2172
+ * @param componentApi - The component API from `components.convexCms`
2173
+ * @param config - Optional configuration options
2174
+ * @returns An enhanced CMS client instance
2175
+ *
2176
+ * @example
2177
+ * ```typescript
2178
+ * import { createCmsClient } from "@convex-cms/core";
2179
+ * import { components } from "./_generated/api";
2180
+ *
2181
+ * // Create with default configuration
2182
+ * export const cms = createCmsClient(components.convexCms);
2183
+ *
2184
+ * // Create with custom configuration
2185
+ * export const cms = createCmsClient(components.convexCms, {
2186
+ * defaultLocale: "en-US",
2187
+ * supportedLocales: ["en-US", "es-ES", "fr-FR"],
2188
+ * features: {
2189
+ * versioning: true,
2190
+ * localization: true,
2191
+ * scheduling: true,
2192
+ * },
2193
+ * maxVersionsPerEntry: 100,
2194
+ * });
2195
+ * ```
2196
+ */
2197
+ export declare function createCmsClient(componentApi: TypedComponentApi, config?: ComponentConfig): CmsClient;
2198
+ //# sourceMappingURL=wrapper.d.ts.map