@nextsparkjs/core 0.1.0-beta.92 → 0.1.0-beta.95

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 (346) hide show
  1. package/dist/components/dashboard/block-editor/array-field.d.ts.map +1 -1
  2. package/dist/components/dashboard/block-editor/array-field.js +55 -3
  3. package/dist/components/dashboard/block-editor/dynamic-form.d.ts.map +1 -1
  4. package/dist/components/dashboard/block-editor/dynamic-form.js +82 -2
  5. package/dist/components/dashboard/navigation/DynamicNavigation.d.ts.map +1 -1
  6. package/dist/components/dashboard/navigation/DynamicNavigation.js +7 -1
  7. package/dist/components/devtools/scheduled-actions/actions-table.d.ts +1 -0
  8. package/dist/components/devtools/scheduled-actions/actions-table.d.ts.map +1 -1
  9. package/dist/components/devtools/scheduled-actions/actions-table.js +182 -46
  10. package/dist/components/devtools/scheduled-actions/types.d.ts +1 -0
  11. package/dist/components/devtools/scheduled-actions/types.d.ts.map +1 -1
  12. package/dist/components/media/MediaCard.d.ts +23 -0
  13. package/dist/components/media/MediaCard.d.ts.map +1 -0
  14. package/dist/components/media/MediaCard.js +154 -0
  15. package/dist/components/media/MediaDetailPanel.d.ts +17 -0
  16. package/dist/components/media/MediaDetailPanel.d.ts.map +1 -0
  17. package/dist/components/media/MediaDetailPanel.js +331 -0
  18. package/dist/components/media/MediaGrid.d.ts +26 -0
  19. package/dist/components/media/MediaGrid.d.ts.map +1 -0
  20. package/dist/components/media/MediaGrid.js +77 -0
  21. package/dist/components/media/MediaLibrary.d.ts +20 -0
  22. package/dist/components/media/MediaLibrary.d.ts.map +1 -0
  23. package/dist/components/media/MediaLibrary.js +229 -0
  24. package/dist/components/media/MediaList.d.ts +24 -0
  25. package/dist/components/media/MediaList.d.ts.map +1 -0
  26. package/dist/components/media/MediaList.js +181 -0
  27. package/dist/components/media/MediaSelector.d.ts +19 -0
  28. package/dist/components/media/MediaSelector.d.ts.map +1 -0
  29. package/dist/components/media/MediaSelector.js +145 -0
  30. package/dist/components/media/MediaTagFilter.d.ts +16 -0
  31. package/dist/components/media/MediaTagFilter.d.ts.map +1 -0
  32. package/dist/components/media/MediaTagFilter.js +122 -0
  33. package/dist/components/media/MediaToolbar.d.ts +25 -0
  34. package/dist/components/media/MediaToolbar.d.ts.map +1 -0
  35. package/dist/components/media/MediaToolbar.js +136 -0
  36. package/dist/components/media/MediaUploadZone.d.ts +19 -0
  37. package/dist/components/media/MediaUploadZone.d.ts.map +1 -0
  38. package/dist/components/media/MediaUploadZone.js +248 -0
  39. package/dist/components/media/index.d.ts +15 -0
  40. package/dist/components/media/index.d.ts.map +1 -0
  41. package/dist/components/media/index.js +20 -0
  42. package/dist/contexts/TeamContext.js +1 -1
  43. package/dist/hooks/index.d.ts +2 -0
  44. package/dist/hooks/index.d.ts.map +1 -1
  45. package/dist/hooks/index.js +2 -0
  46. package/dist/hooks/useEnsureUserMetadata.d.ts +4 -0
  47. package/dist/hooks/useEnsureUserMetadata.d.ts.map +1 -1
  48. package/dist/hooks/useEnsureUserMetadata.js +85 -60
  49. package/dist/hooks/useEntityMutations.d.ts.map +1 -1
  50. package/dist/hooks/useEntityMutations.js +5 -9
  51. package/dist/hooks/useMedia.d.ts +56 -0
  52. package/dist/hooks/useMedia.d.ts.map +1 -0
  53. package/dist/hooks/useMedia.js +181 -0
  54. package/dist/hooks/useMediaUpload.d.ts +27 -0
  55. package/dist/hooks/useMediaUpload.d.ts.map +1 -0
  56. package/dist/hooks/useMediaUpload.js +36 -0
  57. package/dist/hooks/useUserSettings.d.ts +5 -4
  58. package/dist/hooks/useUserSettings.d.ts.map +1 -1
  59. package/dist/hooks/useUserSettings.js +42 -40
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +2 -3
  63. package/dist/lib/api/auth/dual-auth.d.ts +6 -2
  64. package/dist/lib/api/auth/dual-auth.d.ts.map +1 -1
  65. package/dist/lib/api/auth/dual-auth.js +5 -9
  66. package/dist/lib/api/entity/generic-handler.d.ts.map +1 -1
  67. package/dist/lib/api/entity/generic-handler.js +3 -3
  68. package/dist/lib/auth.d.ts.map +1 -1
  69. package/dist/lib/auth.js +3 -2
  70. package/dist/lib/config/app.config.d.ts.map +1 -1
  71. package/dist/lib/config/app.config.js +37 -0
  72. package/dist/lib/config/config-sync.d.ts +1 -0
  73. package/dist/lib/config/config-sync.d.ts.map +1 -1
  74. package/dist/lib/config/config-sync.js +2 -0
  75. package/dist/lib/config/types.d.ts +29 -0
  76. package/dist/lib/config/types.d.ts.map +1 -1
  77. package/dist/lib/db.d.ts +10 -0
  78. package/dist/lib/db.d.ts.map +1 -1
  79. package/dist/lib/db.js +13 -1
  80. package/dist/lib/media/schemas.d.ts +39 -0
  81. package/dist/lib/media/schemas.d.ts.map +1 -0
  82. package/dist/lib/media/schemas.js +32 -0
  83. package/dist/lib/media/types.d.ts +69 -0
  84. package/dist/lib/media/types.d.ts.map +1 -0
  85. package/dist/lib/media/types.js +0 -0
  86. package/dist/lib/media/utils.d.ts +26 -0
  87. package/dist/lib/media/utils.d.ts.map +1 -0
  88. package/dist/lib/media/utils.js +33 -0
  89. package/dist/lib/rate-limit-redis.d.ts.map +1 -1
  90. package/dist/lib/rate-limit-redis.js +13 -4
  91. package/dist/lib/scheduled-actions/initializer.d.ts +6 -3
  92. package/dist/lib/scheduled-actions/initializer.d.ts.map +1 -1
  93. package/dist/lib/scheduled-actions/initializer.js +11 -6
  94. package/dist/lib/scheduled-actions/processor.d.ts +20 -4
  95. package/dist/lib/scheduled-actions/processor.d.ts.map +1 -1
  96. package/dist/lib/scheduled-actions/processor.js +128 -34
  97. package/dist/lib/scheduled-actions/registry.d.ts +3 -0
  98. package/dist/lib/scheduled-actions/registry.d.ts.map +1 -1
  99. package/dist/lib/scheduled-actions/registry.js +2 -1
  100. package/dist/lib/scheduled-actions/scheduler.d.ts +1 -1
  101. package/dist/lib/scheduled-actions/scheduler.d.ts.map +1 -1
  102. package/dist/lib/scheduled-actions/scheduler.js +76 -38
  103. package/dist/lib/scheduled-actions/types.d.ts +73 -0
  104. package/dist/lib/scheduled-actions/types.d.ts.map +1 -1
  105. package/dist/lib/selectors/core-selectors.d.ts +102 -0
  106. package/dist/lib/selectors/core-selectors.d.ts.map +1 -1
  107. package/dist/lib/selectors/core-selectors.js +3 -1
  108. package/dist/lib/selectors/domains/block-editor.selectors.d.ts +8 -0
  109. package/dist/lib/selectors/domains/block-editor.selectors.d.ts.map +1 -1
  110. package/dist/lib/selectors/domains/block-editor.selectors.js +9 -0
  111. package/dist/lib/selectors/domains/devtools.selectors.d.ts +6 -0
  112. package/dist/lib/selectors/domains/devtools.selectors.d.ts.map +1 -1
  113. package/dist/lib/selectors/domains/devtools.selectors.js +6 -0
  114. package/dist/lib/selectors/domains/index.d.ts +1 -0
  115. package/dist/lib/selectors/domains/index.d.ts.map +1 -1
  116. package/dist/lib/selectors/domains/index.js +2 -0
  117. package/dist/lib/selectors/domains/media.selectors.d.ts +96 -0
  118. package/dist/lib/selectors/domains/media.selectors.d.ts.map +1 -0
  119. package/dist/lib/selectors/domains/media.selectors.js +103 -0
  120. package/dist/lib/selectors/selectors.d.ts +204 -0
  121. package/dist/lib/selectors/selectors.d.ts.map +1 -1
  122. package/dist/lib/services/index.d.ts +2 -0
  123. package/dist/lib/services/index.d.ts.map +1 -1
  124. package/dist/lib/services/index.js +2 -0
  125. package/dist/lib/services/media.service.d.ts +158 -0
  126. package/dist/lib/services/media.service.d.ts.map +1 -0
  127. package/dist/lib/services/media.service.js +410 -0
  128. package/dist/messages/de/devtools.json +16 -0
  129. package/dist/messages/de/index.d.ts +16 -0
  130. package/dist/messages/de/index.d.ts.map +1 -1
  131. package/dist/messages/en/admin.json +4 -1
  132. package/dist/messages/en/devtools.json +16 -0
  133. package/dist/messages/en/index.d.ts +167 -0
  134. package/dist/messages/en/index.d.ts.map +1 -1
  135. package/dist/messages/en/index.js +2 -0
  136. package/dist/messages/en/index.ts +2 -0
  137. package/dist/messages/en/media.json +147 -0
  138. package/dist/messages/en/navigation.json +1 -0
  139. package/dist/messages/es/admin.json +4 -1
  140. package/dist/messages/es/devtools.json +16 -0
  141. package/dist/messages/es/index.d.ts +167 -0
  142. package/dist/messages/es/index.d.ts.map +1 -1
  143. package/dist/messages/es/index.js +2 -0
  144. package/dist/messages/es/index.ts +2 -0
  145. package/dist/messages/es/media.json +147 -0
  146. package/dist/messages/es/navigation.json +1 -0
  147. package/dist/messages/fr/devtools.json +16 -0
  148. package/dist/messages/fr/index.d.ts +16 -0
  149. package/dist/messages/fr/index.d.ts.map +1 -1
  150. package/dist/messages/it/devtools.json +16 -0
  151. package/dist/messages/it/index.d.ts +16 -0
  152. package/dist/messages/it/index.d.ts.map +1 -1
  153. package/dist/messages/pt/devtools.json +16 -0
  154. package/dist/messages/pt/index.d.ts +16 -0
  155. package/dist/messages/pt/index.d.ts.map +1 -1
  156. package/dist/migrations/017_scheduled_actions_table.sql +21 -0
  157. package/dist/migrations/021_media.sql +154 -0
  158. package/dist/migrations/090_sample_data.sql +53 -0
  159. package/dist/styles/classes.json +36 -3
  160. package/dist/styles/ui.css +1 -1
  161. package/dist/templates/app/api/devtools/config/entities/route.ts +18 -11
  162. package/dist/templates/app/api/devtools/config/theme/route.ts +5 -4
  163. package/dist/templates/app/api/devtools/tests/[...path]/route.ts +6 -5
  164. package/dist/templates/app/api/devtools/tests/route.ts +5 -4
  165. package/dist/templates/app/api/health/route.ts +6 -4
  166. package/dist/templates/app/api/internal/user-metadata/route.ts +3 -2
  167. package/dist/templates/app/api/superadmin/subscriptions/route.ts +5 -6
  168. package/dist/templates/app/api/superadmin/teams/[teamId]/route.ts +6 -7
  169. package/dist/templates/app/api/superadmin/teams/route.ts +5 -6
  170. package/dist/templates/app/api/superadmin/users/[userId]/route.ts +11 -16
  171. package/dist/templates/app/api/superadmin/users/route.ts +9 -10
  172. package/dist/templates/app/api/user/delete-account/route.ts +3 -2
  173. package/dist/templates/app/api/user/plan-flags/route.ts +11 -24
  174. package/dist/templates/app/api/user/profile/route.ts +7 -6
  175. package/dist/templates/app/api/v1/[entity]/[id]/child/[childType]/[childId]/route.ts +16 -18
  176. package/dist/templates/app/api/v1/[entity]/[id]/child/[childType]/route.ts +17 -19
  177. package/dist/templates/app/api/v1/[entity]/[id]/route.ts +10 -12
  178. package/dist/templates/app/api/v1/[entity]/route.ts +9 -11
  179. package/dist/templates/app/api/v1/api-keys/[id]/route.ts +9 -8
  180. package/dist/templates/app/api/v1/api-keys/route.ts +7 -6
  181. package/dist/templates/app/api/v1/auth/signup-with-invite/route.ts +3 -2
  182. package/dist/templates/app/api/v1/billing/cancel/route.ts +15 -14
  183. package/dist/templates/app/api/v1/billing/change-plan/route.ts +10 -9
  184. package/dist/templates/app/api/v1/billing/check-action/route.ts +8 -7
  185. package/dist/templates/app/api/v1/billing/checkout/route.ts +10 -9
  186. package/dist/templates/app/api/v1/billing/plans/route.ts +5 -4
  187. package/dist/templates/app/api/v1/billing/portal/route.ts +9 -8
  188. package/dist/templates/app/api/v1/blocks/[slug]/route.ts +4 -3
  189. package/dist/templates/app/api/v1/blocks/route.ts +3 -2
  190. package/dist/templates/app/api/v1/blocks/validate/route.ts +5 -3
  191. package/dist/templates/app/api/v1/cron/process/route.ts +4 -6
  192. package/dist/templates/app/api/v1/devtools/blocks/route.ts +3 -2
  193. package/dist/templates/app/api/v1/devtools/docs/route.ts +3 -2
  194. package/dist/templates/app/api/v1/devtools/features/route.ts +3 -2
  195. package/dist/templates/app/api/v1/devtools/flows/route.ts +3 -2
  196. package/dist/templates/app/api/v1/devtools/scheduled-actions/route.ts +125 -3
  197. package/dist/templates/app/api/v1/devtools/scheduled-actions/run/route.ts +110 -0
  198. package/dist/templates/app/api/v1/devtools/testing/route.ts +3 -2
  199. package/dist/templates/app/api/v1/media/[id]/route.ts +144 -0
  200. package/dist/templates/app/api/v1/media/[id]/tags/route.ts +154 -0
  201. package/dist/templates/app/api/v1/media/check-duplicates/route.ts +56 -0
  202. package/dist/templates/app/api/v1/media/route.ts +56 -0
  203. package/dist/templates/app/api/v1/media/upload/route.ts +157 -33
  204. package/dist/templates/app/api/v1/media-tags/route.ts +65 -0
  205. package/dist/templates/app/api/v1/plugin/[...path]/route.ts +16 -15
  206. package/dist/templates/app/api/v1/plugin/route.ts +3 -2
  207. package/dist/templates/app/api/v1/post-categories/[id]/route.ts +10 -9
  208. package/dist/templates/app/api/v1/post-categories/route.ts +5 -4
  209. package/dist/templates/app/api/v1/team-invitations/[token]/accept/route.ts +3 -3
  210. package/dist/templates/app/api/v1/team-invitations/[token]/decline/route.ts +3 -3
  211. package/dist/templates/app/api/v1/team-invitations/[token]/route.ts +3 -2
  212. package/dist/templates/app/api/v1/team-invitations/route.ts +3 -2
  213. package/dist/templates/app/api/v1/teams/[teamId]/invitations/route.ts +5 -4
  214. package/dist/templates/app/api/v1/teams/[teamId]/invoices/[invoiceNumber]/route.ts +3 -2
  215. package/dist/templates/app/api/v1/teams/[teamId]/invoices/route.ts +3 -2
  216. package/dist/templates/app/api/v1/teams/[teamId]/members/[memberId]/route.ts +5 -4
  217. package/dist/templates/app/api/v1/teams/[teamId]/members/route.ts +5 -5
  218. package/dist/templates/app/api/v1/teams/[teamId]/route.ts +31 -58
  219. package/dist/templates/app/api/v1/teams/[teamId]/subscription/route.ts +3 -2
  220. package/dist/templates/app/api/v1/teams/[teamId]/usage/[limitSlug]/route.ts +5 -4
  221. package/dist/templates/app/api/v1/teams/route.ts +18 -17
  222. package/dist/templates/app/api/v1/teams/switch/route.ts +3 -2
  223. package/dist/templates/app/api/v1/theme/[...path]/route.ts +16 -15
  224. package/dist/templates/app/api/v1/theme/route.ts +3 -2
  225. package/dist/templates/app/api/v1/users/[id]/meta/[key]/route.ts +7 -6
  226. package/dist/templates/app/api/v1/users/[id]/route.ts +9 -8
  227. package/dist/templates/app/api/v1/users/route.ts +7 -6
  228. package/dist/templates/app/dashboard/(main)/media/page.tsx +607 -0
  229. package/dist/templates/contents/themes/starter/messages/de/dev.json +106 -0
  230. package/dist/templates/contents/themes/starter/messages/de/index.ts +2 -0
  231. package/dist/templates/contents/themes/starter/messages/en/dev.json +106 -0
  232. package/dist/templates/contents/themes/starter/messages/en/index.ts +2 -0
  233. package/dist/templates/contents/themes/starter/messages/es/dev.json +106 -0
  234. package/dist/templates/contents/themes/starter/messages/es/index.ts +2 -0
  235. package/dist/templates/contents/themes/starter/messages/fr/dev.json +106 -0
  236. package/dist/templates/contents/themes/starter/messages/fr/index.ts +2 -0
  237. package/dist/templates/contents/themes/starter/messages/it/dev.json +106 -0
  238. package/dist/templates/contents/themes/starter/messages/it/index.ts +2 -0
  239. package/dist/templates/contents/themes/starter/messages/pt/dev.json +106 -0
  240. package/dist/templates/contents/themes/starter/messages/pt/index.ts +2 -0
  241. package/dist/templates/contents/themes/starter/styles/globals.css +14 -0
  242. package/dist/templates/instrumentation.ts +33 -0
  243. package/dist/types/blocks.d.ts +1 -1
  244. package/dist/types/blocks.d.ts.map +1 -1
  245. package/migrations/017_scheduled_actions_table.sql +21 -0
  246. package/migrations/021_media.sql +154 -0
  247. package/migrations/090_sample_data.sql +53 -0
  248. package/package.json +16 -15
  249. package/scripts/build/registry/config.mjs +41 -0
  250. package/scripts/build/registry/discovery/templates.mjs +0 -1
  251. package/scripts/build/registry/generators/entity-registry.mjs +16 -6
  252. package/scripts/build/registry/generators/route-handlers.mjs +8 -2
  253. package/scripts/build/registry/generators/template-registry.mjs +16 -4
  254. package/scripts/build/registry/post-build/route-cleanup.mjs +0 -1
  255. package/scripts/build/registry/validate-env.test.mjs +92 -0
  256. package/scripts/build/registry.mjs +18 -1
  257. package/scripts/deploy/vercel-deploy.mjs +1 -1
  258. package/templates/app/api/devtools/config/entities/route.ts +18 -11
  259. package/templates/app/api/devtools/config/theme/route.ts +5 -4
  260. package/templates/app/api/devtools/tests/[...path]/route.ts +6 -5
  261. package/templates/app/api/devtools/tests/route.ts +5 -4
  262. package/templates/app/api/health/route.ts +6 -4
  263. package/templates/app/api/internal/user-metadata/route.ts +3 -2
  264. package/templates/app/api/superadmin/subscriptions/route.ts +5 -6
  265. package/templates/app/api/superadmin/teams/[teamId]/route.ts +6 -7
  266. package/templates/app/api/superadmin/teams/route.ts +5 -6
  267. package/templates/app/api/superadmin/users/[userId]/route.ts +11 -16
  268. package/templates/app/api/superadmin/users/route.ts +9 -10
  269. package/templates/app/api/user/delete-account/route.ts +3 -2
  270. package/templates/app/api/user/plan-flags/route.ts +11 -24
  271. package/templates/app/api/user/profile/route.ts +7 -6
  272. package/templates/app/api/v1/[entity]/[id]/child/[childType]/[childId]/route.ts +16 -18
  273. package/templates/app/api/v1/[entity]/[id]/child/[childType]/route.ts +17 -19
  274. package/templates/app/api/v1/[entity]/[id]/route.ts +10 -12
  275. package/templates/app/api/v1/[entity]/route.ts +9 -11
  276. package/templates/app/api/v1/api-keys/[id]/route.ts +9 -8
  277. package/templates/app/api/v1/api-keys/route.ts +7 -6
  278. package/templates/app/api/v1/auth/signup-with-invite/route.ts +3 -2
  279. package/templates/app/api/v1/billing/cancel/route.ts +15 -14
  280. package/templates/app/api/v1/billing/change-plan/route.ts +10 -9
  281. package/templates/app/api/v1/billing/check-action/route.ts +8 -7
  282. package/templates/app/api/v1/billing/checkout/route.ts +10 -9
  283. package/templates/app/api/v1/billing/plans/route.ts +5 -4
  284. package/templates/app/api/v1/billing/portal/route.ts +9 -8
  285. package/templates/app/api/v1/blocks/[slug]/route.ts +4 -3
  286. package/templates/app/api/v1/blocks/route.ts +3 -2
  287. package/templates/app/api/v1/blocks/validate/route.ts +5 -3
  288. package/templates/app/api/v1/cron/process/route.ts +4 -6
  289. package/templates/app/api/v1/devtools/blocks/route.ts +3 -2
  290. package/templates/app/api/v1/devtools/docs/route.ts +3 -2
  291. package/templates/app/api/v1/devtools/features/route.ts +3 -2
  292. package/templates/app/api/v1/devtools/flows/route.ts +3 -2
  293. package/templates/app/api/v1/devtools/scheduled-actions/route.ts +125 -3
  294. package/templates/app/api/v1/devtools/scheduled-actions/run/route.ts +110 -0
  295. package/templates/app/api/v1/devtools/testing/route.ts +3 -2
  296. package/templates/app/api/v1/media/[id]/route.ts +144 -0
  297. package/templates/app/api/v1/media/[id]/tags/route.ts +154 -0
  298. package/templates/app/api/v1/media/check-duplicates/route.ts +56 -0
  299. package/templates/app/api/v1/media/route.ts +56 -0
  300. package/templates/app/api/v1/media/upload/route.ts +157 -33
  301. package/templates/app/api/v1/media-tags/route.ts +65 -0
  302. package/templates/app/api/v1/plugin/[...path]/route.ts +16 -15
  303. package/templates/app/api/v1/plugin/route.ts +3 -2
  304. package/templates/app/api/v1/post-categories/[id]/route.ts +10 -9
  305. package/templates/app/api/v1/post-categories/route.ts +5 -4
  306. package/templates/app/api/v1/team-invitations/[token]/accept/route.ts +3 -3
  307. package/templates/app/api/v1/team-invitations/[token]/decline/route.ts +3 -3
  308. package/templates/app/api/v1/team-invitations/[token]/route.ts +3 -2
  309. package/templates/app/api/v1/team-invitations/route.ts +3 -2
  310. package/templates/app/api/v1/teams/[teamId]/invitations/route.ts +5 -4
  311. package/templates/app/api/v1/teams/[teamId]/invoices/[invoiceNumber]/route.ts +3 -2
  312. package/templates/app/api/v1/teams/[teamId]/invoices/route.ts +3 -2
  313. package/templates/app/api/v1/teams/[teamId]/members/[memberId]/route.ts +5 -4
  314. package/templates/app/api/v1/teams/[teamId]/members/route.ts +5 -5
  315. package/templates/app/api/v1/teams/[teamId]/route.ts +31 -58
  316. package/templates/app/api/v1/teams/[teamId]/subscription/route.ts +3 -2
  317. package/templates/app/api/v1/teams/[teamId]/usage/[limitSlug]/route.ts +5 -4
  318. package/templates/app/api/v1/teams/route.ts +18 -17
  319. package/templates/app/api/v1/teams/switch/route.ts +3 -2
  320. package/templates/app/api/v1/theme/[...path]/route.ts +16 -15
  321. package/templates/app/api/v1/theme/route.ts +3 -2
  322. package/templates/app/api/v1/users/[id]/meta/[key]/route.ts +7 -6
  323. package/templates/app/api/v1/users/[id]/route.ts +9 -8
  324. package/templates/app/api/v1/users/route.ts +7 -6
  325. package/templates/app/dashboard/(main)/media/page.tsx +607 -0
  326. package/templates/contents/themes/starter/messages/de/dev.json +106 -0
  327. package/templates/contents/themes/starter/messages/de/index.ts +2 -0
  328. package/templates/contents/themes/starter/messages/en/dev.json +106 -0
  329. package/templates/contents/themes/starter/messages/en/index.ts +2 -0
  330. package/templates/contents/themes/starter/messages/es/dev.json +106 -0
  331. package/templates/contents/themes/starter/messages/es/index.ts +2 -0
  332. package/templates/contents/themes/starter/messages/fr/dev.json +106 -0
  333. package/templates/contents/themes/starter/messages/fr/index.ts +2 -0
  334. package/templates/contents/themes/starter/messages/it/dev.json +106 -0
  335. package/templates/contents/themes/starter/messages/it/index.ts +2 -0
  336. package/templates/contents/themes/starter/messages/pt/dev.json +106 -0
  337. package/templates/contents/themes/starter/messages/pt/index.ts +2 -0
  338. package/templates/contents/themes/starter/styles/globals.css +14 -0
  339. package/templates/instrumentation.ts +33 -0
  340. package/dist/presets/plugin/.env.example.template +0 -19
  341. package/dist/presets/plugin/entities/.gitkeep +0 -18
  342. package/dist/presets/theme/blocks/.gitkeep +0 -17
  343. package/dist/presets/theme/public/brand/.gitkeep +0 -8
  344. package/dist/presets/theme/tests/cypress/.gitkeep +0 -10
  345. package/dist/templates/contents/plugins/starter/plugin/.env.example.template +0 -19
  346. package/templates/contents/plugins/starter/plugin/.env.example.template +0 -19
@@ -1,6 +1,13 @@
1
- import { auth } from "@nextsparkjs/core/lib/auth";
1
+ import { getTypedSession } from "@nextsparkjs/core/lib/auth";
2
2
  import { NextResponse } from "next/server";
3
- import { ENTITY_REGISTRY } from "@nextsparkjs/registries/entity-registry";
3
+ import { getEntityRegistry } from "@nextsparkjs/core/lib/entities/queries";
4
+ import type { EntityConfig, ChildEntityDefinition } from "@nextsparkjs/core/lib/entities/types";
5
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit';
6
+
7
+ // Type guard to check if entity is a full EntityConfig
8
+ function isEntityConfig(entity: EntityConfig | ChildEntityDefinition): entity is EntityConfig {
9
+ return 'slug' in entity
10
+ }
4
11
 
5
12
  /**
6
13
  * Entity information structure
@@ -23,11 +30,8 @@ interface EntityInfo {
23
30
  label?: string;
24
31
  required?: boolean;
25
32
  }[];
26
- // Permissions are now optional in entity config (centralized in permissions.config.ts)
27
- permissions?: {
28
- actions: Array<{ action: string; label: string; description?: string }>;
29
- customActions?: Array<{ action: string; label: string; description?: string }>;
30
- };
33
+ // Note: Permissions are now defined centrally in permissions.config.ts
34
+ // Use PermissionService to query entity permissions
31
35
  }
32
36
 
33
37
  /**
@@ -36,10 +40,10 @@ interface EntityInfo {
36
40
  * Returns entity registry information
37
41
  * Only accessible to developer role
38
42
  */
39
- export async function GET(request: Request) {
43
+ export const GET = withRateLimitTier(async (request: Request) => {
40
44
  try {
41
45
  // Verify developer role
42
- const session = await auth.api.getSession({ headers: request.headers });
46
+ const session = await getTypedSession(request.headers);
43
47
 
44
48
  if (!session?.user || session.user.role !== "developer") {
45
49
  return NextResponse.json(
@@ -53,9 +57,11 @@ export async function GET(request: Request) {
53
57
 
54
58
  // Build entity info array
55
59
  const entities: EntityInfo[] = [];
60
+ const registry = getEntityRegistry();
56
61
 
57
- for (const [, entry] of Object.entries(ENTITY_REGISTRY)) {
62
+ for (const [, entry] of Object.entries(registry)) {
58
63
  const config = entry.config;
64
+ if (!isEntityConfig(config)) continue;
59
65
 
60
66
  entities.push({
61
67
  slug: config.slug,
@@ -75,6 +81,7 @@ export async function GET(request: Request) {
75
81
  label: field.label,
76
82
  required: field.required,
77
83
  })) || [],
84
+ // Note: Permissions are now centralized in permissions.config.ts
78
85
  });
79
86
  }
80
87
 
@@ -105,4 +112,4 @@ export async function GET(request: Request) {
105
112
  { status: 500 }
106
113
  );
107
114
  }
108
- }
115
+ }, 'read');
@@ -1,6 +1,7 @@
1
- import { auth } from "@nextsparkjs/core/lib/auth";
1
+ import { getTypedSession } from "@nextsparkjs/core/lib/auth";
2
2
  import { NextResponse } from "next/server";
3
3
  import { ThemeService } from "@nextsparkjs/core/lib/services/theme.service";
4
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit';
4
5
 
5
6
  /**
6
7
  * GET /api/devtools/config/theme
@@ -8,10 +9,10 @@ import { ThemeService } from "@nextsparkjs/core/lib/services/theme.service";
8
9
  * Returns current theme configuration
9
10
  * Only accessible to developer role
10
11
  */
11
- export async function GET(request: Request) {
12
+ export const GET = withRateLimitTier(async (request: Request) => {
12
13
  try {
13
14
  // Verify developer role
14
- const session = await auth.api.getSession({ headers: request.headers });
15
+ const session = await getTypedSession(request.headers);
15
16
 
16
17
  if (!session?.user || session.user.role !== "developer") {
17
18
  return NextResponse.json(
@@ -63,4 +64,4 @@ export async function GET(request: Request) {
63
64
  { status: 500 }
64
65
  );
65
66
  }
66
- }
67
+ }, 'read');
@@ -1,8 +1,9 @@
1
- import { auth } from "@nextsparkjs/core/lib/auth";
1
+ import { getTypedSession } from "@nextsparkjs/core/lib/auth";
2
2
  import { NextResponse } from "next/server";
3
3
  import { readFile, stat } from "fs/promises";
4
4
  import { join } from "path";
5
5
  import matter from "gray-matter";
6
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit';
6
7
 
7
8
  /**
8
9
  * GET /api/devtools/tests/[...path]
@@ -12,13 +13,13 @@ import matter from "gray-matter";
12
13
  *
13
14
  * @param path - Array of path segments (e.g., ['auth', 'login.md'])
14
15
  */
15
- export async function GET(
16
+ export const GET = withRateLimitTier(async (
16
17
  request: Request,
17
18
  { params }: { params: Promise<{ path: string[] }> }
18
- ) {
19
+ ) => {
19
20
  try {
20
21
  // Verify developer role
21
- const session = await auth.api.getSession({ headers: request.headers });
22
+ const session = await getTypedSession(request.headers);
22
23
 
23
24
  if (!session?.user || session.user.role !== "developer") {
24
25
  return NextResponse.json(
@@ -127,4 +128,4 @@ export async function GET(
127
128
  { status: 500 }
128
129
  );
129
130
  }
130
- }
131
+ }, 'read');
@@ -1,7 +1,8 @@
1
- import { auth } from "@nextsparkjs/core/lib/auth";
1
+ import { getTypedSession } from "@nextsparkjs/core/lib/auth";
2
2
  import { NextResponse } from "next/server";
3
3
  import { readdir, stat } from "fs/promises";
4
4
  import { join } from "path";
5
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit';
5
6
 
6
7
  /**
7
8
  * File tree node structure
@@ -58,10 +59,10 @@ async function buildFileTree(dirPath: string, basePath: string): Promise<FileTre
58
59
  * Returns file tree structure of test documentation files
59
60
  * Only accessible to developer role
60
61
  */
61
- export async function GET(request: Request) {
62
+ export const GET = withRateLimitTier(async (request: Request) => {
62
63
  try {
63
64
  // Verify developer role
64
- const session = await auth.api.getSession({ headers: request.headers });
65
+ const session = await getTypedSession(request.headers);
65
66
 
66
67
  if (!session?.user || session.user.role !== "developer") {
67
68
  return NextResponse.json(
@@ -131,4 +132,4 @@ export async function GET(request: Request) {
131
132
  { status: 500 }
132
133
  );
133
134
  }
134
- }
135
+ }, 'read');
@@ -1,11 +1,13 @@
1
1
  import { queryWithRLS } from "@nextsparkjs/core/lib/db";
2
+ import { withRateLimitTier } from "@nextsparkjs/core/lib/api/rate-limit";
3
+ import { NextResponse } from "next/server";
2
4
 
3
- export async function GET() {
5
+ export const GET = withRateLimitTier(async () => {
4
6
  try {
5
7
  // Test database connection
6
8
  await queryWithRLS('SELECT 1');
7
9
 
8
- return Response.json({
10
+ return NextResponse.json({
9
11
  status: 'healthy',
10
12
  timestamp: new Date().toISOString(),
11
13
  services: {
@@ -15,7 +17,7 @@ export async function GET() {
15
17
  });
16
18
  } catch (error) {
17
19
  console.error('Health check failed:', error);
18
- return Response.json({
20
+ return NextResponse.json({
19
21
  status: 'unhealthy',
20
22
  timestamp: new Date().toISOString(),
21
23
  error: 'Database connection failed',
@@ -25,5 +27,5 @@ export async function GET() {
25
27
  }
26
28
  }, { status: 503 });
27
29
  }
28
- }
30
+ }, 'read');
29
31
 
@@ -1,8 +1,9 @@
1
1
  import { NextRequest, NextResponse } from 'next/server'
2
2
  import { MetaService } from '@nextsparkjs/core/lib/services/meta.service'
3
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
3
4
 
4
5
  // Endpoint interno para crear metadata default después del signup
5
- export async function POST(req: NextRequest) {
6
+ export const POST = withRateLimitTier(async (req: NextRequest) => {
6
7
  try {
7
8
  const body = await req.json()
8
9
  const { userId, metadata } = body
@@ -33,4 +34,4 @@ export async function POST(req: NextRequest) {
33
34
  error: 'Internal server error'
34
35
  }, { status: 500 })
35
36
  }
36
- }
37
+ }, 'write');
@@ -1,6 +1,7 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
- import { auth } from '@nextsparkjs/core/lib/auth';
2
+ import { getTypedSession } from '@nextsparkjs/core/lib/auth';
3
3
  import { queryWithRLS } from '@nextsparkjs/core/lib/db';
4
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit';
4
5
 
5
6
  interface SubscriptionResult {
6
7
  id: string;
@@ -51,12 +52,10 @@ interface PlanDistribution {
51
52
  * Retrieves all subscriptions with stats for superadmin overview.
52
53
  * Supports filtering by status and pagination.
53
54
  */
54
- export async function GET(request: NextRequest) {
55
+ export const GET = withRateLimitTier(async (request: NextRequest) => {
55
56
  try {
56
57
  // Get the current session using Better Auth
57
- const session = await auth.api.getSession({
58
- headers: request.headers
59
- });
58
+ const session = await getTypedSession(request.headers);
60
59
 
61
60
  // Check if user is authenticated
62
61
  if (!session?.user) {
@@ -307,4 +306,4 @@ export async function GET(request: NextRequest) {
307
306
  { status: 500 }
308
307
  );
309
308
  }
310
- }
309
+ }, 'strict');
@@ -1,6 +1,7 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
- import { auth } from '@nextsparkjs/core/lib/auth';
2
+ import { getTypedSession } from '@nextsparkjs/core/lib/auth';
3
3
  import { queryWithRLS } from '@nextsparkjs/core/lib/db';
4
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit';
4
5
 
5
6
  interface TeamResult {
6
7
  id: string;
@@ -62,17 +63,15 @@ interface UsageResult {
62
63
  * Retrieves a single team with owner info and members.
63
64
  * Only accessible by superadmin or developer users.
64
65
  */
65
- export async function GET(
66
+ export const GET = withRateLimitTier(async (
66
67
  request: NextRequest,
67
68
  { params }: { params: Promise<{ teamId: string }> }
68
- ) {
69
+ ) => {
69
70
  try {
70
71
  const { teamId } = await params;
71
72
 
72
73
  // Get the current session using Better Auth
73
- const session = await auth.api.getSession({
74
- headers: request.headers
75
- });
74
+ const session = await getTypedSession(request.headers);
76
75
 
77
76
  // Check if user is authenticated
78
77
  if (!session?.user) {
@@ -283,4 +282,4 @@ export async function GET(
283
282
  { status: 500 }
284
283
  );
285
284
  }
286
- }
285
+ }, 'strict');
@@ -1,7 +1,8 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
- import { auth } from '@nextsparkjs/core/lib/auth';
2
+ import { getTypedSession } from '@nextsparkjs/core/lib/auth';
3
3
  import { queryWithRLS } from '@nextsparkjs/core/lib/db';
4
4
  import { SYSTEM_ADMIN_TEAM_ID } from '@nextsparkjs/core/lib/api/auth/dual-auth';
5
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit';
5
6
 
6
7
  interface TeamWithStats {
7
8
  id: string;
@@ -31,12 +32,10 @@ interface TeamWithStats {
31
32
  * - counts: Object with team counts
32
33
  * - pagination: Pagination info
33
34
  */
34
- export async function GET(request: NextRequest) {
35
+ export const GET = withRateLimitTier(async (request: NextRequest) => {
35
36
  try {
36
37
  // Get the current session using Better Auth
37
- const session = await auth.api.getSession({
38
- headers: request.headers
39
- });
38
+ const session = await getTypedSession(request.headers);
40
39
 
41
40
  // Check if user is authenticated
42
41
  if (!session?.user) {
@@ -185,4 +184,4 @@ export async function GET(request: NextRequest) {
185
184
  { status: 500 }
186
185
  );
187
186
  }
188
- }
187
+ }, 'strict');
@@ -1,6 +1,7 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
- import { auth } from '@nextsparkjs/core/lib/auth';
2
+ import { getTypedSession } from '@nextsparkjs/core/lib/auth';
3
3
  import { queryWithRLS } from '@nextsparkjs/core/lib/db';
4
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit';
4
5
 
5
6
  interface UserResult {
6
7
  id: string;
@@ -46,12 +47,10 @@ interface RouteParams {
46
47
  * - teams: Array of team memberships
47
48
  * - stats: User statistics
48
49
  */
49
- export async function GET(request: NextRequest, { params }: RouteParams) {
50
+ export const GET = withRateLimitTier(async (request: NextRequest, { params }: RouteParams) => {
50
51
  try {
51
52
  // Get the current session using Better Auth
52
- const session = await auth.api.getSession({
53
- headers: request.headers
54
- });
53
+ const session = await getTypedSession(request.headers);
55
54
 
56
55
  // Check if user is authenticated
57
56
  if (!session?.user) {
@@ -214,7 +213,7 @@ export async function GET(request: NextRequest, { params }: RouteParams) {
214
213
  { status: 500 }
215
214
  );
216
215
  }
217
- }
216
+ }, 'strict');
218
217
 
219
218
  interface UserActionBody {
220
219
  action: 'change-role' | 'suspend' | 'unsuspend' | 'verify-email';
@@ -233,12 +232,10 @@ interface UserActionBody {
233
232
  * - unsuspend: Restore user's role to 'member'
234
233
  * - verify-email: Manually verify user's email
235
234
  */
236
- export async function PATCH(request: NextRequest, { params }: RouteParams) {
235
+ export const PATCH = withRateLimitTier(async (request: NextRequest, { params }: RouteParams) => {
237
236
  try {
238
237
  // Get the current session using Better Auth
239
- const session = await auth.api.getSession({
240
- headers: request.headers
241
- });
238
+ const session = await getTypedSession(request.headers);
242
239
 
243
240
  // Check if user is authenticated
244
241
  if (!session?.user) {
@@ -394,7 +391,7 @@ export async function PATCH(request: NextRequest, { params }: RouteParams) {
394
391
  { status: 500 }
395
392
  );
396
393
  }
397
- }
394
+ }, 'strict');
398
395
 
399
396
  /**
400
397
  * DELETE /api/superadmin/users/[userId]
@@ -407,12 +404,10 @@ export async function PATCH(request: NextRequest, { params }: RouteParams) {
407
404
  * - Delete user's personal team
408
405
  * - Delete the user account
409
406
  */
410
- export async function DELETE(request: NextRequest, { params }: RouteParams) {
407
+ export const DELETE = withRateLimitTier(async (request: NextRequest, { params }: RouteParams) => {
411
408
  try {
412
409
  // Get the current session using Better Auth
413
- const session = await auth.api.getSession({
414
- headers: request.headers
415
- });
410
+ const session = await getTypedSession(request.headers);
416
411
 
417
412
  // Check if user is authenticated
418
413
  if (!session?.user) {
@@ -537,4 +532,4 @@ export async function DELETE(request: NextRequest, { params }: RouteParams) {
537
532
  { status: 500 }
538
533
  );
539
534
  }
540
- }
535
+ }, 'strict');
@@ -1,7 +1,8 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
- import { auth } from '@nextsparkjs/core/lib/auth';
2
+ import { getTypedSession } from '@nextsparkjs/core/lib/auth';
3
3
  import { queryWithRLS } from '@nextsparkjs/core/lib/db';
4
4
  import type { User } from '@nextsparkjs/core/types/user.types';
5
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit';
5
6
 
6
7
  /**
7
8
  * GET /api/superadmin/users
@@ -23,12 +24,10 @@ import type { User } from '@nextsparkjs/core/types/user.types';
23
24
  * - counts: Object with user counts
24
25
  * - pagination: Pagination info for the active tab
25
26
  */
26
- export async function GET(request: NextRequest) {
27
+ export const GET = withRateLimitTier(async (request: NextRequest) => {
27
28
  try {
28
29
  // Get the current session using Better Auth
29
- const session = await auth.api.getSession({
30
- headers: request.headers
31
- });
30
+ const session = await getTypedSession(request.headers);
32
31
 
33
32
  // Check if user is authenticated
34
33
  if (!session?.user) {
@@ -294,7 +293,7 @@ export async function GET(request: NextRequest) {
294
293
  { status: 500 }
295
294
  );
296
295
  }
297
- }
296
+ }, 'strict');
298
297
 
299
298
  /**
300
299
  * POST /api/superadmin/users
@@ -302,12 +301,12 @@ export async function GET(request: NextRequest) {
302
301
  * Future endpoint for user management actions (create, update roles, etc.)
303
302
  * Currently returns not implemented.
304
303
  */
305
- export async function POST() {
304
+ export const POST = withRateLimitTier(async () => {
306
305
  return NextResponse.json(
307
306
  { error: 'Not implemented yet' },
308
307
  { status: 501 }
309
308
  );
310
- }
309
+ }, 'strict');
311
310
 
312
311
  /**
313
312
  * PUT /api/superadmin/users
@@ -315,9 +314,9 @@ export async function POST() {
315
314
  * Future endpoint for bulk user operations
316
315
  * Currently returns not implemented.
317
316
  */
318
- export async function PUT() {
317
+ export const PUT = withRateLimitTier(async () => {
319
318
  return NextResponse.json(
320
319
  { error: 'Not implemented yet' },
321
320
  { status: 501 }
322
321
  );
323
- }
322
+ }, 'strict');
@@ -1,8 +1,9 @@
1
1
  import { NextRequest, NextResponse } from "next/server";
2
2
  import { auth } from "@nextsparkjs/core/lib/auth";
3
3
  import { mutateWithRLS } from "@nextsparkjs/core/lib/db";
4
+ import { withRateLimitTier } from "@nextsparkjs/core/lib/api/rate-limit";
4
5
 
5
- export async function DELETE(req: NextRequest) {
6
+ export const DELETE = withRateLimitTier(async (req: NextRequest) => {
6
7
  try {
7
8
  // Get session from Better Auth
8
9
  const session = await auth.api.getSession({
@@ -52,4 +53,4 @@ export async function DELETE(req: NextRequest) {
52
53
  { status: 500 }
53
54
  );
54
55
  }
55
- }
56
+ }, 'strict');
@@ -6,10 +6,11 @@
6
6
  */
7
7
 
8
8
  import { NextRequest, NextResponse } from 'next/server'
9
- import { auth } from '@nextsparkjs/core/lib/auth'
9
+ import { getTypedSession } from '@nextsparkjs/core/lib/auth'
10
10
  import { getUserPlanAndFlags, updateUserPlan, updateUserFlags } from '@nextsparkjs/core/lib/user-data'
11
11
  import { z } from 'zod'
12
12
  import type { UserRole } from '@nextsparkjs/core/types/user.types'
13
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
13
14
 
14
15
  // Validation schemas
15
16
  const planFlagsQuerySchema = z.object({
@@ -26,12 +27,10 @@ const planFlagsUpdateSchema = z.object({
26
27
  * GET /api/user/plan-flags
27
28
  * Fetch user plan and flags data
28
29
  */
29
- export async function GET(request: NextRequest) {
30
+ export const GET = withRateLimitTier(async (request: NextRequest) => {
30
31
  try {
31
32
  // Get session
32
- const session = await auth.api.getSession({
33
- headers: request.headers,
34
- })
33
+ const session = await getTypedSession(request.headers)
35
34
 
36
35
  if (!session) {
37
36
  return NextResponse.json(
@@ -84,18 +83,16 @@ export async function GET(request: NextRequest) {
84
83
  { status: 500 }
85
84
  )
86
85
  }
87
- }
86
+ }, 'read');
88
87
 
89
88
  /**
90
89
  * PATCH /api/user/plan-flags
91
90
  * Update user plan and/or flags
92
91
  */
93
- export async function PATCH(request: NextRequest) {
92
+ export const PATCH = withRateLimitTier(async (request: NextRequest) => {
94
93
  try {
95
94
  // Get session
96
- const session = await auth.api.getSession({
97
- headers: request.headers,
98
- })
95
+ const session = await getTypedSession(request.headers)
99
96
 
100
97
  if (!session) {
101
98
  return NextResponse.json(
@@ -121,14 +118,6 @@ export async function PATCH(request: NextRequest) {
121
118
  const userRole = session.user.role as UserRole
122
119
 
123
120
  // Security check: users can only update their own data unless admin
124
- if (userId !== session.user.id && !['admin', 'superadmin'].includes(userRole)) {
125
- return NextResponse.json(
126
- { error: 'Permission denied' },
127
- { status: 403 }
128
- )
129
- }
130
-
131
- // Additional security: only admins can update other users' data
132
121
  if (userId !== session.user.id && !['admin', 'superadmin'].includes(userRole)) {
133
122
  return NextResponse.json(
134
123
  { error: 'Only admins can update other users data' },
@@ -180,18 +169,16 @@ export async function PATCH(request: NextRequest) {
180
169
  { status: 500 }
181
170
  )
182
171
  }
183
- }
172
+ }, 'write');
184
173
 
185
174
  /**
186
175
  * POST /api/user/plan-flags/bulk
187
176
  * Bulk update user plans and flags (admin only)
188
177
  */
189
- export async function POST(request: NextRequest) {
178
+ export const POST = withRateLimitTier(async (request: NextRequest) => {
190
179
  try {
191
180
  // Get session
192
- const session = await auth.api.getSession({
193
- headers: request.headers,
194
- })
181
+ const session = await getTypedSession(request.headers)
195
182
 
196
183
  if (!session) {
197
184
  return NextResponse.json(
@@ -280,4 +267,4 @@ export async function POST(request: NextRequest) {
280
267
  { status: 500 }
281
268
  )
282
269
  }
283
- }
270
+ }, 'strict');
@@ -1,11 +1,12 @@
1
- import { NextResponse } from 'next/server'
1
+ import { NextRequest, NextResponse } from 'next/server'
2
2
  import { auth } from '@nextsparkjs/core/lib/auth'
3
3
  import { headers } from 'next/headers'
4
4
  import { queryOneWithRLS, mutateWithRLS, queryOne } from '@nextsparkjs/core/lib/db'
5
5
  import { profileSchema } from '@nextsparkjs/core/lib/validation'
6
6
  import { MetaService } from '@nextsparkjs/core/lib/services/meta.service'
7
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
7
8
 
8
- export async function GET(request: Request) {
9
+ export const GET = withRateLimitTier(async (request: NextRequest) => {
9
10
  const url = new URL(request.url)
10
11
  const includeMeta = url.searchParams.get('includeMeta') === 'true'
11
12
  try {
@@ -53,9 +54,9 @@ export async function GET(request: Request) {
53
54
  console.error('Error fetching user profile:', error)
54
55
  return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
55
56
  }
56
- }
57
+ }, 'read');
57
58
 
58
- export async function PATCH(request: Request) {
59
+ export const PATCH = withRateLimitTier(async (request: NextRequest) => {
59
60
  try {
60
61
  const sessionHeaders = await headers()
61
62
  const session = await auth.api.getSession({ headers: sessionHeaders })
@@ -122,7 +123,7 @@ export async function PATCH(request: Request) {
122
123
  }
123
124
  }
124
125
 
125
- return NextResponse.json({
126
+ return NextResponse.json({
126
127
  message: 'Profile updated successfully',
127
128
  success: true
128
129
  })
@@ -130,4 +131,4 @@ export async function PATCH(request: Request) {
130
131
  console.error('Error updating user profile:', error)
131
132
  return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
132
133
  }
133
- }
134
+ }, 'write');