@nextsparkjs/core 0.1.0-beta.188 → 0.1.0-beta.189

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 (412) hide show
  1. package/dist/components/api/keys/ApiKeyDisplay.js +19 -19
  2. package/dist/components/api/keys/CreateApiKeyDialog.js +21 -21
  3. package/dist/components/app/layouts/PublicNavbar.d.ts.map +1 -1
  4. package/dist/components/app/layouts/PublicNavbar.js +34 -16
  5. package/dist/components/app/misc/ThemeToggle.d.ts.map +1 -1
  6. package/dist/components/app/misc/ThemeToggle.js +3 -4
  7. package/dist/components/auth/SessionCookieRefresher.d.ts +5 -0
  8. package/dist/components/auth/SessionCookieRefresher.d.ts.map +1 -1
  9. package/dist/components/auth/SessionCookieRefresher.js +7 -1
  10. package/dist/components/auth/forms/LoginForm.d.ts.map +1 -1
  11. package/dist/components/auth/forms/LoginForm.js +49 -12
  12. package/dist/components/auth/forms/SignupForm.d.ts.map +1 -1
  13. package/dist/components/auth/forms/SignupForm.js +4 -3
  14. package/dist/components/dashboard/block-editor/block-settings-panel.js +1 -1
  15. package/dist/components/dashboard/block-editor/floating-block-toolbar.js +1 -1
  16. package/dist/components/dashboard/block-editor/sortable-block.js +1 -1
  17. package/dist/components/dashboard/layouts/Sidebar.d.ts.map +1 -1
  18. package/dist/components/dashboard/layouts/Sidebar.js +8 -6
  19. package/dist/components/dashboard/layouts/TopNavbar.d.ts.map +1 -1
  20. package/dist/components/dashboard/layouts/TopNavbar.js +51 -54
  21. package/dist/components/dashboard/misc/NotificationsDropdown.d.ts.map +1 -1
  22. package/dist/components/dashboard/misc/NotificationsDropdown.js +17 -15
  23. package/dist/components/dashboard/misc/SearchDropdown.d.ts.map +1 -1
  24. package/dist/components/dashboard/misc/SearchDropdown.js +19 -22
  25. package/dist/components/dashboard/mobile/MobileBottomNav.js +1 -1
  26. package/dist/components/dashboard/mobile/MobileTopBar.js +2 -2
  27. package/dist/components/dashboard/navigation/DynamicNavigation.js +5 -5
  28. package/dist/components/devtools/BlockDetailViewer.js +1 -1
  29. package/dist/components/devtools/BlocksViewer.js +1 -1
  30. package/dist/components/entities/EntityChildManager.js +5 -5
  31. package/dist/components/entities/EntityDetailPage.d.ts.map +1 -1
  32. package/dist/components/entities/EntityDetailPage.js +16 -15
  33. package/dist/components/entities/EntityFieldRenderer.d.ts.map +1 -1
  34. package/dist/components/entities/EntityFieldRenderer.js +12 -7
  35. package/dist/components/entities/EntityPageHeader.js +5 -5
  36. package/dist/components/entities/ErrorBoundary.d.ts.map +1 -1
  37. package/dist/components/entities/ErrorBoundary.js +20 -21
  38. package/dist/components/entities/wrappers/EntityDetailWrapper.js +5 -5
  39. package/dist/components/entities/wrappers/EntityFormWrapper.js +2 -2
  40. package/dist/components/entities/wrappers/EntityListWrapper.js +3 -3
  41. package/dist/components/permissions/NoPermission.js +10 -10
  42. package/dist/components/public/pageBuilder/PageRenderer.d.ts.map +1 -1
  43. package/dist/components/public/pageBuilder/PageRenderer.js +2 -1
  44. package/dist/components/settings/SettingsPageSkeleton.js +4 -4
  45. package/dist/components/settings/layouts/SettingsSidebar.js +6 -6
  46. package/dist/components/shared/MultiSelectFilter.d.ts +3 -1
  47. package/dist/components/shared/MultiSelectFilter.d.ts.map +1 -1
  48. package/dist/components/shared/MultiSelectFilter.js +7 -3
  49. package/dist/components/shared/SearchInput.d.ts +2 -0
  50. package/dist/components/shared/SearchInput.d.ts.map +1 -1
  51. package/dist/components/shared/SearchInput.js +64 -6
  52. package/dist/components/ui/address-input.js +18 -18
  53. package/dist/components/ui/audio-upload.js +9 -9
  54. package/dist/components/ui/combobox.d.ts.map +1 -1
  55. package/dist/components/ui/combobox.js +4 -4
  56. package/dist/components/ui/country-select.d.ts.map +1 -1
  57. package/dist/components/ui/country-select.js +3 -3
  58. package/dist/components/ui/currency-select.d.ts.map +1 -1
  59. package/dist/components/ui/currency-select.js +3 -3
  60. package/dist/components/ui/dynamic-icon.d.ts.map +1 -1
  61. package/dist/components/ui/dynamic-icon.js +3 -2
  62. package/dist/components/ui/file-upload.js +7 -7
  63. package/dist/components/ui/image-upload.js +8 -8
  64. package/dist/components/ui/multi-select.d.ts +2 -1
  65. package/dist/components/ui/multi-select.d.ts.map +1 -1
  66. package/dist/components/ui/multi-select.js +4 -3
  67. package/dist/components/ui/phone-input.d.ts.map +1 -1
  68. package/dist/components/ui/phone-input.js +3 -3
  69. package/dist/components/ui/relation-display.js +1 -1
  70. package/dist/components/ui/simple-relation-select.d.ts +2 -1
  71. package/dist/components/ui/simple-relation-select.d.ts.map +1 -1
  72. package/dist/components/ui/simple-relation-select.js +7 -6
  73. package/dist/components/ui/tags-input.d.ts.map +1 -1
  74. package/dist/components/ui/tags-input.js +1 -1
  75. package/dist/components/ui/timezone-select.d.ts.map +1 -1
  76. package/dist/components/ui/timezone-select.js +3 -3
  77. package/dist/components/ui/user-display.js +4 -4
  78. package/dist/components/ui/user-select.d.ts.map +1 -1
  79. package/dist/components/ui/user-select.js +9 -9
  80. package/dist/components/ui/video-upload.js +9 -9
  81. package/dist/contexts/SubscriptionContext.d.ts.map +1 -1
  82. package/dist/contexts/SubscriptionContext.js +5 -1
  83. package/dist/contexts/TeamContext.d.ts.map +1 -1
  84. package/dist/contexts/TeamContext.js +83 -26
  85. package/dist/emails/otp-verification.d.ts.map +1 -1
  86. package/dist/emails/otp-verification.js +3 -2
  87. package/dist/hooks/useAccountPreferencesSync.d.ts +13 -0
  88. package/dist/hooks/useAccountPreferencesSync.d.ts.map +1 -0
  89. package/dist/hooks/useAccountPreferencesSync.js +95 -0
  90. package/dist/hooks/useAuth.d.ts +202 -15
  91. package/dist/hooks/useAuth.d.ts.map +1 -1
  92. package/dist/hooks/useAuth.js +49 -13
  93. package/dist/hooks/useEntityConfig.js +2 -2
  94. package/dist/hooks/useEntitySearch.js +10 -10
  95. package/dist/hooks/useNotifications.js +12 -12
  96. package/dist/hooks/usePrefetch.d.ts.map +1 -1
  97. package/dist/hooks/usePrefetch.js +6 -2
  98. package/dist/hooks/useSearch.js +15 -15
  99. package/dist/hooks/useSessionCookieRefresh.d.ts +18 -1
  100. package/dist/hooks/useSessionCookieRefresh.d.ts.map +1 -1
  101. package/dist/hooks/useSessionCookieRefresh.js +17 -4
  102. package/dist/hooks/useSessionHint.d.ts +12 -0
  103. package/dist/hooks/useSessionHint.d.ts.map +1 -0
  104. package/dist/hooks/useSessionHint.js +15 -0
  105. package/dist/hooks/useTranslationPreload.js +6 -6
  106. package/dist/i18n.d.ts +13 -0
  107. package/dist/i18n.d.ts.map +1 -1
  108. package/dist/i18n.js +2 -27
  109. package/dist/lib/actions/entity.actions.d.ts.map +1 -1
  110. package/dist/lib/actions/entity.actions.js +3 -2
  111. package/dist/lib/api/auth/dual-auth.d.ts +4 -1
  112. package/dist/lib/api/auth/dual-auth.d.ts.map +1 -1
  113. package/dist/lib/api/auth/dual-auth.js +5 -16
  114. package/dist/lib/api/entities.js +33 -33
  115. package/dist/lib/api/keys.d.ts +27 -27
  116. package/dist/lib/api/keys.js +27 -27
  117. package/dist/lib/auth/callback-url.d.ts +11 -0
  118. package/dist/lib/auth/callback-url.d.ts.map +1 -0
  119. package/dist/lib/auth/callback-url.js +14 -0
  120. package/dist/lib/auth/otp-config.d.ts +55 -0
  121. package/dist/lib/auth/otp-config.d.ts.map +1 -0
  122. package/dist/lib/auth/otp-config.js +48 -0
  123. package/dist/lib/auth/registration-helpers.d.ts.map +1 -1
  124. package/dist/lib/auth/registration-helpers.js +3 -1
  125. package/dist/lib/auth/session-hint.d.ts +31 -0
  126. package/dist/lib/auth/session-hint.d.ts.map +1 -0
  127. package/dist/lib/auth/session-hint.js +37 -0
  128. package/dist/lib/auth.d.ts.map +1 -1
  129. package/dist/lib/auth.js +6 -4
  130. package/dist/lib/blocks/loader.d.ts +3 -11
  131. package/dist/lib/blocks/loader.d.ts.map +1 -1
  132. package/dist/lib/blocks/loader.js +1 -9
  133. package/dist/lib/blocks/loader.server.d.ts +18 -0
  134. package/dist/lib/blocks/loader.server.d.ts.map +1 -0
  135. package/dist/lib/blocks/loader.server.js +11 -0
  136. package/dist/lib/blocks/sanitize-html.d.ts +31 -0
  137. package/dist/lib/blocks/sanitize-html.d.ts.map +1 -0
  138. package/dist/lib/blocks/sanitize-html.js +60 -0
  139. package/dist/lib/config/config-sync.d.ts +1 -0
  140. package/dist/lib/config/config-sync.d.ts.map +1 -1
  141. package/dist/lib/config/config-sync.js +4 -1
  142. package/dist/lib/config/types.d.ts +48 -0
  143. package/dist/lib/config/types.d.ts.map +1 -1
  144. package/dist/lib/email/types.d.ts +6 -0
  145. package/dist/lib/email/types.d.ts.map +1 -1
  146. package/dist/lib/entities/serialization.d.ts.map +1 -1
  147. package/dist/lib/entities/serialization.js +3 -6
  148. package/dist/lib/icons.d.ts +12 -0
  149. package/dist/lib/icons.d.ts.map +1 -0
  150. package/dist/lib/icons.js +30 -0
  151. package/dist/lib/locale.d.ts +25 -1
  152. package/dist/lib/locale.d.ts.map +1 -1
  153. package/dist/lib/locale.js +49 -35
  154. package/dist/lib/mcp/engine.js +1 -1
  155. package/dist/lib/mcp/errors.js +17 -17
  156. package/dist/lib/mcp/schema-builder.js +16 -16
  157. package/dist/lib/mcp/tool-generator.js +18 -18
  158. package/dist/lib/search-highlighting.d.ts +7 -0
  159. package/dist/lib/search-highlighting.d.ts.map +1 -1
  160. package/dist/lib/search-highlighting.js +6 -2
  161. package/dist/lib/selectors/core-selectors.d.ts +2 -0
  162. package/dist/lib/selectors/core-selectors.d.ts.map +1 -1
  163. package/dist/lib/selectors/domains/auth.selectors.d.ts +1 -0
  164. package/dist/lib/selectors/domains/auth.selectors.d.ts.map +1 -1
  165. package/dist/lib/selectors/domains/auth.selectors.js +1 -0
  166. package/dist/lib/selectors/domains/entities.selectors.d.ts +2 -0
  167. package/dist/lib/selectors/domains/entities.selectors.d.ts.map +1 -1
  168. package/dist/lib/selectors/domains/entities.selectors.js +2 -0
  169. package/dist/lib/selectors/selectors.d.ts +4 -0
  170. package/dist/lib/selectors/selectors.d.ts.map +1 -1
  171. package/dist/lib/services/block.service.js +1 -1
  172. package/dist/lib/teams/active-team-cookie.d.ts +24 -0
  173. package/dist/lib/teams/active-team-cookie.d.ts.map +1 -0
  174. package/dist/lib/teams/active-team-cookie.js +17 -0
  175. package/dist/lib/teams/dashboard-team.d.ts +20 -0
  176. package/dist/lib/teams/dashboard-team.d.ts.map +1 -0
  177. package/dist/lib/teams/dashboard-team.js +38 -0
  178. package/dist/lib/teams/schema.d.ts.map +1 -1
  179. package/dist/lib/teams/schema.js +1 -1
  180. package/dist/lib/template-resolver.d.ts.map +1 -1
  181. package/dist/lib/template-resolver.js +0 -1
  182. package/dist/lib/theme/get-default-theme-mode.d.ts +7 -4
  183. package/dist/lib/theme/get-default-theme-mode.d.ts.map +1 -1
  184. package/dist/lib/theme/get-default-theme-mode.js +2 -44
  185. package/dist/messages/de/auth.json +4 -2
  186. package/dist/messages/de/common.json +83 -3
  187. package/dist/messages/de/email.json +1 -1
  188. package/dist/messages/de/index.d.ts +87 -0
  189. package/dist/messages/de/index.d.ts.map +1 -1
  190. package/dist/messages/de/settings.json +5 -0
  191. package/dist/messages/en/auth.json +4 -2
  192. package/dist/messages/en/common.json +83 -3
  193. package/dist/messages/en/email.json +1 -1
  194. package/dist/messages/en/index.d.ts +86 -0
  195. package/dist/messages/en/index.d.ts.map +1 -1
  196. package/dist/messages/en/settings.json +4 -0
  197. package/dist/messages/es/auth.json +4 -2
  198. package/dist/messages/es/common.json +83 -3
  199. package/dist/messages/es/email.json +1 -1
  200. package/dist/messages/es/index.d.ts +86 -0
  201. package/dist/messages/es/index.d.ts.map +1 -1
  202. package/dist/messages/es/settings.json +4 -0
  203. package/dist/messages/fr/auth.json +4 -2
  204. package/dist/messages/fr/common.json +83 -3
  205. package/dist/messages/fr/email.json +1 -1
  206. package/dist/messages/fr/index.d.ts +87 -0
  207. package/dist/messages/fr/index.d.ts.map +1 -1
  208. package/dist/messages/fr/settings.json +5 -0
  209. package/dist/messages/it/auth.json +4 -2
  210. package/dist/messages/it/common.json +83 -3
  211. package/dist/messages/it/email.json +1 -1
  212. package/dist/messages/it/index.d.ts +87 -0
  213. package/dist/messages/it/index.d.ts.map +1 -1
  214. package/dist/messages/it/settings.json +5 -0
  215. package/dist/messages/pt/auth.json +4 -2
  216. package/dist/messages/pt/common.json +83 -3
  217. package/dist/messages/pt/email.json +1 -1
  218. package/dist/messages/pt/index.d.ts +87 -0
  219. package/dist/messages/pt/index.d.ts.map +1 -1
  220. package/dist/messages/pt/settings.json +5 -0
  221. package/dist/nextspark-registries.d.ts +54 -0
  222. package/dist/providers/DashboardProviders.d.ts +13 -10
  223. package/dist/providers/DashboardProviders.d.ts.map +1 -1
  224. package/dist/providers/DashboardProviders.js +7 -1
  225. package/dist/templates/app/(auth)/forgot-password/page.tsx +2 -2
  226. package/dist/templates/app/(auth)/reset-password/page.tsx +6 -6
  227. package/dist/templates/app/403/page.tsx +6 -6
  228. package/dist/templates/app/api/v1/teams/switch/route.ts +24 -5
  229. package/dist/templates/app/dashboard/(main)/[entity]/layout.tsx +9 -7
  230. package/dist/templates/app/dashboard/(main)/layout.tsx +4 -3
  231. package/dist/templates/app/dashboard/settings/api-keys/page.tsx +36 -34
  232. package/dist/templates/app/dashboard/settings/profile/page.tsx +7 -6
  233. package/dist/templates/app/dashboard/settings/security/page.tsx +5 -4
  234. package/dist/templates/app/layout.ppr.tsx +8 -8
  235. package/dist/templates/app/layout.tsx +12 -17
  236. package/dist/templates/blocks/cta-section/component.tsx +5 -2
  237. package/dist/templates/blocks/cta-section/config.ts +3 -2
  238. package/dist/templates/blocks/cta-section/fields.ts +2 -2
  239. package/dist/templates/blocks/cta-section/schema.ts +2 -2
  240. package/dist/templates/blocks/features-grid/component.tsx +10 -2
  241. package/dist/templates/blocks/features-grid/config.ts +3 -2
  242. package/dist/templates/blocks/features-grid/fields.ts +2 -2
  243. package/dist/templates/blocks/features-grid/schema.ts +2 -2
  244. package/dist/templates/blocks/hero/component.tsx +6 -3
  245. package/dist/templates/blocks/hero/config.ts +3 -2
  246. package/dist/templates/blocks/hero/fields.ts +2 -2
  247. package/dist/templates/blocks/hero/schema.ts +2 -2
  248. package/dist/templates/blocks/testimonials/component.tsx +6 -3
  249. package/dist/templates/blocks/testimonials/config.ts +3 -2
  250. package/dist/templates/blocks/testimonials/fields.ts +2 -2
  251. package/dist/templates/blocks/testimonials/schema.ts +2 -2
  252. package/dist/templates/blocks/text-content/component.tsx +7 -3
  253. package/dist/templates/blocks/text-content/config.ts +3 -2
  254. package/dist/templates/blocks/text-content/fields.ts +2 -2
  255. package/dist/templates/blocks/text-content/schema.ts +2 -2
  256. package/dist/templates/contents/themes/starter/blocks/cta-section/component.tsx +102 -0
  257. package/dist/templates/contents/themes/starter/blocks/cta-section/config.ts +11 -0
  258. package/dist/templates/contents/themes/starter/blocks/cta-section/fields.ts +89 -0
  259. package/dist/templates/contents/themes/starter/blocks/cta-section/index.ts +6 -0
  260. package/dist/templates/contents/themes/starter/blocks/cta-section/schema.ts +32 -0
  261. package/dist/templates/contents/themes/starter/blocks/cta-section/thumbnail.png +0 -0
  262. package/dist/templates/contents/themes/starter/blocks/features-grid/component.tsx +119 -0
  263. package/dist/templates/contents/themes/starter/blocks/features-grid/config.ts +11 -0
  264. package/dist/templates/contents/themes/starter/blocks/features-grid/fields.ts +97 -0
  265. package/dist/templates/contents/themes/starter/blocks/features-grid/index.ts +6 -0
  266. package/dist/templates/contents/themes/starter/blocks/features-grid/schema.ts +40 -0
  267. package/dist/templates/contents/themes/starter/blocks/features-grid/thumbnail.png +0 -0
  268. package/dist/templates/contents/themes/starter/blocks/hero/component.tsx +105 -0
  269. package/dist/templates/contents/themes/starter/blocks/hero/config.ts +11 -0
  270. package/dist/templates/contents/themes/starter/blocks/hero/fields.ts +60 -0
  271. package/dist/templates/contents/themes/starter/blocks/hero/index.ts +6 -0
  272. package/dist/templates/contents/themes/starter/blocks/hero/schema.ts +33 -0
  273. package/dist/templates/contents/themes/starter/blocks/hero/thumbnail.png +0 -0
  274. package/dist/templates/contents/themes/starter/blocks/testimonials/component.tsx +116 -0
  275. package/dist/templates/contents/themes/starter/blocks/testimonials/config.ts +11 -0
  276. package/dist/templates/contents/themes/starter/blocks/testimonials/fields.ts +105 -0
  277. package/dist/templates/contents/themes/starter/blocks/testimonials/index.ts +6 -0
  278. package/dist/templates/contents/themes/starter/blocks/testimonials/schema.ts +41 -0
  279. package/dist/templates/contents/themes/starter/blocks/testimonials/thumbnail.png +0 -0
  280. package/dist/templates/contents/themes/starter/blocks/text-content/component.tsx +100 -0
  281. package/dist/templates/contents/themes/starter/blocks/text-content/config.ts +11 -0
  282. package/dist/templates/contents/themes/starter/blocks/text-content/fields.ts +88 -0
  283. package/dist/templates/contents/themes/starter/blocks/text-content/index.ts +6 -0
  284. package/dist/templates/contents/themes/starter/blocks/text-content/schema.ts +30 -0
  285. package/dist/templates/contents/themes/starter/blocks/text-content/thumbnail.png +0 -0
  286. package/dist/templates/contents/themes/starter/config/app.config.ts +8 -0
  287. package/dist/templates/contents/themes/starter/entities/tasks/tasks.config.ts +7 -0
  288. package/dist/templates/contents/themes/starter/tests/cypress/e2e/_utils/devtools/access.cy.ts +9 -1
  289. package/dist/templates/contents/themes/starter/tests/cypress/e2e/api/entities/tasks/TaskAPIController.js +2 -2
  290. package/dist/templates/contents/themes/starter/tests/cypress/e2e/uat/entities/tasks/tasks-crud.cy.ts +45 -38
  291. package/dist/templates/contents/themes/starter/tests/cypress/fixtures/entities.json +16 -0
  292. package/dist/templates/contents/themes/starter/tests/cypress/src/components/DevKeyringPOM.ts +3 -1
  293. package/dist/templates/contents/themes/starter/tests/cypress/src/core/BlockEditorBasePOM.ts +3 -3
  294. package/dist/templates/contents/themes/starter/tests/cypress/src/entities/PagesPOM.ts +137 -0
  295. package/dist/templates/contents/themes/starter/tests/cypress/src/entities/index.ts +2 -0
  296. package/dist/templates/contents/themes/starter/tests/cypress/src/index.ts +1 -0
  297. package/dist/templates/contents/themes/starter/tests/cypress/src/session-helpers.ts +42 -11
  298. package/dist/templates/contents/themes/starter/tests/cypress/support/commands.ts +29 -18
  299. package/dist/templates/features/blog/blocks/post-content/component.tsx +5 -1
  300. package/dist/templates/features/blog/blocks/post-content/schema.ts +1 -1
  301. package/dist/templates/features/pages/blocks/hero/component.tsx +3 -0
  302. package/dist/templates/features/pages/blocks/hero/schema.ts +1 -1
  303. package/dist/templates/proxy.ts +138 -53
  304. package/dist/types/blocks.d.ts.map +1 -1
  305. package/dist/types/blocks.js +1 -1
  306. package/dist/types/task.types.d.ts +1 -1
  307. package/dist/types/task.types.js +7 -7
  308. package/dist/utils/dev/TranslationDebugger.js +2 -2
  309. package/package.json +14 -5
  310. package/scripts/build/registry/__tests__/block-registry.test.mjs +73 -0
  311. package/scripts/build/registry/__tests__/icons-discovery.test.mjs +130 -0
  312. package/scripts/build/registry/__tests__/identifier.test.mjs +65 -0
  313. package/scripts/build/registry/__tests__/page-generator.test.mjs +430 -0
  314. package/scripts/build/registry/__tests__/scheduled-actions-registry.test.mjs +41 -0
  315. package/scripts/build/registry/__tests__/template-registry.test.mjs +89 -0
  316. package/scripts/build/registry/discovery/icons.mjs +275 -0
  317. package/scripts/build/registry/discovery/index.mjs +1 -0
  318. package/scripts/build/registry/generators/block-registry.mjs +203 -55
  319. package/scripts/build/registry/generators/feature-registry.mjs +9 -2
  320. package/scripts/build/registry/generators/icon-registry.mjs +56 -0
  321. package/scripts/build/registry/generators/identifier.mjs +28 -0
  322. package/scripts/build/registry/generators/index.mjs +1 -0
  323. package/scripts/build/registry/generators/plugin-registry.mjs +4 -3
  324. package/scripts/build/registry/generators/scheduled-actions-registry.mjs +4 -2
  325. package/scripts/build/registry/generators/template-registry.mjs +49 -41
  326. package/scripts/build/registry/generators/theme-registry.mjs +6 -7
  327. package/scripts/build/registry/post-build/page-generator.mjs +380 -59
  328. package/scripts/build/registry.mjs +9 -1
  329. package/templates/app/(auth)/forgot-password/page.tsx +2 -2
  330. package/templates/app/(auth)/reset-password/page.tsx +6 -6
  331. package/templates/app/403/page.tsx +6 -6
  332. package/templates/app/api/v1/teams/switch/route.ts +24 -5
  333. package/templates/app/dashboard/(main)/[entity]/layout.tsx +9 -7
  334. package/templates/app/dashboard/(main)/layout.tsx +4 -3
  335. package/templates/app/dashboard/settings/api-keys/page.tsx +36 -34
  336. package/templates/app/dashboard/settings/profile/page.tsx +7 -6
  337. package/templates/app/dashboard/settings/security/page.tsx +5 -4
  338. package/templates/app/layout.ppr.tsx +8 -8
  339. package/templates/app/layout.tsx +12 -17
  340. package/templates/blocks/cta-section/component.tsx +5 -2
  341. package/templates/blocks/cta-section/config.ts +3 -2
  342. package/templates/blocks/cta-section/fields.ts +2 -2
  343. package/templates/blocks/cta-section/schema.ts +2 -2
  344. package/templates/blocks/features-grid/component.tsx +10 -2
  345. package/templates/blocks/features-grid/config.ts +3 -2
  346. package/templates/blocks/features-grid/fields.ts +2 -2
  347. package/templates/blocks/features-grid/schema.ts +2 -2
  348. package/templates/blocks/hero/component.tsx +6 -3
  349. package/templates/blocks/hero/config.ts +3 -2
  350. package/templates/blocks/hero/fields.ts +2 -2
  351. package/templates/blocks/hero/schema.ts +2 -2
  352. package/templates/blocks/testimonials/component.tsx +6 -3
  353. package/templates/blocks/testimonials/config.ts +3 -2
  354. package/templates/blocks/testimonials/fields.ts +2 -2
  355. package/templates/blocks/testimonials/schema.ts +2 -2
  356. package/templates/blocks/text-content/component.tsx +7 -3
  357. package/templates/blocks/text-content/config.ts +3 -2
  358. package/templates/blocks/text-content/fields.ts +2 -2
  359. package/templates/blocks/text-content/schema.ts +2 -2
  360. package/templates/contents/themes/starter/blocks/cta-section/component.tsx +102 -0
  361. package/templates/contents/themes/starter/blocks/cta-section/config.ts +11 -0
  362. package/templates/contents/themes/starter/blocks/cta-section/fields.ts +89 -0
  363. package/templates/contents/themes/starter/blocks/cta-section/index.ts +6 -0
  364. package/templates/contents/themes/starter/blocks/cta-section/schema.ts +32 -0
  365. package/templates/contents/themes/starter/blocks/cta-section/thumbnail.png +0 -0
  366. package/templates/contents/themes/starter/blocks/features-grid/component.tsx +119 -0
  367. package/templates/contents/themes/starter/blocks/features-grid/config.ts +11 -0
  368. package/templates/contents/themes/starter/blocks/features-grid/fields.ts +97 -0
  369. package/templates/contents/themes/starter/blocks/features-grid/index.ts +6 -0
  370. package/templates/contents/themes/starter/blocks/features-grid/schema.ts +40 -0
  371. package/templates/contents/themes/starter/blocks/features-grid/thumbnail.png +0 -0
  372. package/templates/contents/themes/starter/blocks/hero/component.tsx +105 -0
  373. package/templates/contents/themes/starter/blocks/hero/config.ts +11 -0
  374. package/templates/contents/themes/starter/blocks/hero/fields.ts +60 -0
  375. package/templates/contents/themes/starter/blocks/hero/index.ts +6 -0
  376. package/templates/contents/themes/starter/blocks/hero/schema.ts +33 -0
  377. package/templates/contents/themes/starter/blocks/hero/thumbnail.png +0 -0
  378. package/templates/contents/themes/starter/blocks/testimonials/component.tsx +116 -0
  379. package/templates/contents/themes/starter/blocks/testimonials/config.ts +11 -0
  380. package/templates/contents/themes/starter/blocks/testimonials/fields.ts +105 -0
  381. package/templates/contents/themes/starter/blocks/testimonials/index.ts +6 -0
  382. package/templates/contents/themes/starter/blocks/testimonials/schema.ts +41 -0
  383. package/templates/contents/themes/starter/blocks/testimonials/thumbnail.png +0 -0
  384. package/templates/contents/themes/starter/blocks/text-content/component.tsx +100 -0
  385. package/templates/contents/themes/starter/blocks/text-content/config.ts +11 -0
  386. package/templates/contents/themes/starter/blocks/text-content/fields.ts +88 -0
  387. package/templates/contents/themes/starter/blocks/text-content/index.ts +6 -0
  388. package/templates/contents/themes/starter/blocks/text-content/schema.ts +30 -0
  389. package/templates/contents/themes/starter/blocks/text-content/thumbnail.png +0 -0
  390. package/templates/contents/themes/starter/config/app.config.ts +8 -0
  391. package/templates/contents/themes/starter/entities/tasks/tasks.config.ts +7 -0
  392. package/templates/contents/themes/starter/tests/cypress/e2e/_utils/devtools/access.cy.ts +9 -1
  393. package/templates/contents/themes/starter/tests/cypress/e2e/api/entities/tasks/TaskAPIController.js +2 -2
  394. package/templates/contents/themes/starter/tests/cypress/e2e/uat/entities/tasks/tasks-crud.cy.ts +45 -38
  395. package/templates/contents/themes/starter/tests/cypress/fixtures/entities.json +16 -0
  396. package/templates/contents/themes/starter/tests/cypress/src/components/DevKeyringPOM.ts +3 -1
  397. package/templates/contents/themes/starter/tests/cypress/src/core/BlockEditorBasePOM.ts +3 -3
  398. package/templates/contents/themes/starter/tests/cypress/src/entities/PagesPOM.ts +137 -0
  399. package/templates/contents/themes/starter/tests/cypress/src/entities/index.ts +2 -0
  400. package/templates/contents/themes/starter/tests/cypress/src/index.ts +1 -0
  401. package/templates/contents/themes/starter/tests/cypress/src/session-helpers.ts +42 -11
  402. package/templates/contents/themes/starter/tests/cypress/support/commands.ts +29 -18
  403. package/templates/features/blog/blocks/post-content/component.tsx +5 -1
  404. package/templates/features/blog/blocks/post-content/schema.ts +1 -1
  405. package/templates/features/pages/blocks/hero/component.tsx +3 -0
  406. package/templates/features/pages/blocks/hero/schema.ts +1 -1
  407. package/templates/proxy.ts +138 -53
  408. package/tests/jest/__mocks__/@nextsparkjs/registries/block-registry.client.ts +9 -0
  409. package/tests/jest/__mocks__/@nextsparkjs/registries/block-registry.lazy.ts +5 -0
  410. package/tests/jest/__mocks__/@nextsparkjs/registries/icon-registry.ts +42 -0
  411. package/tests/jest/__mocks__/next-intl-server.js +85 -5
  412. package/tests/jest/__mocks__/next-server.js +32 -0
@@ -45,7 +45,7 @@ function useEntityConfig(entityType, options = {}) {
45
45
  const allEntities = getAllEntityConfigs();
46
46
  const foundEntity = allEntities.find((entity) => entity.slug === entityType);
47
47
  if (!foundEntity) {
48
- const error = `Entidad "${entityType}" no encontrada en el registry`;
48
+ const error = `Entity "${entityType}" not found in the registry`;
49
49
  setState({
50
50
  config: null,
51
51
  isLoading: false,
@@ -78,7 +78,7 @@ function useEntityConfig(entityType, options = {}) {
78
78
  });
79
79
  }
80
80
  } catch (err) {
81
- const error = err instanceof Error ? err.message : "Error desconocido al cargar configuraci\xF3n de entidad";
81
+ const error = err instanceof Error ? err.message : "Unknown error loading entity configuration";
82
82
  setState({
83
83
  config: null,
84
84
  isLoading: false,
@@ -35,35 +35,35 @@ function useEntitySearch() {
35
35
  {
36
36
  id: "dashboard",
37
37
  title: "Dashboard",
38
- description: "Panel principal con estad\xEDsticas y acciones r\xE1pidas",
38
+ description: "Main panel with statistics and quick actions",
39
39
  url: "/dashboard",
40
40
  category: "Navigation"
41
41
  },
42
42
  {
43
43
  id: "profile",
44
- title: "Configuraci\xF3n de Perfil",
45
- description: "Actualizar informaci\xF3n personal y preferencias",
44
+ title: "Profile Settings",
45
+ description: "Update personal information and preferences",
46
46
  url: "/dashboard/settings/profile",
47
47
  category: "Settings"
48
48
  },
49
49
  {
50
50
  id: "security",
51
- title: "Configuraci\xF3n de Seguridad",
52
- description: "Autenticaci\xF3n de dos factores y sesiones activas",
51
+ title: "Security Settings",
52
+ description: "Two-factor authentication and active sessions",
53
53
  url: "/dashboard/settings/security",
54
54
  category: "Settings"
55
55
  },
56
56
  {
57
57
  id: "notifications",
58
- title: "Configuraci\xF3n de Notificaciones",
59
- description: "Preferencias de emails y notificaciones push",
58
+ title: "Notification Settings",
59
+ description: "Email and push notification preferences",
60
60
  url: "/dashboard/settings/notifications",
61
61
  category: "Settings"
62
62
  },
63
63
  {
64
64
  id: "billing",
65
- title: "Facturaci\xF3n",
66
- description: "Planes, m\xE9todos de pago y historial de facturaci\xF3n",
65
+ title: "Billing",
66
+ description: "Plans, payment methods and billing history",
67
67
  url: "/dashboard/settings/billing",
68
68
  category: "Settings"
69
69
  }
@@ -80,7 +80,7 @@ function useEntitySearch() {
80
80
  return availableEntities.map((entity) => ({
81
81
  id: `entity-${entity.slug}`,
82
82
  title: entity.names.singular,
83
- description: `Gestionar ${entity.names.plural.toLowerCase()}`,
83
+ description: `Manage ${entity.names.plural.toLowerCase()}`,
84
84
  entityType: entity.slug,
85
85
  type: "entity",
86
86
  url: `/dashboard/${entity.slug}`,
@@ -3,8 +3,8 @@ import { useState } from "react";
3
3
  const EXAMPLE_NOTIFICATIONS = [
4
4
  {
5
5
  id: "1",
6
- title: "Bienvenido al Dashboard",
7
- message: "Tu cuenta ha sido configurada exitosamente. Explora todas las funcionalidades disponibles.",
6
+ title: "Welcome to the Dashboard",
7
+ message: "Your account has been set up successfully. Explore all the available features.",
8
8
  type: "success",
9
9
  timestamp: new Date(Date.now() - 2 * 60 * 1e3),
10
10
  // 2 minutos atrás
@@ -13,8 +13,8 @@ const EXAMPLE_NOTIFICATIONS = [
13
13
  },
14
14
  {
15
15
  id: "2",
16
- title: "Nueva tarea pendiente",
17
- message: "Tienes 3 tareas sin completar. \xBFQuieres revisarlas ahora?",
16
+ title: "New pending task",
17
+ message: "You have 3 incomplete tasks. Want to review them now?",
18
18
  type: "info",
19
19
  timestamp: new Date(Date.now() - 15 * 60 * 1e3),
20
20
  // 15 minutos atrás
@@ -23,8 +23,8 @@ const EXAMPLE_NOTIFICATIONS = [
23
23
  },
24
24
  {
25
25
  id: "3",
26
- title: "Configuraci\xF3n de seguridad",
27
- message: "Te recomendamos activar la autenticaci\xF3n de dos factores para mayor seguridad.",
26
+ title: "Security settings",
27
+ message: "We recommend enabling two-factor authentication for extra security.",
28
28
  type: "warning",
29
29
  timestamp: new Date(Date.now() - 2 * 60 * 60 * 1e3),
30
30
  // 2 horas atrás
@@ -33,8 +33,8 @@ const EXAMPLE_NOTIFICATIONS = [
33
33
  },
34
34
  {
35
35
  id: "4",
36
- title: "Perfil actualizado",
37
- message: "Tu informaci\xF3n de perfil ha sido actualizada correctamente.",
36
+ title: "Profile updated",
37
+ message: "Your profile information has been updated successfully.",
38
38
  type: "success",
39
39
  timestamp: new Date(Date.now() - 24 * 60 * 60 * 1e3),
40
40
  // 1 día atrás
@@ -43,8 +43,8 @@ const EXAMPLE_NOTIFICATIONS = [
43
43
  },
44
44
  {
45
45
  id: "5",
46
- title: "Nuevo login detectado",
47
- message: "Se detect\xF3 un nuevo inicio de sesi\xF3n desde Chrome en Ciudad de M\xE9xico.",
46
+ title: "New login detected",
47
+ message: "A new sign-in was detected from Chrome in Mexico City.",
48
48
  type: "info",
49
49
  timestamp: new Date(Date.now() - 3 * 24 * 60 * 60 * 1e3),
50
50
  // 3 días atrás
@@ -52,8 +52,8 @@ const EXAMPLE_NOTIFICATIONS = [
52
52
  },
53
53
  {
54
54
  id: "6",
55
- title: "Backup completado",
56
- message: "Se ha realizado una copia de seguridad de tus datos exitosamente.",
55
+ title: "Backup completed",
56
+ message: "Your data has been backed up successfully.",
57
57
  type: "success",
58
58
  timestamp: new Date(Date.now() - 7 * 24 * 60 * 60 * 1e3),
59
59
  // 1 semana atrás
@@ -1 +1 @@
1
- {"version":3,"file":"usePrefetch.d.ts","sourceRoot":"","sources":["../../src/hooks/usePrefetch.ts"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB;;;EAuBlC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,cAgBnD"}
1
+ {"version":3,"file":"usePrefetch.d.ts","sourceRoot":"","sources":["../../src/hooks/usePrefetch.ts"],"names":[],"mappings":"AA0BA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB;;;EA0BlC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,cAgBnD"}
@@ -2,6 +2,7 @@
2
2
  import { useQueryClient } from "@tanstack/react-query";
3
3
  import { useCallback } from "react";
4
4
  import { TEAMS_QUERY_KEY, fetchUserTeams } from "../contexts/TeamContext.js";
5
+ import { useAuth } from "./useAuth.js";
5
6
  const USER_PROFILE_QUERY_KEY = ["user-profile"];
6
7
  async function fetchUserProfile() {
7
8
  const response = await fetch("/api/user/profile");
@@ -12,6 +13,7 @@ async function fetchUserProfile() {
12
13
  }
13
14
  function usePrefetchSettings() {
14
15
  const queryClient = useQueryClient();
16
+ const { user } = useAuth();
15
17
  const prefetchProfile = useCallback(() => {
16
18
  queryClient.prefetchQuery({
17
19
  queryKey: USER_PROFILE_QUERY_KEY,
@@ -21,13 +23,15 @@ function usePrefetchSettings() {
21
23
  });
22
24
  }, [queryClient]);
23
25
  const prefetchTeams = useCallback(() => {
26
+ if (!user) return;
24
27
  queryClient.prefetchQuery({
25
- queryKey: TEAMS_QUERY_KEY,
28
+ // The key TeamProvider reads: the teams of this user
29
+ queryKey: [...TEAMS_QUERY_KEY, user.id],
26
30
  queryFn: fetchUserTeams,
27
31
  staleTime: 1e3 * 60 * 5
28
32
  // 5 minutes
29
33
  });
30
- }, [queryClient]);
34
+ }, [queryClient, user]);
31
35
  return {
32
36
  prefetchProfile,
33
37
  prefetchTeams
@@ -21,11 +21,11 @@ const generateEntitySearchResults = () => {
21
21
  return {
22
22
  id: `entity-${entry.name}`,
23
23
  title: displayName,
24
- description: `Gesti\xF3n de ${((_c = (_b = config.names) == null ? void 0 : _b.plural) == null ? void 0 : _c.toLowerCase()) || displayName.toLowerCase()}`,
24
+ description: `Manage ${((_c = (_b = config.names) == null ? void 0 : _b.plural) == null ? void 0 : _c.toLowerCase()) || displayName.toLowerCase()}`,
25
25
  type: entry.name,
26
26
  // Map to specific entity types
27
27
  url: `/dashboard/${config.slug || entry.name}`,
28
- category: "Entidades",
28
+ category: "Entities",
29
29
  entityType: entry.name,
30
30
  priority: "medium"
31
31
  };
@@ -41,43 +41,43 @@ const getSearchableFields = (entityConfig) => {
41
41
  const SYSTEM_PAGES = [
42
42
  {
43
43
  title: "Dashboard",
44
- description: "Panel principal con estad\xEDsticas y acciones r\xE1pidas",
44
+ description: "Main panel with statistics and quick actions",
45
45
  type: "page",
46
46
  url: "/dashboard"
47
47
  },
48
48
  {
49
- title: "Gesti\xF3n de Tareas",
50
- description: "Crear, editar y organizar tus tareas",
49
+ title: "Task Management",
50
+ description: "Create, edit and organize your tasks",
51
51
  type: "page",
52
52
  url: "/dashboard/tasks"
53
53
  },
54
54
  {
55
- title: "Configuraci\xF3n de Perfil",
56
- description: "Actualizar informaci\xF3n personal y preferencias",
55
+ title: "Profile Settings",
56
+ description: "Update personal information and preferences",
57
57
  type: "setting",
58
58
  url: "/dashboard/settings/profile"
59
59
  },
60
60
  {
61
- title: "Configuraci\xF3n de Seguridad",
62
- description: "Autenticaci\xF3n de dos factores y sesiones activas",
61
+ title: "Security Settings",
62
+ description: "Two-factor authentication and active sessions",
63
63
  type: "setting",
64
64
  url: "/dashboard/settings/security"
65
65
  },
66
66
  {
67
- title: "Configuraci\xF3n de Notificaciones",
68
- description: "Preferencias de emails y notificaciones push",
67
+ title: "Notification Settings",
68
+ description: "Email and push notification preferences",
69
69
  type: "setting",
70
70
  url: "/dashboard/settings/notifications"
71
71
  },
72
72
  {
73
- title: "Configuraci\xF3n de Contrase\xF1a",
74
- description: "Cambiar contrase\xF1a y opciones de seguridad",
73
+ title: "Password Settings",
74
+ description: "Change password and security options",
75
75
  type: "setting",
76
76
  url: "/dashboard/settings/password"
77
77
  },
78
78
  {
79
- title: "Facturaci\xF3n",
80
- description: "Planes, m\xE9todos de pago y historial de facturaci\xF3n",
79
+ title: "Billing",
80
+ description: "Plans, payment methods and billing history",
81
81
  type: "setting",
82
82
  url: "/dashboard/settings/billing"
83
83
  }
@@ -12,6 +12,21 @@ export interface UseSessionCookieRefreshOptions {
12
12
  refreshOnMount?: boolean;
13
13
  /** Set to false to turn the hook off (e.g. on public/auth pages). Default: true. */
14
14
  enabled?: boolean;
15
+ /**
16
+ * Called with each refresh's answer: the session, or `data: null` when there is
17
+ * none. `session.isCurrent()` turns false once the hook is turned off (a
18
+ * sign-out), so work the answer starts can drop what arrives after that.
19
+ */
20
+ onRefresh?: (result: SessionRefreshResult, session: SessionRefreshContext) => void;
21
+ }
22
+ /** What `refreshSessionCookie()` answers. */
23
+ export type SessionRefreshResult = {
24
+ data?: unknown;
25
+ error?: unknown;
26
+ } | null | undefined;
27
+ /** Passed with each answer: whether the session it belongs to is still the page's. */
28
+ export interface SessionRefreshContext {
29
+ isCurrent: () => boolean;
15
30
  }
16
31
  export declare const DEFAULT_SESSION_REFRESH_INTERVAL_MS: number;
17
32
  /**
@@ -29,7 +44,9 @@ export declare const DEFAULT_SESSION_REFRESH_INTERVAL_MS: number;
29
44
  *
30
45
  * Calls are throttled by `minIntervalMs`; a failed call (offline, server
31
46
  * down) does not count towards the throttle, so the next trigger retries.
32
- * Anonymous visitors just get a cheap `null` session response.
47
+ * Anonymous visitors just get a cheap `null` session response. Turning the
48
+ * hook off (a sign-out) drops the answer of a call still on the wire, and
49
+ * turning it on again reads the session at once, whatever the throttle says.
33
50
  */
34
51
  export declare function useSessionCookieRefresh(options?: UseSessionCookieRefreshOptions): void;
35
52
  //# sourceMappingURL=useSessionCookieRefresh.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSessionCookieRefresh.d.ts","sourceRoot":"","sources":["../../src/hooks/useSessionCookieRefresh.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,oFAAoF;IACpF,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,mCAAmC,QAAgB,CAAA;AAEhE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,8BAAmC,QAmDnF"}
1
+ {"version":3,"file":"useSessionCookieRefresh.d.ts","sourceRoot":"","sources":["../../src/hooks/useSessionCookieRefresh.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,oFAAoF;IACpF,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAA;CACnF;AAED,6CAA6C;AAC7C,MAAM,MAAM,oBAAoB,GAAG;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,CAAA;AAEzF,sFAAsF;AACtF,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,OAAO,CAAA;CACzB;AAED,eAAO,MAAM,mCAAmC,QAAgB,CAAA;AAEhE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,8BAAmC,QAiEnF"}
@@ -10,20 +10,33 @@ function useSessionCookieRefresh(options = {}) {
10
10
  } = options;
11
11
  const lastRefreshAtRef = useRef(0);
12
12
  const inFlightRef = useRef(false);
13
+ const generationRef = useRef(0);
14
+ const onRefreshRef = useRef(options.onRefresh);
15
+ onRefreshRef.current = options.onRefresh;
13
16
  useEffect(() => {
14
- if (!enabled || typeof window === "undefined") return;
17
+ if (typeof window === "undefined") return;
18
+ if (!enabled) {
19
+ generationRef.current++;
20
+ inFlightRef.current = false;
21
+ lastRefreshAtRef.current = 0;
22
+ return;
23
+ }
15
24
  const refresh = async () => {
25
+ var _a;
16
26
  if (inFlightRef.current) return;
17
27
  const now = Date.now();
18
28
  if (now - lastRefreshAtRef.current < minIntervalMs) return;
29
+ const generation = generationRef.current;
30
+ const current = () => generation === generationRef.current;
19
31
  inFlightRef.current = true;
20
32
  lastRefreshAtRef.current = now;
21
33
  try {
22
- await refreshSessionCookie();
34
+ const result = await refreshSessionCookie();
35
+ if (current()) (_a = onRefreshRef.current) == null ? void 0 : _a.call(onRefreshRef, result, { isCurrent: current });
23
36
  } catch {
24
- lastRefreshAtRef.current = 0;
37
+ if (current()) lastRefreshAtRef.current = 0;
25
38
  } finally {
26
- inFlightRef.current = false;
39
+ if (current()) inFlightRef.current = false;
27
40
  }
28
41
  };
29
42
  const onVisibilityChange = () => {
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Whether this browser is signed in, as the session hint says (see
3
+ * lib/auth/session-hint), following it as it changes: a sign-in or sign-out on
4
+ * the page, or the tab coming back into view. `ready` stays false through the
5
+ * server render and hydration, which cannot read the cookie, so both render the
6
+ * same thing until the effect runs.
7
+ */
8
+ export declare function useSessionHint(): {
9
+ ready: boolean;
10
+ signedIn: boolean;
11
+ };
12
+ //# sourceMappingURL=useSessionHint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSessionHint.d.ts","sourceRoot":"","sources":["../../src/hooks/useSessionHint.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,wBAAgB,cAAc,IAAI;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAStE"}
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { useEffect, useState, useSyncExternalStore } from "react";
3
+ import { hasSessionHint, subscribeSessionHint } from "../lib/auth/session-hint.js";
4
+ const signedOutOnServer = () => false;
5
+ function useSessionHint() {
6
+ const [ready, setReady] = useState(false);
7
+ const signedIn = useSyncExternalStore(subscribeSessionHint, hasSessionHint, signedOutOnServer);
8
+ useEffect(() => {
9
+ setReady(true);
10
+ }, []);
11
+ return { ready, signedIn: ready && signedIn };
12
+ }
13
+ export {
14
+ useSessionHint
15
+ };
@@ -8,14 +8,14 @@ function useTranslationPreload(context = "auto") {
8
8
  const locale = useLocale();
9
9
  useEffect(() => {
10
10
  const preloadNamespaces = async (namespaces, contextName) => {
11
- console.log(`[TranslationPreload] \u{1F680} Iniciando precarga ${contextName} para ${locale}:`, namespaces);
11
+ console.log(`[TranslationPreload] \u{1F680} Starting ${contextName} preload for ${locale}:`, namespaces);
12
12
  const promises = namespaces.map(async (namespace) => {
13
13
  try {
14
14
  await import(`../messages/${locale}/${namespace}.json`);
15
- console.log(`[TranslationPreload] \u2713 Precargado: ${namespace}`);
15
+ console.log(`[TranslationPreload] \u2713 Preloaded: ${namespace}`);
16
16
  return { namespace, success: true };
17
17
  } catch (error) {
18
- console.warn(`[TranslationPreload] \u26A0\uFE0F Error precargando ${namespace}:`, error);
18
+ console.warn(`[TranslationPreload] \u26A0\uFE0F Error preloading ${namespace}:`, error);
19
19
  return { namespace, success: false, error };
20
20
  }
21
21
  });
@@ -23,7 +23,7 @@ function useTranslationPreload(context = "auto") {
23
23
  const successful = results.filter(
24
24
  (result) => result.status === "fulfilled" && result.value.success
25
25
  ).length;
26
- console.log(`[TranslationPreload] \u2705 Precarga ${contextName} completa: ${successful}/${namespaces.length} namespaces`);
26
+ console.log(`[TranslationPreload] \u2705 ${contextName} preload complete: ${successful}/${namespaces.length} namespaces`);
27
27
  };
28
28
  const schedulePreload = () => {
29
29
  let namespacesToLoad = [];
@@ -76,7 +76,7 @@ function useNavigationPreload() {
76
76
  } else {
77
77
  namespacesToLoad = PUBLIC_NAMESPACES;
78
78
  }
79
- console.log(`[NavigationPreload] Precargando para ${pathname}:`, namespacesToLoad);
79
+ console.log(`[NavigationPreload] Preloading for ${pathname}:`, namespacesToLoad);
80
80
  const promises = namespacesToLoad.map(
81
81
  (namespace) => import(`../messages/${locale}/${namespace}.json`).catch((error) => {
82
82
  console.warn(`[NavigationPreload] Error: ${namespace}`, error);
@@ -84,7 +84,7 @@ function useNavigationPreload() {
84
84
  })
85
85
  );
86
86
  await Promise.all(promises);
87
- console.log(`[NavigationPreload] \u2705 Listo para navegar a ${pathname}`);
87
+ console.log(`[NavigationPreload] \u2705 Ready to navigate to ${pathname}`);
88
88
  };
89
89
  return { preloadForRoute };
90
90
  }
package/dist/i18n.d.ts CHANGED
@@ -1,10 +1,23 @@
1
+ /**
2
+ * @deprecated Not used to load translations: every request gets the merged
3
+ * catalog. Kept for code that imports it.
4
+ */
1
5
  declare const NAMESPACE_GROUPS: {
2
6
  PUBLIC_INITIAL: string[];
3
7
  DASHBOARD_AUTHENTICATED: string[];
4
8
  AUTH_ONLY: string[];
5
9
  ALL: string[];
6
10
  };
11
+ /**
12
+ * @deprecated Not used to load translations: every request gets the merged
13
+ * catalog. Kept for code that imports it.
14
+ */
7
15
  declare function getPageNamespaces(pathname: string): string[];
16
+ /**
17
+ * The request config next-intl builds translations from. It reads nothing from
18
+ * the request itself: a page rendered with request data is dynamic, and the
19
+ * locale already comes from getUserLocale, resolved once per request.
20
+ */
8
21
  declare const _default: (params: import("next-intl/server").GetRequestConfigParams) => import("next-intl/server").RequestConfig | Promise<import("next-intl/server").RequestConfig>;
9
22
  export default _default;
10
23
  export { getPageNamespaces, NAMESPACE_GROUPS };
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,gBAAgB;;;;;CAYrB,CAAC;AAGF,iBAAS,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAsErD;;AAYD,wBA4DG;AAGH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC"}
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,QAAA,MAAM,gBAAgB;;;;;CAYrB,CAAC;AAEF;;;GAGG;AACH,iBAAS,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAsErD;AAYD;;;;GAIG;;AACH,wBA8BG;AAGH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC"}
package/dist/i18n.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { getRequestConfig } from "next-intl/server";
2
2
  import { I18N_CONFIG } from "./lib/config/index.js";
3
- import { headers } from "next/headers";
4
3
  import { loadMergedTranslations } from "./lib/translations/registry.js";
5
4
  import { getUserLocale } from "./lib/locale.js";
6
5
  const DEBUG_I18N = process.env.NEXTSPARK_DEBUG_I18N === "true";
@@ -67,33 +66,9 @@ async function getServerLocale() {
67
66
  return I18N_CONFIG.defaultLocale;
68
67
  }
69
68
  }
70
- var i18n_default = getRequestConfig(async () => {
71
- let locale;
69
+ var i18n_default = getRequestConfig(async ({ locale: requestedLocale }) => {
70
+ const locale = I18N_CONFIG.supportedLocales.includes(requestedLocale) ? requestedLocale : await getServerLocale();
72
71
  try {
73
- locale = await getServerLocale();
74
- } catch {
75
- locale = I18N_CONFIG.defaultLocale;
76
- }
77
- try {
78
- let pathname = "";
79
- try {
80
- const headersList = await headers();
81
- pathname = headersList.get("x-pathname") || headersList.get("x-url") || "";
82
- if (!pathname) {
83
- const referer = headersList.get("referer") || "";
84
- if (referer) {
85
- try {
86
- const url = new URL(referer);
87
- pathname = url.pathname;
88
- if (DEBUG_I18N) {
89
- console.log(`[i18n] Extracted pathname from referer: "${pathname}"`);
90
- }
91
- } catch {
92
- }
93
- }
94
- }
95
- } catch {
96
- }
97
72
  const messages = await loadMergedTranslations(locale);
98
73
  if (DEBUG_I18N) {
99
74
  console.log(`[i18n] Loaded merged translations for ${locale} with ${Object.keys(messages).length} namespaces`);
@@ -1 +1 @@
1
- {"version":3,"file":"entity.actions.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/entity.actions.ts"],"names":[],"mappings":"AA4CA,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EAElB,MAAM,SAAS,CAAA;AAqChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,YAAY,CAAC,CAAC,GAAG,OAAO,EAC5C,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,iBAAiB,EACvB,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EAAE,EAAE,MAAM,GACT,OAAO,CAAC,kBAAkB,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAsCvC;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,YAAY,CAAC,CAAC,GAAG,OAAO,EAC5C,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAoClD;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,EAAE,EACb,MAAM,CAAC,EAAE,YAAY,GACpB,OAAO,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAC,CA0DhD;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAuCtC;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAkCrC"}
@@ -1,20 +1,21 @@
1
1
  "use server";
2
2
  import { revalidatePath, revalidateTag } from "next/cache";
3
3
  import { headers, cookies } from "next/headers";
4
+ import { ACTIVE_TEAM_COOKIE, activeTeamIdForSession } from "../teams/active-team-cookie.js";
4
5
  import { redirect } from "next/navigation";
5
6
  import { GenericEntityService } from "../services/generic-entity.service.js";
6
7
  import { entityRegistry } from "../entities/registry.js";
7
8
  import { getTypedSession } from "../auth.js";
8
9
  import { checkPermission } from "../permissions/check.js";
9
10
  async function getAuthContext() {
10
- var _a, _b;
11
+ var _a, _b, _c;
11
12
  const headersList = await headers();
12
13
  const session = await getTypedSession(headersList);
13
14
  if (!((_a = session == null ? void 0 : session.user) == null ? void 0 : _a.id)) {
14
15
  return { success: false, error: "Authentication required" };
15
16
  }
16
17
  const cookieStore = await cookies();
17
- const teamId = (_b = cookieStore.get("activeTeamId")) == null ? void 0 : _b.value;
18
+ const teamId = activeTeamIdForSession((_b = cookieStore.get(ACTIVE_TEAM_COOKIE)) == null ? void 0 : _b.value, (_c = session.session) == null ? void 0 : _c.id);
18
19
  if (!teamId) {
19
20
  return { success: false, error: "No active team selected" };
20
21
  }
@@ -45,6 +45,8 @@ export interface DualAuthResult {
45
45
  scopes?: string[];
46
46
  /** `api_key.id` of the key that authenticated the request (type 'api-key' only). Used for audit logging (#105). */
47
47
  keyId?: string;
48
+ /** The session's id (type 'session' only): the active team cookie counts only for it. */
49
+ sessionId?: string;
48
50
  rateLimitResponse?: Response;
49
51
  /** Set when a dev-only x-act-as-user override replaced the real caller. */
50
52
  actingAs?: {
@@ -88,7 +90,8 @@ export declare function hasRequiredScope(authResult: DualAuthResult, requiredSco
88
90
  /**
89
91
  * Resolve and validate team context from request.
90
92
  *
91
- * Resolution priority: x-team-id header > activeTeamId cookie > user's defaultTeamId
93
+ * Resolution priority: x-team-id header > the activeTeamId cookie this session wrote >
94
+ * user's defaultTeamId
92
95
  *
93
96
  * Returns the validated teamId string on success, or a NextResponse error if:
94
97
  * - No team context can be resolved (400)
@@ -1 +1 @@
1
- {"version":3,"file":"dual-auth.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/auth/dual-auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAMvD,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,eAAe,EAKrB,MAAM,gBAAgB,CAAA;AAEvB,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAK/F;;;GAGG;AACH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A;IACzB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,mHAAmH;IACnH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iBAAiB,CAAC,EAAE,QAAQ,CAAA;IAC5B,2EAA2E;IAC3E,QAAQ,CAAC,EAAE;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3D,0EAA0E;IAC1E,KAAK,CAAC,EAAE,eAAe,CAAA;CACxB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,cAAc,CAAC,CAsCzB;AAwKD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAUtG;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,cAAc,GACzB,OAAO,CAAC,MAAM,GAAG,YAAY,CAAC,CAsChC;AAMD;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,OAAO,CAAC,CAkBlB;AA2BD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,MAAkC,EAAE,MAAM,GAAE,MAAY;;;;GAShG;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,cAAc,GAAG,YAAY,CAUlF"}
@@ -1,3 +1,5 @@
1
+ import { ACTIVE_TEAM_COOKIE, activeTeamIdForSession } from "../../teams/active-team-cookie.js";
2
+ import { getUserDefaultTeamId } from "../../teams/dashboard-team.js";
1
3
  import { NextResponse } from "next/server";
2
4
  import { auth } from "../../auth.js";
3
5
  import { validateApiKey } from "../auth.js";
@@ -15,21 +17,6 @@ const ADMIN_BYPASS_HEADER = "x-admin-bypass";
15
17
  const ADMIN_BYPASS_VALUE = "confirm-cross-team-access";
16
18
  const ACT_AS_USER_HEADER = "x-act-as-user";
17
19
  const ELEVATED_ROLES = ["superadmin", "developer"];
18
- async function getUserDefaultTeamId(userId) {
19
- try {
20
- const result = await queryOne(
21
- `SELECT "teamId" FROM "team_members"
22
- WHERE "userId" = $1
23
- ORDER BY "joinedAt" ASC
24
- LIMIT 1`,
25
- [userId]
26
- );
27
- return result == null ? void 0 : result.teamId;
28
- } catch (error) {
29
- console.error("[dual-auth] Failed to get default team:", error);
30
- return void 0;
31
- }
32
- }
33
20
  async function authenticateRequest(request, options = {}) {
34
21
  const apiKeyResult = await tryApiKeyAuth(request);
35
22
  if (apiKeyResult.success) {
@@ -131,6 +118,7 @@ async function tryApiKeyAuth(request) {
131
118
  }
132
119
  }
133
120
  async function trySessionAuth(request) {
121
+ var _a;
134
122
  try {
135
123
  console.log("[dual-auth] Attempting session authentication...");
136
124
  const session = await auth.api.getSession({ headers: request.headers });
@@ -144,6 +132,7 @@ async function trySessionAuth(request) {
144
132
  return {
145
133
  success: true,
146
134
  type: "session",
135
+ sessionId: (_a = session.session) == null ? void 0 : _a.id,
147
136
  user: {
148
137
  id: session.user.id,
149
138
  email: session.user.email,
@@ -171,7 +160,7 @@ function hasRequiredScope(authResult, requiredScope) {
171
160
  }
172
161
  async function resolveTeamContext(request, authResult) {
173
162
  var _a;
174
- const teamId = request.headers.get("x-team-id") || ((_a = request.cookies.get("activeTeamId")) == null ? void 0 : _a.value) || authResult.user.defaultTeamId;
163
+ const teamId = request.headers.get("x-team-id") || activeTeamIdForSession((_a = request.cookies.get(ACTIVE_TEAM_COOKIE)) == null ? void 0 : _a.value, authResult.sessionId) || authResult.user.defaultTeamId;
175
164
  if (!teamId) {
176
165
  return NextResponse.json(
177
166
  { success: false, error: "Team context required. Include x-team-id header." },