@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.
- package/dist/components/dashboard/block-editor/array-field.d.ts.map +1 -1
- package/dist/components/dashboard/block-editor/array-field.js +55 -3
- package/dist/components/dashboard/block-editor/dynamic-form.d.ts.map +1 -1
- package/dist/components/dashboard/block-editor/dynamic-form.js +82 -2
- package/dist/components/dashboard/navigation/DynamicNavigation.d.ts.map +1 -1
- package/dist/components/dashboard/navigation/DynamicNavigation.js +7 -1
- package/dist/components/devtools/scheduled-actions/actions-table.d.ts +1 -0
- package/dist/components/devtools/scheduled-actions/actions-table.d.ts.map +1 -1
- package/dist/components/devtools/scheduled-actions/actions-table.js +182 -46
- package/dist/components/devtools/scheduled-actions/types.d.ts +1 -0
- package/dist/components/devtools/scheduled-actions/types.d.ts.map +1 -1
- package/dist/components/media/MediaCard.d.ts +23 -0
- package/dist/components/media/MediaCard.d.ts.map +1 -0
- package/dist/components/media/MediaCard.js +154 -0
- package/dist/components/media/MediaDetailPanel.d.ts +17 -0
- package/dist/components/media/MediaDetailPanel.d.ts.map +1 -0
- package/dist/components/media/MediaDetailPanel.js +331 -0
- package/dist/components/media/MediaGrid.d.ts +26 -0
- package/dist/components/media/MediaGrid.d.ts.map +1 -0
- package/dist/components/media/MediaGrid.js +77 -0
- package/dist/components/media/MediaLibrary.d.ts +20 -0
- package/dist/components/media/MediaLibrary.d.ts.map +1 -0
- package/dist/components/media/MediaLibrary.js +229 -0
- package/dist/components/media/MediaList.d.ts +24 -0
- package/dist/components/media/MediaList.d.ts.map +1 -0
- package/dist/components/media/MediaList.js +181 -0
- package/dist/components/media/MediaSelector.d.ts +19 -0
- package/dist/components/media/MediaSelector.d.ts.map +1 -0
- package/dist/components/media/MediaSelector.js +145 -0
- package/dist/components/media/MediaTagFilter.d.ts +16 -0
- package/dist/components/media/MediaTagFilter.d.ts.map +1 -0
- package/dist/components/media/MediaTagFilter.js +122 -0
- package/dist/components/media/MediaToolbar.d.ts +25 -0
- package/dist/components/media/MediaToolbar.d.ts.map +1 -0
- package/dist/components/media/MediaToolbar.js +136 -0
- package/dist/components/media/MediaUploadZone.d.ts +19 -0
- package/dist/components/media/MediaUploadZone.d.ts.map +1 -0
- package/dist/components/media/MediaUploadZone.js +248 -0
- package/dist/components/media/index.d.ts +15 -0
- package/dist/components/media/index.d.ts.map +1 -0
- package/dist/components/media/index.js +20 -0
- package/dist/contexts/TeamContext.js +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useEnsureUserMetadata.d.ts +4 -0
- package/dist/hooks/useEnsureUserMetadata.d.ts.map +1 -1
- package/dist/hooks/useEnsureUserMetadata.js +85 -60
- package/dist/hooks/useEntityMutations.d.ts.map +1 -1
- package/dist/hooks/useEntityMutations.js +5 -9
- package/dist/hooks/useMedia.d.ts +56 -0
- package/dist/hooks/useMedia.d.ts.map +1 -0
- package/dist/hooks/useMedia.js +181 -0
- package/dist/hooks/useMediaUpload.d.ts +27 -0
- package/dist/hooks/useMediaUpload.d.ts.map +1 -0
- package/dist/hooks/useMediaUpload.js +36 -0
- package/dist/hooks/useUserSettings.d.ts +5 -4
- package/dist/hooks/useUserSettings.d.ts.map +1 -1
- package/dist/hooks/useUserSettings.js +42 -40
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/lib/api/auth/dual-auth.d.ts +6 -2
- package/dist/lib/api/auth/dual-auth.d.ts.map +1 -1
- package/dist/lib/api/auth/dual-auth.js +5 -9
- package/dist/lib/api/entity/generic-handler.d.ts.map +1 -1
- package/dist/lib/api/entity/generic-handler.js +3 -3
- package/dist/lib/auth.d.ts.map +1 -1
- package/dist/lib/auth.js +3 -2
- package/dist/lib/config/app.config.d.ts.map +1 -1
- package/dist/lib/config/app.config.js +37 -0
- package/dist/lib/config/config-sync.d.ts +1 -0
- package/dist/lib/config/config-sync.d.ts.map +1 -1
- package/dist/lib/config/config-sync.js +2 -0
- package/dist/lib/config/types.d.ts +29 -0
- package/dist/lib/config/types.d.ts.map +1 -1
- package/dist/lib/db.d.ts +10 -0
- package/dist/lib/db.d.ts.map +1 -1
- package/dist/lib/db.js +13 -1
- package/dist/lib/media/schemas.d.ts +39 -0
- package/dist/lib/media/schemas.d.ts.map +1 -0
- package/dist/lib/media/schemas.js +32 -0
- package/dist/lib/media/types.d.ts +69 -0
- package/dist/lib/media/types.d.ts.map +1 -0
- package/dist/lib/media/types.js +0 -0
- package/dist/lib/media/utils.d.ts +26 -0
- package/dist/lib/media/utils.d.ts.map +1 -0
- package/dist/lib/media/utils.js +33 -0
- package/dist/lib/rate-limit-redis.d.ts.map +1 -1
- package/dist/lib/rate-limit-redis.js +13 -4
- package/dist/lib/scheduled-actions/initializer.d.ts +6 -3
- package/dist/lib/scheduled-actions/initializer.d.ts.map +1 -1
- package/dist/lib/scheduled-actions/initializer.js +11 -6
- package/dist/lib/scheduled-actions/processor.d.ts +20 -4
- package/dist/lib/scheduled-actions/processor.d.ts.map +1 -1
- package/dist/lib/scheduled-actions/processor.js +128 -34
- package/dist/lib/scheduled-actions/registry.d.ts +3 -0
- package/dist/lib/scheduled-actions/registry.d.ts.map +1 -1
- package/dist/lib/scheduled-actions/registry.js +2 -1
- package/dist/lib/scheduled-actions/scheduler.d.ts +1 -1
- package/dist/lib/scheduled-actions/scheduler.d.ts.map +1 -1
- package/dist/lib/scheduled-actions/scheduler.js +76 -38
- package/dist/lib/scheduled-actions/types.d.ts +73 -0
- package/dist/lib/scheduled-actions/types.d.ts.map +1 -1
- package/dist/lib/selectors/core-selectors.d.ts +102 -0
- package/dist/lib/selectors/core-selectors.d.ts.map +1 -1
- package/dist/lib/selectors/core-selectors.js +3 -1
- package/dist/lib/selectors/domains/block-editor.selectors.d.ts +8 -0
- package/dist/lib/selectors/domains/block-editor.selectors.d.ts.map +1 -1
- package/dist/lib/selectors/domains/block-editor.selectors.js +9 -0
- package/dist/lib/selectors/domains/devtools.selectors.d.ts +6 -0
- package/dist/lib/selectors/domains/devtools.selectors.d.ts.map +1 -1
- package/dist/lib/selectors/domains/devtools.selectors.js +6 -0
- package/dist/lib/selectors/domains/index.d.ts +1 -0
- package/dist/lib/selectors/domains/index.d.ts.map +1 -1
- package/dist/lib/selectors/domains/index.js +2 -0
- package/dist/lib/selectors/domains/media.selectors.d.ts +96 -0
- package/dist/lib/selectors/domains/media.selectors.d.ts.map +1 -0
- package/dist/lib/selectors/domains/media.selectors.js +103 -0
- package/dist/lib/selectors/selectors.d.ts +204 -0
- package/dist/lib/selectors/selectors.d.ts.map +1 -1
- package/dist/lib/services/index.d.ts +2 -0
- package/dist/lib/services/index.d.ts.map +1 -1
- package/dist/lib/services/index.js +2 -0
- package/dist/lib/services/media.service.d.ts +158 -0
- package/dist/lib/services/media.service.d.ts.map +1 -0
- package/dist/lib/services/media.service.js +410 -0
- package/dist/messages/de/devtools.json +16 -0
- package/dist/messages/de/index.d.ts +16 -0
- package/dist/messages/de/index.d.ts.map +1 -1
- package/dist/messages/en/admin.json +4 -1
- package/dist/messages/en/devtools.json +16 -0
- package/dist/messages/en/index.d.ts +167 -0
- package/dist/messages/en/index.d.ts.map +1 -1
- package/dist/messages/en/index.js +2 -0
- package/dist/messages/en/index.ts +2 -0
- package/dist/messages/en/media.json +147 -0
- package/dist/messages/en/navigation.json +1 -0
- package/dist/messages/es/admin.json +4 -1
- package/dist/messages/es/devtools.json +16 -0
- package/dist/messages/es/index.d.ts +167 -0
- package/dist/messages/es/index.d.ts.map +1 -1
- package/dist/messages/es/index.js +2 -0
- package/dist/messages/es/index.ts +2 -0
- package/dist/messages/es/media.json +147 -0
- package/dist/messages/es/navigation.json +1 -0
- package/dist/messages/fr/devtools.json +16 -0
- package/dist/messages/fr/index.d.ts +16 -0
- package/dist/messages/fr/index.d.ts.map +1 -1
- package/dist/messages/it/devtools.json +16 -0
- package/dist/messages/it/index.d.ts +16 -0
- package/dist/messages/it/index.d.ts.map +1 -1
- package/dist/messages/pt/devtools.json +16 -0
- package/dist/messages/pt/index.d.ts +16 -0
- package/dist/messages/pt/index.d.ts.map +1 -1
- package/dist/migrations/017_scheduled_actions_table.sql +21 -0
- package/dist/migrations/021_media.sql +154 -0
- package/dist/migrations/090_sample_data.sql +53 -0
- package/dist/styles/classes.json +36 -3
- package/dist/styles/ui.css +1 -1
- package/dist/templates/app/api/devtools/config/entities/route.ts +18 -11
- package/dist/templates/app/api/devtools/config/theme/route.ts +5 -4
- package/dist/templates/app/api/devtools/tests/[...path]/route.ts +6 -5
- package/dist/templates/app/api/devtools/tests/route.ts +5 -4
- package/dist/templates/app/api/health/route.ts +6 -4
- package/dist/templates/app/api/internal/user-metadata/route.ts +3 -2
- package/dist/templates/app/api/superadmin/subscriptions/route.ts +5 -6
- package/dist/templates/app/api/superadmin/teams/[teamId]/route.ts +6 -7
- package/dist/templates/app/api/superadmin/teams/route.ts +5 -6
- package/dist/templates/app/api/superadmin/users/[userId]/route.ts +11 -16
- package/dist/templates/app/api/superadmin/users/route.ts +9 -10
- package/dist/templates/app/api/user/delete-account/route.ts +3 -2
- package/dist/templates/app/api/user/plan-flags/route.ts +11 -24
- package/dist/templates/app/api/user/profile/route.ts +7 -6
- package/dist/templates/app/api/v1/[entity]/[id]/child/[childType]/[childId]/route.ts +16 -18
- package/dist/templates/app/api/v1/[entity]/[id]/child/[childType]/route.ts +17 -19
- package/dist/templates/app/api/v1/[entity]/[id]/route.ts +10 -12
- package/dist/templates/app/api/v1/[entity]/route.ts +9 -11
- package/dist/templates/app/api/v1/api-keys/[id]/route.ts +9 -8
- package/dist/templates/app/api/v1/api-keys/route.ts +7 -6
- package/dist/templates/app/api/v1/auth/signup-with-invite/route.ts +3 -2
- package/dist/templates/app/api/v1/billing/cancel/route.ts +15 -14
- package/dist/templates/app/api/v1/billing/change-plan/route.ts +10 -9
- package/dist/templates/app/api/v1/billing/check-action/route.ts +8 -7
- package/dist/templates/app/api/v1/billing/checkout/route.ts +10 -9
- package/dist/templates/app/api/v1/billing/plans/route.ts +5 -4
- package/dist/templates/app/api/v1/billing/portal/route.ts +9 -8
- package/dist/templates/app/api/v1/blocks/[slug]/route.ts +4 -3
- package/dist/templates/app/api/v1/blocks/route.ts +3 -2
- package/dist/templates/app/api/v1/blocks/validate/route.ts +5 -3
- package/dist/templates/app/api/v1/cron/process/route.ts +4 -6
- package/dist/templates/app/api/v1/devtools/blocks/route.ts +3 -2
- package/dist/templates/app/api/v1/devtools/docs/route.ts +3 -2
- package/dist/templates/app/api/v1/devtools/features/route.ts +3 -2
- package/dist/templates/app/api/v1/devtools/flows/route.ts +3 -2
- package/dist/templates/app/api/v1/devtools/scheduled-actions/route.ts +125 -3
- package/dist/templates/app/api/v1/devtools/scheduled-actions/run/route.ts +110 -0
- package/dist/templates/app/api/v1/devtools/testing/route.ts +3 -2
- package/dist/templates/app/api/v1/media/[id]/route.ts +144 -0
- package/dist/templates/app/api/v1/media/[id]/tags/route.ts +154 -0
- package/dist/templates/app/api/v1/media/check-duplicates/route.ts +56 -0
- package/dist/templates/app/api/v1/media/route.ts +56 -0
- package/dist/templates/app/api/v1/media/upload/route.ts +157 -33
- package/dist/templates/app/api/v1/media-tags/route.ts +65 -0
- package/dist/templates/app/api/v1/plugin/[...path]/route.ts +16 -15
- package/dist/templates/app/api/v1/plugin/route.ts +3 -2
- package/dist/templates/app/api/v1/post-categories/[id]/route.ts +10 -9
- package/dist/templates/app/api/v1/post-categories/route.ts +5 -4
- package/dist/templates/app/api/v1/team-invitations/[token]/accept/route.ts +3 -3
- package/dist/templates/app/api/v1/team-invitations/[token]/decline/route.ts +3 -3
- package/dist/templates/app/api/v1/team-invitations/[token]/route.ts +3 -2
- package/dist/templates/app/api/v1/team-invitations/route.ts +3 -2
- package/dist/templates/app/api/v1/teams/[teamId]/invitations/route.ts +5 -4
- package/dist/templates/app/api/v1/teams/[teamId]/invoices/[invoiceNumber]/route.ts +3 -2
- package/dist/templates/app/api/v1/teams/[teamId]/invoices/route.ts +3 -2
- package/dist/templates/app/api/v1/teams/[teamId]/members/[memberId]/route.ts +5 -4
- package/dist/templates/app/api/v1/teams/[teamId]/members/route.ts +5 -5
- package/dist/templates/app/api/v1/teams/[teamId]/route.ts +31 -58
- package/dist/templates/app/api/v1/teams/[teamId]/subscription/route.ts +3 -2
- package/dist/templates/app/api/v1/teams/[teamId]/usage/[limitSlug]/route.ts +5 -4
- package/dist/templates/app/api/v1/teams/route.ts +18 -17
- package/dist/templates/app/api/v1/teams/switch/route.ts +3 -2
- package/dist/templates/app/api/v1/theme/[...path]/route.ts +16 -15
- package/dist/templates/app/api/v1/theme/route.ts +3 -2
- package/dist/templates/app/api/v1/users/[id]/meta/[key]/route.ts +7 -6
- package/dist/templates/app/api/v1/users/[id]/route.ts +9 -8
- package/dist/templates/app/api/v1/users/route.ts +7 -6
- package/dist/templates/app/dashboard/(main)/media/page.tsx +607 -0
- package/dist/templates/contents/themes/starter/messages/de/dev.json +106 -0
- package/dist/templates/contents/themes/starter/messages/de/index.ts +2 -0
- package/dist/templates/contents/themes/starter/messages/en/dev.json +106 -0
- package/dist/templates/contents/themes/starter/messages/en/index.ts +2 -0
- package/dist/templates/contents/themes/starter/messages/es/dev.json +106 -0
- package/dist/templates/contents/themes/starter/messages/es/index.ts +2 -0
- package/dist/templates/contents/themes/starter/messages/fr/dev.json +106 -0
- package/dist/templates/contents/themes/starter/messages/fr/index.ts +2 -0
- package/dist/templates/contents/themes/starter/messages/it/dev.json +106 -0
- package/dist/templates/contents/themes/starter/messages/it/index.ts +2 -0
- package/dist/templates/contents/themes/starter/messages/pt/dev.json +106 -0
- package/dist/templates/contents/themes/starter/messages/pt/index.ts +2 -0
- package/dist/templates/contents/themes/starter/styles/globals.css +14 -0
- package/dist/templates/instrumentation.ts +33 -0
- package/dist/types/blocks.d.ts +1 -1
- package/dist/types/blocks.d.ts.map +1 -1
- package/migrations/017_scheduled_actions_table.sql +21 -0
- package/migrations/021_media.sql +154 -0
- package/migrations/090_sample_data.sql +53 -0
- package/package.json +16 -15
- package/scripts/build/registry/config.mjs +41 -0
- package/scripts/build/registry/discovery/templates.mjs +0 -1
- package/scripts/build/registry/generators/entity-registry.mjs +16 -6
- package/scripts/build/registry/generators/route-handlers.mjs +8 -2
- package/scripts/build/registry/generators/template-registry.mjs +16 -4
- package/scripts/build/registry/post-build/route-cleanup.mjs +0 -1
- package/scripts/build/registry/validate-env.test.mjs +92 -0
- package/scripts/build/registry.mjs +18 -1
- package/scripts/deploy/vercel-deploy.mjs +1 -1
- package/templates/app/api/devtools/config/entities/route.ts +18 -11
- package/templates/app/api/devtools/config/theme/route.ts +5 -4
- package/templates/app/api/devtools/tests/[...path]/route.ts +6 -5
- package/templates/app/api/devtools/tests/route.ts +5 -4
- package/templates/app/api/health/route.ts +6 -4
- package/templates/app/api/internal/user-metadata/route.ts +3 -2
- package/templates/app/api/superadmin/subscriptions/route.ts +5 -6
- package/templates/app/api/superadmin/teams/[teamId]/route.ts +6 -7
- package/templates/app/api/superadmin/teams/route.ts +5 -6
- package/templates/app/api/superadmin/users/[userId]/route.ts +11 -16
- package/templates/app/api/superadmin/users/route.ts +9 -10
- package/templates/app/api/user/delete-account/route.ts +3 -2
- package/templates/app/api/user/plan-flags/route.ts +11 -24
- package/templates/app/api/user/profile/route.ts +7 -6
- package/templates/app/api/v1/[entity]/[id]/child/[childType]/[childId]/route.ts +16 -18
- package/templates/app/api/v1/[entity]/[id]/child/[childType]/route.ts +17 -19
- package/templates/app/api/v1/[entity]/[id]/route.ts +10 -12
- package/templates/app/api/v1/[entity]/route.ts +9 -11
- package/templates/app/api/v1/api-keys/[id]/route.ts +9 -8
- package/templates/app/api/v1/api-keys/route.ts +7 -6
- package/templates/app/api/v1/auth/signup-with-invite/route.ts +3 -2
- package/templates/app/api/v1/billing/cancel/route.ts +15 -14
- package/templates/app/api/v1/billing/change-plan/route.ts +10 -9
- package/templates/app/api/v1/billing/check-action/route.ts +8 -7
- package/templates/app/api/v1/billing/checkout/route.ts +10 -9
- package/templates/app/api/v1/billing/plans/route.ts +5 -4
- package/templates/app/api/v1/billing/portal/route.ts +9 -8
- package/templates/app/api/v1/blocks/[slug]/route.ts +4 -3
- package/templates/app/api/v1/blocks/route.ts +3 -2
- package/templates/app/api/v1/blocks/validate/route.ts +5 -3
- package/templates/app/api/v1/cron/process/route.ts +4 -6
- package/templates/app/api/v1/devtools/blocks/route.ts +3 -2
- package/templates/app/api/v1/devtools/docs/route.ts +3 -2
- package/templates/app/api/v1/devtools/features/route.ts +3 -2
- package/templates/app/api/v1/devtools/flows/route.ts +3 -2
- package/templates/app/api/v1/devtools/scheduled-actions/route.ts +125 -3
- package/templates/app/api/v1/devtools/scheduled-actions/run/route.ts +110 -0
- package/templates/app/api/v1/devtools/testing/route.ts +3 -2
- package/templates/app/api/v1/media/[id]/route.ts +144 -0
- package/templates/app/api/v1/media/[id]/tags/route.ts +154 -0
- package/templates/app/api/v1/media/check-duplicates/route.ts +56 -0
- package/templates/app/api/v1/media/route.ts +56 -0
- package/templates/app/api/v1/media/upload/route.ts +157 -33
- package/templates/app/api/v1/media-tags/route.ts +65 -0
- package/templates/app/api/v1/plugin/[...path]/route.ts +16 -15
- package/templates/app/api/v1/plugin/route.ts +3 -2
- package/templates/app/api/v1/post-categories/[id]/route.ts +10 -9
- package/templates/app/api/v1/post-categories/route.ts +5 -4
- package/templates/app/api/v1/team-invitations/[token]/accept/route.ts +3 -3
- package/templates/app/api/v1/team-invitations/[token]/decline/route.ts +3 -3
- package/templates/app/api/v1/team-invitations/[token]/route.ts +3 -2
- package/templates/app/api/v1/team-invitations/route.ts +3 -2
- package/templates/app/api/v1/teams/[teamId]/invitations/route.ts +5 -4
- package/templates/app/api/v1/teams/[teamId]/invoices/[invoiceNumber]/route.ts +3 -2
- package/templates/app/api/v1/teams/[teamId]/invoices/route.ts +3 -2
- package/templates/app/api/v1/teams/[teamId]/members/[memberId]/route.ts +5 -4
- package/templates/app/api/v1/teams/[teamId]/members/route.ts +5 -5
- package/templates/app/api/v1/teams/[teamId]/route.ts +31 -58
- package/templates/app/api/v1/teams/[teamId]/subscription/route.ts +3 -2
- package/templates/app/api/v1/teams/[teamId]/usage/[limitSlug]/route.ts +5 -4
- package/templates/app/api/v1/teams/route.ts +18 -17
- package/templates/app/api/v1/teams/switch/route.ts +3 -2
- package/templates/app/api/v1/theme/[...path]/route.ts +16 -15
- package/templates/app/api/v1/theme/route.ts +3 -2
- package/templates/app/api/v1/users/[id]/meta/[key]/route.ts +7 -6
- package/templates/app/api/v1/users/[id]/route.ts +9 -8
- package/templates/app/api/v1/users/route.ts +7 -6
- package/templates/app/dashboard/(main)/media/page.tsx +607 -0
- package/templates/contents/themes/starter/messages/de/dev.json +106 -0
- package/templates/contents/themes/starter/messages/de/index.ts +2 -0
- package/templates/contents/themes/starter/messages/en/dev.json +106 -0
- package/templates/contents/themes/starter/messages/en/index.ts +2 -0
- package/templates/contents/themes/starter/messages/es/dev.json +106 -0
- package/templates/contents/themes/starter/messages/es/index.ts +2 -0
- package/templates/contents/themes/starter/messages/fr/dev.json +106 -0
- package/templates/contents/themes/starter/messages/fr/index.ts +2 -0
- package/templates/contents/themes/starter/messages/it/dev.json +106 -0
- package/templates/contents/themes/starter/messages/it/index.ts +2 -0
- package/templates/contents/themes/starter/messages/pt/dev.json +106 -0
- package/templates/contents/themes/starter/messages/pt/index.ts +2 -0
- package/templates/contents/themes/starter/styles/globals.css +14 -0
- package/templates/instrumentation.ts +33 -0
- package/dist/presets/plugin/.env.example.template +0 -19
- package/dist/presets/plugin/entities/.gitkeep +0 -18
- package/dist/presets/theme/blocks/.gitkeep +0 -17
- package/dist/presets/theme/public/brand/.gitkeep +0 -8
- package/dist/presets/theme/tests/cypress/.gitkeep +0 -10
- package/dist/templates/contents/plugins/starter/plugin/.env.example.template +0 -19
- package/templates/contents/plugins/starter/plugin/.env.example.template +0 -19
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getTypedSession } from "@nextsparkjs/core/lib/auth";
|
|
2
2
|
import { NextResponse } from "next/server";
|
|
3
|
-
import {
|
|
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
|
|
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
|
|
43
|
+
export const GET = withRateLimitTier(async (request: Request) => {
|
|
40
44
|
try {
|
|
41
45
|
// Verify developer role
|
|
42
|
-
const session = await
|
|
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(
|
|
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 {
|
|
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
|
|
12
|
+
export const GET = withRateLimitTier(async (request: Request) => {
|
|
12
13
|
try {
|
|
13
14
|
// Verify developer role
|
|
14
|
-
const session = await
|
|
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 {
|
|
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
|
|
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
|
|
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 {
|
|
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
|
|
62
|
+
export const GET = withRateLimitTier(async (request: Request) => {
|
|
62
63
|
try {
|
|
63
64
|
// Verify developer role
|
|
64
|
-
const session = await
|
|
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
|
|
5
|
+
export const GET = withRateLimitTier(async () => {
|
|
4
6
|
try {
|
|
5
7
|
// Test database connection
|
|
6
8
|
await queryWithRLS('SELECT 1');
|
|
7
9
|
|
|
8
|
-
return
|
|
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
|
|
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
|
|
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 {
|
|
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
|
|
55
|
+
export const GET = withRateLimitTier(async (request: NextRequest) => {
|
|
55
56
|
try {
|
|
56
57
|
// Get the current session using Better Auth
|
|
57
|
-
const session = await
|
|
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 {
|
|
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
|
|
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
|
|
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 {
|
|
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
|
|
35
|
+
export const GET = withRateLimitTier(async (request: NextRequest) => {
|
|
35
36
|
try {
|
|
36
37
|
// Get the current session using Better Auth
|
|
37
|
-
const session = await
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
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
|
|
27
|
+
export const GET = withRateLimitTier(async (request: NextRequest) => {
|
|
27
28
|
try {
|
|
28
29
|
// Get the current session using Better Auth
|
|
29
|
-
const session = await
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
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
|
|
30
|
+
export const GET = withRateLimitTier(async (request: NextRequest) => {
|
|
30
31
|
try {
|
|
31
32
|
// Get session
|
|
32
|
-
const session = await
|
|
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
|
|
92
|
+
export const PATCH = withRateLimitTier(async (request: NextRequest) => {
|
|
94
93
|
try {
|
|
95
94
|
// Get session
|
|
96
|
-
const session = await
|
|
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
|
|
178
|
+
export const POST = withRateLimitTier(async (request: NextRequest) => {
|
|
190
179
|
try {
|
|
191
180
|
// Get session
|
|
192
|
-
const session = await
|
|
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
|
|
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
|
|
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');
|