@nextsparkjs/core 0.1.0-beta.83 → 0.1.0-beta.85
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/styles/classes.json +1 -1
- package/dist/templates/app/(auth)/forgot-password/page.tsx +216 -0
- package/dist/templates/app/(auth)/layout.tsx +51 -0
- package/dist/templates/app/(auth)/login/page.tsx +21 -0
- package/dist/templates/app/(auth)/reset-password/page.tsx +212 -0
- package/dist/templates/app/(auth)/signup/page.tsx +21 -0
- package/dist/templates/app/(auth)/verify-email/page.tsx +190 -0
- package/dist/templates/app/(public)/[...slug]/page.tsx +378 -0
- package/dist/templates/app/(public)/docs/[section]/[page]/page.tsx +90 -0
- package/dist/templates/app/(public)/docs/layout.tsx +25 -0
- package/dist/templates/app/(public)/docs/page.tsx +81 -0
- package/dist/templates/app/(public)/layout.tsx +41 -0
- package/dist/templates/app/(public)/page.tsx +19 -0
- package/dist/templates/app/403/page.tsx +89 -0
- package/dist/templates/app/api/auth/[...all]/route.ts +78 -0
- package/dist/templates/app/api/cron/billing/lifecycle/route.ts +98 -0
- package/dist/templates/app/api/csp-report/route.ts +175 -0
- package/dist/templates/app/api/devtools/config/entities/route.ts +108 -0
- package/dist/templates/app/api/devtools/config/theme/route.ts +66 -0
- package/dist/templates/app/api/devtools/tests/[...path]/route.ts +130 -0
- package/dist/templates/app/api/devtools/tests/route.ts +134 -0
- package/dist/templates/app/api/health/route.ts +29 -0
- package/dist/templates/app/api/internal/user-metadata/route.ts +36 -0
- package/dist/templates/app/api/superadmin/subscriptions/route.ts +310 -0
- package/dist/templates/app/api/superadmin/teams/[teamId]/route.ts +286 -0
- package/dist/templates/app/api/superadmin/teams/route.ts +188 -0
- package/dist/templates/app/api/superadmin/users/[userId]/route.ts +540 -0
- package/dist/templates/app/api/superadmin/users/route.ts +323 -0
- package/dist/templates/app/api/user/delete-account/route.ts +55 -0
- package/dist/templates/app/api/user/plan-flags/route.ts +283 -0
- package/dist/templates/app/api/user/profile/route.ts +133 -0
- package/dist/templates/app/api/v1/[entity]/[id]/child/[childType]/[childId]/route.ts +210 -0
- package/dist/templates/app/api/v1/[entity]/[id]/child/[childType]/route.ts +331 -0
- package/dist/templates/app/api/v1/[entity]/[id]/route.ts +35 -0
- package/dist/templates/app/api/v1/[entity]/docs.md +369 -0
- package/dist/templates/app/api/v1/[entity]/presets.ts +194 -0
- package/dist/templates/app/api/v1/[entity]/route.ts +31 -0
- package/dist/templates/app/api/v1/api-keys/[id]/route.ts +303 -0
- package/dist/templates/app/api/v1/api-keys/docs.md +101 -0
- package/dist/templates/app/api/v1/api-keys/presets.ts +31 -0
- package/dist/templates/app/api/v1/api-keys/route.ts +250 -0
- package/dist/templates/app/api/v1/auth/docs.md +184 -0
- package/dist/templates/app/api/v1/auth/presets.ts +44 -0
- package/dist/templates/app/api/v1/auth/signup-with-invite/route.ts +227 -0
- package/dist/templates/app/api/v1/billing/cancel/route.ts +206 -0
- package/dist/templates/app/api/v1/billing/change-plan/route.ts +97 -0
- package/dist/templates/app/api/v1/billing/check-action/route.ts +81 -0
- package/dist/templates/app/api/v1/billing/checkout/route.ts +124 -0
- package/dist/templates/app/api/v1/billing/docs.md +209 -0
- package/dist/templates/app/api/v1/billing/plans/route.ts +85 -0
- package/dist/templates/app/api/v1/billing/portal/route.ts +90 -0
- package/dist/templates/app/api/v1/billing/presets.ts +121 -0
- package/dist/templates/app/api/v1/billing/webhooks/stripe/route.ts +428 -0
- package/dist/templates/app/api/v1/blocks/[slug]/route.ts +29 -0
- package/dist/templates/app/api/v1/blocks/docs.md +173 -0
- package/dist/templates/app/api/v1/blocks/presets.ts +121 -0
- package/dist/templates/app/api/v1/blocks/route.ts +45 -0
- package/dist/templates/app/api/v1/blocks/validate/route.ts +45 -0
- package/dist/templates/app/api/v1/cron/docs.md +116 -0
- package/dist/templates/app/api/v1/cron/presets.ts +26 -0
- package/dist/templates/app/api/v1/cron/process/route.ts +108 -0
- package/dist/templates/app/api/v1/devtools/blocks/route.ts +82 -0
- package/dist/templates/app/api/v1/devtools/docs/route.ts +150 -0
- package/dist/templates/app/api/v1/devtools/docs.md +204 -0
- package/dist/templates/app/api/v1/devtools/features/route.ts +61 -0
- package/dist/templates/app/api/v1/devtools/flows/route.ts +61 -0
- package/dist/templates/app/api/v1/devtools/presets.ts +113 -0
- package/dist/templates/app/api/v1/devtools/scheduled-actions/route.ts +120 -0
- package/dist/templates/app/api/v1/devtools/testing/route.ts +82 -0
- package/dist/templates/app/api/v1/media/docs.md +117 -0
- package/dist/templates/app/api/v1/media/presets.ts +24 -0
- package/dist/templates/app/api/v1/media/upload/route.ts +150 -0
- package/dist/templates/app/api/v1/patterns/[id]/usages/route.ts +116 -0
- package/dist/templates/app/api/v1/plugin/[...path]/route.ts +373 -0
- package/dist/templates/app/api/v1/plugin/docs.md +79 -0
- package/dist/templates/app/api/v1/plugin/presets.ts +21 -0
- package/dist/templates/app/api/v1/plugin/route.ts +96 -0
- package/dist/templates/app/api/v1/post-categories/[id]/route.ts +255 -0
- package/dist/templates/app/api/v1/post-categories/docs.md +134 -0
- package/dist/templates/app/api/v1/post-categories/presets.ts +78 -0
- package/dist/templates/app/api/v1/post-categories/route.ts +119 -0
- package/dist/templates/app/api/v1/team-invitations/[token]/accept/route.ts +179 -0
- package/dist/templates/app/api/v1/team-invitations/[token]/decline/route.ts +120 -0
- package/dist/templates/app/api/v1/team-invitations/[token]/route.ts +89 -0
- package/dist/templates/app/api/v1/team-invitations/docs.md +88 -0
- package/dist/templates/app/api/v1/team-invitations/presets.ts +43 -0
- package/dist/templates/app/api/v1/team-invitations/route.ts +114 -0
- package/dist/templates/app/api/v1/teams/[teamId]/invitations/route.ts +171 -0
- package/dist/templates/app/api/v1/teams/[teamId]/invoices/[invoiceNumber]/route.ts +105 -0
- package/dist/templates/app/api/v1/teams/[teamId]/invoices/route.ts +125 -0
- package/dist/templates/app/api/v1/teams/[teamId]/members/[memberId]/route.ts +263 -0
- package/dist/templates/app/api/v1/teams/[teamId]/members/route.ts +358 -0
- package/dist/templates/app/api/v1/teams/[teamId]/route.ts +322 -0
- package/dist/templates/app/api/v1/teams/[teamId]/subscription/route.ts +50 -0
- package/dist/templates/app/api/v1/teams/[teamId]/usage/[limitSlug]/route.ts +91 -0
- package/dist/templates/app/api/v1/teams/docs.md +320 -0
- package/dist/templates/app/api/v1/teams/presets.ts +178 -0
- package/dist/templates/app/api/v1/teams/route.ts +293 -0
- package/dist/templates/app/api/v1/teams/switch/route.ts +88 -0
- package/dist/templates/app/api/v1/theme/[...path]/route.ts +361 -0
- package/dist/templates/app/api/v1/theme/docs.md +74 -0
- package/dist/templates/app/api/v1/theme/presets.ts +21 -0
- package/dist/templates/app/api/v1/theme/route.ts +96 -0
- package/dist/templates/app/api/v1/users/[id]/meta/[key]/route.ts +363 -0
- package/dist/templates/app/api/v1/users/[id]/route.ts +302 -0
- package/dist/templates/app/api/v1/users/docs.md +93 -0
- package/dist/templates/app/api/v1/users/presets.ts +59 -0
- package/dist/templates/app/api/v1/users/route.ts +197 -0
- package/dist/templates/app/dashboard/(main)/[entity]/[id]/edit/page.tsx +117 -0
- package/dist/templates/app/dashboard/(main)/[entity]/[id]/page.tsx +103 -0
- package/dist/templates/app/dashboard/(main)/[entity]/create/page.tsx +95 -0
- package/dist/templates/app/dashboard/(main)/[entity]/error.tsx +51 -0
- package/dist/templates/app/dashboard/(main)/[entity]/layout.tsx +113 -0
- package/dist/templates/app/dashboard/(main)/[entity]/loading.tsx +61 -0
- package/dist/templates/app/dashboard/(main)/[entity]/page.tsx +90 -0
- package/dist/templates/app/dashboard/(main)/layout.tsx +98 -0
- package/dist/templates/app/dashboard/(main)/loading.tsx +5 -0
- package/dist/templates/app/dashboard/(main)/page.tsx +201 -0
- package/dist/templates/app/dashboard/(main)/patterns/[id]/edit/page.tsx +114 -0
- package/dist/templates/app/dashboard/(main)/patterns/[id]/page.tsx +20 -0
- package/dist/templates/app/dashboard/(main)/patterns/[id]/reports/page.tsx +171 -0
- package/dist/templates/app/dashboard/(main)/patterns/create/page.tsx +86 -0
- package/dist/templates/app/dashboard/(main)/patterns/page.tsx +444 -0
- package/dist/templates/app/dashboard/features/analytics/page.tsx +35 -0
- package/dist/templates/app/dashboard/features/automation/page.tsx +35 -0
- package/dist/templates/app/dashboard/features/layout.tsx +13 -0
- package/dist/templates/app/dashboard/features/loading.tsx +5 -0
- package/dist/templates/app/dashboard/features/webhooks/page.tsx +35 -0
- package/dist/templates/app/dashboard/layout.tsx +86 -0
- package/dist/templates/app/dashboard/permission-denied/page.tsx +29 -0
- package/dist/templates/app/dashboard/settings/api-keys/loading.tsx +5 -0
- package/dist/templates/app/dashboard/settings/api-keys/page.tsx +513 -0
- package/dist/templates/app/dashboard/settings/billing/loading.tsx +5 -0
- package/dist/templates/app/dashboard/settings/billing/page.tsx +284 -0
- package/dist/templates/app/dashboard/settings/invoices/[invoiceNumber]/page.tsx +222 -0
- package/dist/templates/app/dashboard/settings/invoices/loading.tsx +5 -0
- package/dist/templates/app/dashboard/settings/invoices/page.tsx +82 -0
- package/dist/templates/app/dashboard/settings/layout.tsx +151 -0
- package/dist/templates/app/dashboard/settings/loading.tsx +5 -0
- package/dist/templates/app/dashboard/settings/notifications/loading.tsx +5 -0
- package/dist/templates/app/dashboard/settings/notifications/page.tsx +462 -0
- package/dist/templates/app/dashboard/settings/page.tsx +92 -0
- package/dist/templates/app/dashboard/settings/password/loading.tsx +5 -0
- package/dist/templates/app/dashboard/settings/password/page.tsx +306 -0
- package/dist/templates/app/dashboard/settings/plans/loading.tsx +5 -0
- package/dist/templates/app/dashboard/settings/plans/page.tsx +40 -0
- package/dist/templates/app/dashboard/settings/profile/loading.tsx +5 -0
- package/dist/templates/app/dashboard/settings/profile/page.tsx +686 -0
- package/dist/templates/app/dashboard/settings/security/loading.tsx +5 -0
- package/dist/templates/app/dashboard/settings/security/page.tsx +505 -0
- package/dist/templates/app/dashboard/settings/teams/loading.tsx +5 -0
- package/dist/templates/app/dashboard/settings/teams/page.tsx +272 -0
- package/dist/templates/app/dashboard/settings/teams/permissions/page.tsx +92 -0
- package/dist/templates/app/devtools/blocks/[slug]/page.tsx +39 -0
- package/dist/templates/app/devtools/blocks/page.tsx +31 -0
- package/dist/templates/app/devtools/config/page.tsx +31 -0
- package/dist/templates/app/devtools/features/page.tsx +31 -0
- package/dist/templates/app/devtools/flows/page.tsx +31 -0
- package/dist/templates/app/devtools/layout.tsx +58 -0
- package/dist/templates/app/devtools/page.tsx +121 -0
- package/dist/templates/app/devtools/scheduled-actions/page.tsx +157 -0
- package/dist/templates/app/devtools/style/page.tsx +330 -0
- package/dist/templates/app/devtools/tags/page.tsx +31 -0
- package/dist/templates/app/devtools/tests/[[...path]]/page.tsx +47 -0
- package/dist/templates/app/favicon.ico +0 -0
- package/dist/templates/app/globals.css +12 -0
- package/dist/templates/app/layout.tsx +96 -0
- package/dist/templates/app/public/page.tsx +30 -0
- package/dist/templates/app/superadmin/docs/[section]/[page]/page.tsx +92 -0
- package/dist/templates/app/superadmin/docs/page.tsx +75 -0
- package/dist/templates/app/superadmin/layout.tsx +67 -0
- package/dist/templates/app/superadmin/page.tsx +149 -0
- package/dist/templates/app/superadmin/subscriptions/page.tsx +655 -0
- package/dist/templates/app/superadmin/team-roles/page.tsx +493 -0
- package/dist/templates/app/superadmin/teams/[teamId]/page.tsx +687 -0
- package/dist/templates/app/superadmin/teams/page.tsx +302 -0
- package/dist/templates/app/superadmin/users/[userId]/page.tsx +548 -0
- package/dist/templates/app/superadmin/users/page.tsx +528 -0
- package/package.json +15 -15
- package/scripts/build/docs-registry.mjs +0 -0
- package/scripts/create-theme.mjs +0 -0
- package/scripts/deploy/release-version.mjs +0 -0
- package/scripts/deploy/vercel-deploy.mjs +0 -0
- package/scripts/dev/watch-plugins.mjs +0 -0
- package/scripts/maintenance/update-core.mjs +0 -0
- package/scripts/setup/npm-postinstall.mjs +0 -0
- package/scripts/setup/setup-claude.mjs +0 -0
- package/scripts/validation/check-imports.sh +0 -0
- package/templates/app/(auth)/forgot-password/page.tsx +216 -0
- package/templates/app/(auth)/layout.tsx +51 -0
- package/templates/app/(auth)/login/page.tsx +21 -0
- package/templates/app/(auth)/reset-password/page.tsx +212 -0
- package/templates/app/(auth)/signup/page.tsx +21 -0
- package/templates/app/(auth)/verify-email/page.tsx +190 -0
- package/templates/app/(public)/[...slug]/page.tsx +378 -0
- package/templates/app/(public)/docs/[section]/[page]/page.tsx +90 -0
- package/templates/app/(public)/docs/layout.tsx +25 -0
- package/templates/app/(public)/docs/page.tsx +81 -0
- package/templates/app/(public)/layout.tsx +41 -0
- package/templates/app/(public)/page.tsx +19 -0
- package/templates/app/403/page.tsx +89 -0
- package/templates/app/api/auth/[...all]/route.ts +78 -0
- package/templates/app/api/cron/billing/lifecycle/route.ts +98 -0
- package/templates/app/api/csp-report/route.ts +175 -0
- package/templates/app/api/devtools/config/entities/route.ts +108 -0
- package/templates/app/api/devtools/config/theme/route.ts +66 -0
- package/templates/app/api/devtools/tests/[...path]/route.ts +130 -0
- package/templates/app/api/devtools/tests/route.ts +134 -0
- package/templates/app/api/health/route.ts +29 -0
- package/templates/app/api/internal/user-metadata/route.ts +36 -0
- package/templates/app/api/superadmin/subscriptions/route.ts +310 -0
- package/templates/app/api/superadmin/teams/[teamId]/route.ts +286 -0
- package/templates/app/api/superadmin/teams/route.ts +188 -0
- package/templates/app/api/superadmin/users/[userId]/route.ts +540 -0
- package/templates/app/api/superadmin/users/route.ts +323 -0
- package/templates/app/api/user/delete-account/route.ts +55 -0
- package/templates/app/api/user/plan-flags/route.ts +283 -0
- package/templates/app/api/user/profile/route.ts +133 -0
- package/templates/app/api/v1/[entity]/[id]/child/[childType]/[childId]/route.ts +210 -0
- package/templates/app/api/v1/[entity]/[id]/child/[childType]/route.ts +331 -0
- package/templates/app/api/v1/[entity]/[id]/route.ts +35 -0
- package/templates/app/api/v1/[entity]/docs.md +369 -0
- package/templates/app/api/v1/[entity]/presets.ts +194 -0
- package/templates/app/api/v1/[entity]/route.ts +31 -0
- package/templates/app/api/v1/api-keys/[id]/route.ts +303 -0
- package/templates/app/api/v1/api-keys/docs.md +101 -0
- package/templates/app/api/v1/api-keys/presets.ts +31 -0
- package/templates/app/api/v1/api-keys/route.ts +250 -0
- package/templates/app/api/v1/auth/docs.md +184 -0
- package/templates/app/api/v1/auth/presets.ts +44 -0
- package/templates/app/api/v1/auth/signup-with-invite/route.ts +227 -0
- package/templates/app/api/v1/billing/cancel/route.ts +206 -0
- package/templates/app/api/v1/billing/change-plan/route.ts +97 -0
- package/templates/app/api/v1/billing/check-action/route.ts +81 -0
- package/templates/app/api/v1/billing/checkout/route.ts +124 -0
- package/templates/app/api/v1/billing/docs.md +209 -0
- package/templates/app/api/v1/billing/plans/route.ts +85 -0
- package/templates/app/api/v1/billing/portal/route.ts +90 -0
- package/templates/app/api/v1/billing/presets.ts +121 -0
- package/templates/app/api/v1/billing/webhooks/stripe/route.ts +428 -0
- package/templates/app/api/v1/blocks/[slug]/route.ts +29 -0
- package/templates/app/api/v1/blocks/docs.md +173 -0
- package/templates/app/api/v1/blocks/presets.ts +121 -0
- package/templates/app/api/v1/blocks/route.ts +45 -0
- package/templates/app/api/v1/blocks/validate/route.ts +45 -0
- package/templates/app/api/v1/cron/docs.md +116 -0
- package/templates/app/api/v1/cron/presets.ts +26 -0
- package/templates/app/api/v1/cron/process/route.ts +108 -0
- package/templates/app/api/v1/devtools/blocks/route.ts +82 -0
- package/templates/app/api/v1/devtools/docs/route.ts +150 -0
- package/templates/app/api/v1/devtools/docs.md +204 -0
- package/templates/app/api/v1/devtools/features/route.ts +61 -0
- package/templates/app/api/v1/devtools/flows/route.ts +61 -0
- package/templates/app/api/v1/devtools/presets.ts +113 -0
- package/templates/app/api/v1/devtools/scheduled-actions/route.ts +120 -0
- package/templates/app/api/v1/devtools/testing/route.ts +82 -0
- package/templates/app/api/v1/media/docs.md +117 -0
- package/templates/app/api/v1/media/presets.ts +24 -0
- package/templates/app/api/v1/media/upload/route.ts +150 -0
- package/templates/app/api/v1/patterns/[id]/usages/route.ts +116 -0
- package/templates/app/api/v1/plugin/[...path]/route.ts +373 -0
- package/templates/app/api/v1/plugin/docs.md +79 -0
- package/templates/app/api/v1/plugin/presets.ts +21 -0
- package/templates/app/api/v1/plugin/route.ts +96 -0
- package/templates/app/api/v1/post-categories/[id]/route.ts +255 -0
- package/templates/app/api/v1/post-categories/docs.md +134 -0
- package/templates/app/api/v1/post-categories/presets.ts +78 -0
- package/templates/app/api/v1/post-categories/route.ts +119 -0
- package/templates/app/api/v1/team-invitations/[token]/accept/route.ts +179 -0
- package/templates/app/api/v1/team-invitations/[token]/decline/route.ts +120 -0
- package/templates/app/api/v1/team-invitations/[token]/route.ts +89 -0
- package/templates/app/api/v1/team-invitations/docs.md +88 -0
- package/templates/app/api/v1/team-invitations/presets.ts +43 -0
- package/templates/app/api/v1/team-invitations/route.ts +114 -0
- package/templates/app/api/v1/teams/[teamId]/invitations/route.ts +171 -0
- package/templates/app/api/v1/teams/[teamId]/invoices/[invoiceNumber]/route.ts +105 -0
- package/templates/app/api/v1/teams/[teamId]/invoices/route.ts +125 -0
- package/templates/app/api/v1/teams/[teamId]/members/[memberId]/route.ts +263 -0
- package/templates/app/api/v1/teams/[teamId]/members/route.ts +358 -0
- package/templates/app/api/v1/teams/[teamId]/route.ts +322 -0
- package/templates/app/api/v1/teams/[teamId]/subscription/route.ts +50 -0
- package/templates/app/api/v1/teams/[teamId]/usage/[limitSlug]/route.ts +91 -0
- package/templates/app/api/v1/teams/docs.md +320 -0
- package/templates/app/api/v1/teams/presets.ts +178 -0
- package/templates/app/api/v1/teams/route.ts +293 -0
- package/templates/app/api/v1/teams/switch/route.ts +88 -0
- package/templates/app/api/v1/theme/[...path]/route.ts +361 -0
- package/templates/app/api/v1/theme/docs.md +74 -0
- package/templates/app/api/v1/theme/presets.ts +21 -0
- package/templates/app/api/v1/theme/route.ts +96 -0
- package/templates/app/api/v1/users/[id]/meta/[key]/route.ts +363 -0
- package/templates/app/api/v1/users/[id]/route.ts +302 -0
- package/templates/app/api/v1/users/docs.md +93 -0
- package/templates/app/api/v1/users/presets.ts +59 -0
- package/templates/app/api/v1/users/route.ts +197 -0
- package/templates/app/dashboard/(main)/[entity]/[id]/edit/page.tsx +117 -0
- package/templates/app/dashboard/(main)/[entity]/[id]/page.tsx +103 -0
- package/templates/app/dashboard/(main)/[entity]/create/page.tsx +95 -0
- package/templates/app/dashboard/(main)/[entity]/error.tsx +51 -0
- package/templates/app/dashboard/(main)/[entity]/layout.tsx +113 -0
- package/templates/app/dashboard/(main)/[entity]/loading.tsx +61 -0
- package/templates/app/dashboard/(main)/[entity]/page.tsx +90 -0
- package/templates/app/dashboard/(main)/layout.tsx +98 -0
- package/templates/app/dashboard/(main)/loading.tsx +5 -0
- package/templates/app/dashboard/(main)/page.tsx +201 -0
- package/templates/app/dashboard/(main)/patterns/[id]/edit/page.tsx +114 -0
- package/templates/app/dashboard/(main)/patterns/[id]/page.tsx +20 -0
- package/templates/app/dashboard/(main)/patterns/[id]/reports/page.tsx +171 -0
- package/templates/app/dashboard/(main)/patterns/create/page.tsx +86 -0
- package/templates/app/dashboard/(main)/patterns/page.tsx +444 -0
- package/templates/app/dashboard/features/analytics/page.tsx +35 -0
- package/templates/app/dashboard/features/automation/page.tsx +35 -0
- package/templates/app/dashboard/features/layout.tsx +13 -0
- package/templates/app/dashboard/features/loading.tsx +5 -0
- package/templates/app/dashboard/features/webhooks/page.tsx +35 -0
- package/templates/app/dashboard/layout.tsx +86 -0
- package/templates/app/dashboard/permission-denied/page.tsx +29 -0
- package/templates/app/dashboard/settings/api-keys/loading.tsx +5 -0
- package/templates/app/dashboard/settings/api-keys/page.tsx +513 -0
- package/templates/app/dashboard/settings/billing/loading.tsx +5 -0
- package/templates/app/dashboard/settings/billing/page.tsx +284 -0
- package/templates/app/dashboard/settings/invoices/[invoiceNumber]/page.tsx +222 -0
- package/templates/app/dashboard/settings/invoices/loading.tsx +5 -0
- package/templates/app/dashboard/settings/invoices/page.tsx +82 -0
- package/templates/app/dashboard/settings/layout.tsx +151 -0
- package/templates/app/dashboard/settings/loading.tsx +5 -0
- package/templates/app/dashboard/settings/notifications/loading.tsx +5 -0
- package/templates/app/dashboard/settings/notifications/page.tsx +462 -0
- package/templates/app/dashboard/settings/page.tsx +92 -0
- package/templates/app/dashboard/settings/password/loading.tsx +5 -0
- package/templates/app/dashboard/settings/password/page.tsx +306 -0
- package/templates/app/dashboard/settings/plans/loading.tsx +5 -0
- package/templates/app/dashboard/settings/plans/page.tsx +40 -0
- package/templates/app/dashboard/settings/profile/loading.tsx +5 -0
- package/templates/app/dashboard/settings/profile/page.tsx +686 -0
- package/templates/app/dashboard/settings/security/loading.tsx +5 -0
- package/templates/app/dashboard/settings/security/page.tsx +505 -0
- package/templates/app/dashboard/settings/teams/loading.tsx +5 -0
- package/templates/app/dashboard/settings/teams/page.tsx +272 -0
- package/templates/app/dashboard/settings/teams/permissions/page.tsx +92 -0
- package/templates/app/devtools/blocks/[slug]/page.tsx +39 -0
- package/templates/app/devtools/blocks/page.tsx +31 -0
- package/templates/app/devtools/config/page.tsx +31 -0
- package/templates/app/devtools/features/page.tsx +31 -0
- package/templates/app/devtools/flows/page.tsx +31 -0
- package/templates/app/devtools/layout.tsx +58 -0
- package/templates/app/devtools/page.tsx +121 -0
- package/templates/app/devtools/scheduled-actions/page.tsx +157 -0
- package/templates/app/devtools/style/page.tsx +330 -0
- package/templates/app/devtools/tags/page.tsx +31 -0
- package/templates/app/devtools/tests/[[...path]]/page.tsx +47 -0
- package/templates/app/favicon.ico +0 -0
- package/templates/app/globals.css +12 -0
- package/templates/app/layout.tsx +96 -0
- package/templates/app/public/page.tsx +30 -0
- package/templates/app/superadmin/docs/[section]/[page]/page.tsx +92 -0
- package/templates/app/superadmin/docs/page.tsx +75 -0
- package/templates/app/superadmin/layout.tsx +67 -0
- package/templates/app/superadmin/page.tsx +149 -0
- package/templates/app/superadmin/subscriptions/page.tsx +655 -0
- package/templates/app/superadmin/team-roles/page.tsx +493 -0
- package/templates/app/superadmin/teams/[teamId]/page.tsx +687 -0
- package/templates/app/superadmin/teams/page.tsx +302 -0
- package/templates/app/superadmin/users/[userId]/page.tsx +548 -0
- package/templates/app/superadmin/users/page.tsx +528 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server'
|
|
2
|
+
import { authenticateRequest } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
3
|
+
import { query as dbQuery } from '@nextsparkjs/core/lib/db'
|
|
4
|
+
import { z } from 'zod'
|
|
5
|
+
|
|
6
|
+
const updateCategorySchema = z.object({
|
|
7
|
+
name: z.string().min(1).max(255).optional(),
|
|
8
|
+
slug: z.string().min(2).max(100).regex(/^[a-z0-9-]+$/, 'Slug must be lowercase alphanumeric with dashes').optional(),
|
|
9
|
+
description: z.string().optional(),
|
|
10
|
+
icon: z.string().optional(),
|
|
11
|
+
color: z.string().optional(),
|
|
12
|
+
parentId: z.string().optional(),
|
|
13
|
+
order: z.number().int().optional(),
|
|
14
|
+
isDefault: z.boolean().optional(),
|
|
15
|
+
isActive: z.boolean().optional()
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
// GET /api/v1/post-categories/:id - Get category by ID
|
|
19
|
+
export async function GET(
|
|
20
|
+
request: NextRequest,
|
|
21
|
+
{ params }: { params: Promise<{ id: string }> }
|
|
22
|
+
): Promise<NextResponse> {
|
|
23
|
+
try {
|
|
24
|
+
const { id } = await params
|
|
25
|
+
|
|
26
|
+
const result = await dbQuery(
|
|
27
|
+
`SELECT id, name, slug, description, icon, color, "parentId", "order", "isDefault", "isActive",
|
|
28
|
+
"createdAt", "updatedAt"
|
|
29
|
+
FROM taxonomies
|
|
30
|
+
WHERE id = $1 AND type = 'post_category' AND "deletedAt" IS NULL`,
|
|
31
|
+
[id]
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
if (result.rows.length === 0) {
|
|
35
|
+
return NextResponse.json({ success: false, error: 'Category not found' }, { status: 404 })
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return NextResponse.json({
|
|
39
|
+
success: true,
|
|
40
|
+
data: result.rows[0]
|
|
41
|
+
})
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.error('Error in post-categories API:', err)
|
|
44
|
+
return NextResponse.json({ success: false, error: 'Internal server error' }, { status: 500 })
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// PUT /api/v1/post-categories/:id - Update category
|
|
49
|
+
export async function PUT(
|
|
50
|
+
request: NextRequest,
|
|
51
|
+
{ params }: { params: Promise<{ id: string }> }
|
|
52
|
+
): Promise<NextResponse> {
|
|
53
|
+
try {
|
|
54
|
+
// Dual authentication: API key or session
|
|
55
|
+
const authResult = await authenticateRequest(request)
|
|
56
|
+
if (!authResult.success || !authResult.user) {
|
|
57
|
+
return NextResponse.json({ success: false, error: 'Unauthorized' }, { status: 401 })
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const body = await request.json()
|
|
61
|
+
const data = updateCategorySchema.parse(body)
|
|
62
|
+
const { id } = await params
|
|
63
|
+
|
|
64
|
+
// Verify this is a post_category taxonomy
|
|
65
|
+
const typeCheck = await dbQuery(
|
|
66
|
+
'SELECT id FROM taxonomies WHERE id = $1 AND type = \'post_category\'',
|
|
67
|
+
[id]
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
if (typeCheck.rows.length === 0) {
|
|
71
|
+
return NextResponse.json({ success: false, error: 'Category not found' }, { status: 404 })
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Check slug uniqueness if slug is being updated
|
|
75
|
+
if (data.slug) {
|
|
76
|
+
const slugCheck = await dbQuery(
|
|
77
|
+
'SELECT id FROM taxonomies WHERE type = \'post_category\' AND slug = $1 AND id != $2',
|
|
78
|
+
[data.slug, id]
|
|
79
|
+
)
|
|
80
|
+
if (slugCheck.rows.length > 0) {
|
|
81
|
+
return NextResponse.json(
|
|
82
|
+
{ success: false, error: 'A category with this slug already exists' },
|
|
83
|
+
{ status: 409 }
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Verify parentId exists if provided
|
|
89
|
+
if (data.parentId) {
|
|
90
|
+
const parentCheck = await dbQuery(
|
|
91
|
+
'SELECT id FROM taxonomies WHERE id = $1 AND type = \'post_category\'',
|
|
92
|
+
[data.parentId]
|
|
93
|
+
)
|
|
94
|
+
if (parentCheck.rows.length === 0) {
|
|
95
|
+
return NextResponse.json({
|
|
96
|
+
success: false,
|
|
97
|
+
error: 'Parent category not found'
|
|
98
|
+
}, { status: 400 })
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Prevent circular reference
|
|
102
|
+
if (data.parentId === id) {
|
|
103
|
+
return NextResponse.json({
|
|
104
|
+
success: false,
|
|
105
|
+
error: 'A category cannot be its own parent'
|
|
106
|
+
}, { status: 400 })
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Build the update query dynamically based on provided fields
|
|
111
|
+
const updates: string[] = []
|
|
112
|
+
const values: unknown[] = []
|
|
113
|
+
let paramIndex = 1
|
|
114
|
+
|
|
115
|
+
if (data.name !== undefined) {
|
|
116
|
+
updates.push(`name = $${paramIndex++}`)
|
|
117
|
+
values.push(data.name)
|
|
118
|
+
}
|
|
119
|
+
if (data.slug !== undefined) {
|
|
120
|
+
updates.push(`slug = $${paramIndex++}`)
|
|
121
|
+
values.push(data.slug)
|
|
122
|
+
}
|
|
123
|
+
if (data.description !== undefined) {
|
|
124
|
+
updates.push(`description = $${paramIndex++}`)
|
|
125
|
+
values.push(data.description || null)
|
|
126
|
+
}
|
|
127
|
+
if (data.icon !== undefined) {
|
|
128
|
+
updates.push(`icon = $${paramIndex++}`)
|
|
129
|
+
values.push(data.icon || null)
|
|
130
|
+
}
|
|
131
|
+
if (data.color !== undefined) {
|
|
132
|
+
updates.push(`color = $${paramIndex++}`)
|
|
133
|
+
values.push(data.color || null)
|
|
134
|
+
}
|
|
135
|
+
if (data.parentId !== undefined) {
|
|
136
|
+
updates.push(`"parentId" = $${paramIndex++}`)
|
|
137
|
+
values.push(data.parentId || null)
|
|
138
|
+
}
|
|
139
|
+
if (data.order !== undefined) {
|
|
140
|
+
updates.push(`"order" = $${paramIndex++}`)
|
|
141
|
+
values.push(data.order)
|
|
142
|
+
}
|
|
143
|
+
if (data.isDefault !== undefined) {
|
|
144
|
+
updates.push(`"isDefault" = $${paramIndex++}`)
|
|
145
|
+
values.push(data.isDefault)
|
|
146
|
+
}
|
|
147
|
+
if (data.isActive !== undefined) {
|
|
148
|
+
updates.push(`"isActive" = $${paramIndex++}`)
|
|
149
|
+
values.push(data.isActive)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Only update if there are fields to update
|
|
153
|
+
if (updates.length === 0) {
|
|
154
|
+
// No fields to update, just return current data
|
|
155
|
+
const current = await dbQuery(
|
|
156
|
+
`SELECT id, name, slug, description, icon, color, "parentId", "order", "isDefault", "isActive",
|
|
157
|
+
"createdAt", "updatedAt"
|
|
158
|
+
FROM taxonomies WHERE id = $1`,
|
|
159
|
+
[id]
|
|
160
|
+
)
|
|
161
|
+
return NextResponse.json({ success: true, data: current.rows[0] })
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Add the id as the last parameter
|
|
165
|
+
values.push(id)
|
|
166
|
+
|
|
167
|
+
const query = `UPDATE taxonomies SET ${updates.join(', ')} WHERE id = $${paramIndex} RETURNING *`
|
|
168
|
+
const result = await dbQuery(query, values)
|
|
169
|
+
|
|
170
|
+
if (result.rows.length === 0) {
|
|
171
|
+
return NextResponse.json({ success: false, error: 'Category not found' }, { status: 404 })
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return NextResponse.json({
|
|
175
|
+
success: true,
|
|
176
|
+
data: result.rows[0]
|
|
177
|
+
})
|
|
178
|
+
} catch (err) {
|
|
179
|
+
console.error('Error in post-categories API PUT:', err)
|
|
180
|
+
if (err instanceof z.ZodError) {
|
|
181
|
+
return NextResponse.json({ success: false, error: 'Validation error', details: err.issues }, { status: 400 })
|
|
182
|
+
}
|
|
183
|
+
const errorMessage = err instanceof Error ? err.message : 'Internal server error'
|
|
184
|
+
return NextResponse.json({ success: false, error: errorMessage }, { status: 500 })
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// DELETE /api/v1/post-categories/:id - Delete category
|
|
189
|
+
export async function DELETE(
|
|
190
|
+
request: NextRequest,
|
|
191
|
+
{ params }: { params: Promise<{ id: string }> }
|
|
192
|
+
): Promise<NextResponse> {
|
|
193
|
+
try {
|
|
194
|
+
// Dual authentication: API key or session
|
|
195
|
+
const authResult = await authenticateRequest(request)
|
|
196
|
+
if (!authResult.success || !authResult.user) {
|
|
197
|
+
return NextResponse.json({ success: false, error: 'Unauthorized' }, { status: 401 })
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const { id } = await params
|
|
201
|
+
|
|
202
|
+
// Verify this is a post_category taxonomy
|
|
203
|
+
const typeCheck = await dbQuery(
|
|
204
|
+
'SELECT id FROM taxonomies WHERE id = $1 AND type = \'post_category\'',
|
|
205
|
+
[id]
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
if (typeCheck.rows.length === 0) {
|
|
209
|
+
return NextResponse.json({ success: false, error: 'Category not found' }, { status: 404 })
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Check if category is used by any posts (using entity_taxonomy_relations)
|
|
213
|
+
let usageCount = 0
|
|
214
|
+
try {
|
|
215
|
+
const usageCheck = await dbQuery<{ count: string }>(
|
|
216
|
+
`SELECT COUNT(*) as count FROM entity_taxonomy_relations
|
|
217
|
+
WHERE "taxonomyId" = $1 AND "entityType" = 'posts'`,
|
|
218
|
+
[id]
|
|
219
|
+
)
|
|
220
|
+
usageCount = parseInt(usageCheck.rows[0].count)
|
|
221
|
+
} catch {
|
|
222
|
+
// Table might not exist yet, assume no usage
|
|
223
|
+
usageCount = 0
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Soft delete if used, hard delete if not used
|
|
227
|
+
if (usageCount > 0) {
|
|
228
|
+
// Soft delete: SET deletedAt = now()
|
|
229
|
+
await dbQuery(
|
|
230
|
+
'UPDATE taxonomies SET "deletedAt" = now() WHERE id = $1',
|
|
231
|
+
[id]
|
|
232
|
+
)
|
|
233
|
+
return NextResponse.json({
|
|
234
|
+
success: true,
|
|
235
|
+
data: { id, deleted: 'soft', message: 'Category soft-deleted (still referenced by posts)' }
|
|
236
|
+
})
|
|
237
|
+
} else {
|
|
238
|
+
// Hard delete: No posts use it
|
|
239
|
+
const result = await dbQuery<{ id: string }>(
|
|
240
|
+
'DELETE FROM taxonomies WHERE id = $1 RETURNING id',
|
|
241
|
+
[id]
|
|
242
|
+
)
|
|
243
|
+
if (result.rows.length === 0) {
|
|
244
|
+
return NextResponse.json({ success: false, error: 'Category not found' }, { status: 404 })
|
|
245
|
+
}
|
|
246
|
+
return NextResponse.json({
|
|
247
|
+
success: true,
|
|
248
|
+
data: { id: result.rows[0].id, deleted: 'hard' }
|
|
249
|
+
})
|
|
250
|
+
}
|
|
251
|
+
} catch (err) {
|
|
252
|
+
console.error('Error in post-categories API DELETE:', err)
|
|
253
|
+
return NextResponse.json({ success: false, error: 'Internal server error' }, { status: 500 })
|
|
254
|
+
}
|
|
255
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Post Categories API
|
|
2
|
+
|
|
3
|
+
Manage blog post categories (taxonomies).
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Post Categories API provides endpoints for managing blog post categories. Categories are stored in the `taxonomies` table with type `post_category`. Supports hierarchical categories with parent-child relationships.
|
|
8
|
+
|
|
9
|
+
## Authentication
|
|
10
|
+
|
|
11
|
+
- **GET** endpoints are public (no authentication required)
|
|
12
|
+
- **POST/PATCH/DELETE** endpoints require authentication via session cookie or API key
|
|
13
|
+
|
|
14
|
+
## Endpoints
|
|
15
|
+
|
|
16
|
+
### List Categories
|
|
17
|
+
`GET /api/v1/post-categories`
|
|
18
|
+
|
|
19
|
+
Returns all active post categories ordered by sort order and name.
|
|
20
|
+
|
|
21
|
+
**Example Response:**
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"success": true,
|
|
25
|
+
"data": [
|
|
26
|
+
{
|
|
27
|
+
"id": "cat_123",
|
|
28
|
+
"name": "Technology",
|
|
29
|
+
"slug": "technology",
|
|
30
|
+
"description": "Tech news and tutorials",
|
|
31
|
+
"icon": "Cpu",
|
|
32
|
+
"color": "#3b82f6",
|
|
33
|
+
"parentId": null,
|
|
34
|
+
"order": 1,
|
|
35
|
+
"isDefault": false,
|
|
36
|
+
"isActive": true,
|
|
37
|
+
"createdAt": "2024-01-15T10:00:00Z",
|
|
38
|
+
"updatedAt": "2024-01-15T10:00:00Z"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Create Category
|
|
45
|
+
`POST /api/v1/post-categories`
|
|
46
|
+
|
|
47
|
+
Create a new post category.
|
|
48
|
+
|
|
49
|
+
**Request Body:**
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"name": "Technology",
|
|
53
|
+
"slug": "technology",
|
|
54
|
+
"description": "Tech news and tutorials",
|
|
55
|
+
"icon": "Cpu",
|
|
56
|
+
"color": "#3b82f6",
|
|
57
|
+
"parentId": null,
|
|
58
|
+
"order": 1,
|
|
59
|
+
"isDefault": false
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Parameters:**
|
|
64
|
+
- `name` (string, required): Category display name (1-255 chars)
|
|
65
|
+
- `slug` (string, optional): URL-friendly identifier (auto-generated if not provided)
|
|
66
|
+
- `description` (string, optional): Category description
|
|
67
|
+
- `icon` (string, optional): Lucide icon name
|
|
68
|
+
- `color` (string, optional): Hex color code
|
|
69
|
+
- `parentId` (string, optional): Parent category ID for hierarchical categories
|
|
70
|
+
- `order` (number, optional): Sort order (default: 0)
|
|
71
|
+
- `isDefault` (boolean, optional): Mark as default category (default: false)
|
|
72
|
+
|
|
73
|
+
**Slug Rules:**
|
|
74
|
+
- Lowercase alphanumeric with dashes only
|
|
75
|
+
- 2-100 characters
|
|
76
|
+
- Pattern: `^[a-z0-9-]+$`
|
|
77
|
+
- Must be unique within post categories
|
|
78
|
+
|
|
79
|
+
### Get Category
|
|
80
|
+
`GET /api/v1/post-categories/[id]`
|
|
81
|
+
|
|
82
|
+
Returns a single category by ID.
|
|
83
|
+
|
|
84
|
+
**Path Parameters:**
|
|
85
|
+
- `id` (string, required): Category ID
|
|
86
|
+
|
|
87
|
+
### Update Category
|
|
88
|
+
`PATCH /api/v1/post-categories/[id]`
|
|
89
|
+
|
|
90
|
+
Update an existing category. Partial updates supported.
|
|
91
|
+
|
|
92
|
+
**Path Parameters:**
|
|
93
|
+
- `id` (string, required): Category ID
|
|
94
|
+
|
|
95
|
+
**Request Body:**
|
|
96
|
+
Any fields from the create schema (partial update).
|
|
97
|
+
|
|
98
|
+
### Delete Category
|
|
99
|
+
`DELETE /api/v1/post-categories/[id]`
|
|
100
|
+
|
|
101
|
+
Soft delete a category (sets `deletedAt`).
|
|
102
|
+
|
|
103
|
+
**Path Parameters:**
|
|
104
|
+
- `id` (string, required): Category ID
|
|
105
|
+
|
|
106
|
+
## Hierarchical Categories
|
|
107
|
+
|
|
108
|
+
Categories support parent-child relationships:
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"name": "JavaScript",
|
|
113
|
+
"slug": "javascript",
|
|
114
|
+
"parentId": "cat_technology"
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
When listing categories, use `parentId` to build tree structures client-side.
|
|
119
|
+
|
|
120
|
+
## Error Responses
|
|
121
|
+
|
|
122
|
+
| Status | Description |
|
|
123
|
+
|--------|-------------|
|
|
124
|
+
| 400 | Bad Request - Validation error or slug already exists |
|
|
125
|
+
| 401 | Unauthorized - Authentication required for write operations |
|
|
126
|
+
| 404 | Not Found - Category or parent category not found |
|
|
127
|
+
| 500 | Server Error - Internal error |
|
|
128
|
+
|
|
129
|
+
## Usage Notes
|
|
130
|
+
|
|
131
|
+
- Categories are stored in the `taxonomies` table with `type = 'post_category'`
|
|
132
|
+
- Only active categories (`isActive = true`, `deletedAt IS NULL`) are returned
|
|
133
|
+
- Slugs are auto-generated from name if not provided
|
|
134
|
+
- The `order` field controls sort order in listings
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Presets for Post Categories
|
|
3
|
+
*
|
|
4
|
+
* These presets appear in the DevTools API Explorer's "Presets" tab.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { defineApiEndpoint } from '@nextsparkjs/core/types/api-presets'
|
|
8
|
+
|
|
9
|
+
export default defineApiEndpoint({
|
|
10
|
+
endpoint: '/api/v1/post-categories',
|
|
11
|
+
summary: 'Manage blog post categories (taxonomies)',
|
|
12
|
+
presets: [
|
|
13
|
+
// List
|
|
14
|
+
{
|
|
15
|
+
id: 'list-all',
|
|
16
|
+
title: 'List All Categories',
|
|
17
|
+
description: 'Fetch all active post categories',
|
|
18
|
+
method: 'GET',
|
|
19
|
+
tags: ['read', 'list']
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
// Create
|
|
23
|
+
{
|
|
24
|
+
id: 'create-category',
|
|
25
|
+
title: 'Create Category',
|
|
26
|
+
description: 'Create a new post category',
|
|
27
|
+
method: 'POST',
|
|
28
|
+
payload: {
|
|
29
|
+
name: 'Technology',
|
|
30
|
+
description: 'Tech news and tutorials',
|
|
31
|
+
icon: 'Cpu',
|
|
32
|
+
color: '#3b82f6',
|
|
33
|
+
order: 1
|
|
34
|
+
},
|
|
35
|
+
tags: ['write', 'create']
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 'create-category-with-slug',
|
|
39
|
+
title: 'Create with Custom Slug',
|
|
40
|
+
description: 'Create category with explicit slug',
|
|
41
|
+
method: 'POST',
|
|
42
|
+
payload: {
|
|
43
|
+
name: 'Web Development',
|
|
44
|
+
slug: 'web-dev',
|
|
45
|
+
description: 'Web development tutorials and tips',
|
|
46
|
+
order: 2
|
|
47
|
+
},
|
|
48
|
+
tags: ['write', 'create']
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'create-subcategory',
|
|
52
|
+
title: 'Create Subcategory',
|
|
53
|
+
description: 'Create child category with parent',
|
|
54
|
+
method: 'POST',
|
|
55
|
+
payload: {
|
|
56
|
+
name: 'JavaScript',
|
|
57
|
+
slug: 'javascript',
|
|
58
|
+
parentId: 'parent_category_id_here',
|
|
59
|
+
description: 'JavaScript tutorials',
|
|
60
|
+
order: 1
|
|
61
|
+
},
|
|
62
|
+
tags: ['write', 'create', 'hierarchy']
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'create-default-category',
|
|
66
|
+
title: 'Create Default Category',
|
|
67
|
+
description: 'Create category marked as default',
|
|
68
|
+
method: 'POST',
|
|
69
|
+
payload: {
|
|
70
|
+
name: 'Uncategorized',
|
|
71
|
+
slug: 'uncategorized',
|
|
72
|
+
isDefault: true,
|
|
73
|
+
order: 999
|
|
74
|
+
},
|
|
75
|
+
tags: ['write', 'create']
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
})
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server'
|
|
2
|
+
import { authenticateRequest } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
3
|
+
import { query as dbQuery } from '@nextsparkjs/core/lib/db'
|
|
4
|
+
import { z } from 'zod'
|
|
5
|
+
|
|
6
|
+
const createCategorySchema = z.object({
|
|
7
|
+
name: z.string().min(1).max(255),
|
|
8
|
+
slug: z.string().min(2).max(100).regex(/^[a-z0-9-]+$/, 'Slug must be lowercase alphanumeric with dashes').optional(),
|
|
9
|
+
description: z.string().optional(),
|
|
10
|
+
icon: z.string().optional(),
|
|
11
|
+
color: z.string().optional(),
|
|
12
|
+
parentId: z.string().optional(),
|
|
13
|
+
order: z.number().int().default(0),
|
|
14
|
+
isDefault: z.boolean().default(false)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
// Helper to generate slug from name
|
|
18
|
+
function generateSlug(name: string): string {
|
|
19
|
+
return name
|
|
20
|
+
.toLowerCase()
|
|
21
|
+
.trim()
|
|
22
|
+
.replace(/[^a-z0-9\s-]/g, '') // Remove special chars
|
|
23
|
+
.replace(/\s+/g, '-') // Replace spaces with dashes
|
|
24
|
+
.replace(/-+/g, '-') // Replace multiple dashes with single
|
|
25
|
+
.replace(/^-|-$/g, '') // Remove leading/trailing dashes
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// GET /api/v1/post-categories - List categories (filters taxonomies by type = 'post_category')
|
|
29
|
+
export async function GET() {
|
|
30
|
+
try {
|
|
31
|
+
const result = await dbQuery(
|
|
32
|
+
`SELECT id, name, slug, description, icon, color, "parentId", "order", "isDefault", "isActive",
|
|
33
|
+
"createdAt", "updatedAt"
|
|
34
|
+
FROM taxonomies
|
|
35
|
+
WHERE type = 'post_category' AND "deletedAt" IS NULL AND "isActive" = true
|
|
36
|
+
ORDER BY "order" ASC, name ASC`
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
return NextResponse.json({
|
|
40
|
+
success: true,
|
|
41
|
+
data: result.rows
|
|
42
|
+
})
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('Error fetching post categories:', error)
|
|
45
|
+
return NextResponse.json({ success: false, error: 'Internal server error' }, { status: 500 })
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// POST /api/v1/post-categories - Create category
|
|
50
|
+
export async function POST(request: NextRequest) {
|
|
51
|
+
try {
|
|
52
|
+
// Dual authentication: API key or session
|
|
53
|
+
const authResult = await authenticateRequest(request)
|
|
54
|
+
if (!authResult.success || !authResult.user) {
|
|
55
|
+
return NextResponse.json({ success: false, error: 'Unauthorized' }, { status: 401 })
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const body = await request.json()
|
|
59
|
+
const data = createCategorySchema.parse(body)
|
|
60
|
+
|
|
61
|
+
// Auto-generate slug if not provided
|
|
62
|
+
const slug = data.slug || generateSlug(data.name)
|
|
63
|
+
|
|
64
|
+
// Check slug uniqueness for this taxonomy type
|
|
65
|
+
const existing = await dbQuery(
|
|
66
|
+
'SELECT id FROM taxonomies WHERE type = \'post_category\' AND slug = $1',
|
|
67
|
+
[slug]
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
if (existing.rows.length > 0) {
|
|
71
|
+
return NextResponse.json({
|
|
72
|
+
success: false,
|
|
73
|
+
error: 'Slug already exists',
|
|
74
|
+
message: `A category with slug "${slug}" already exists`
|
|
75
|
+
}, { status: 400 })
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Verify parentId exists if provided
|
|
79
|
+
if (data.parentId) {
|
|
80
|
+
const parentCheck = await dbQuery(
|
|
81
|
+
'SELECT id FROM taxonomies WHERE id = $1 AND type = \'post_category\'',
|
|
82
|
+
[data.parentId]
|
|
83
|
+
)
|
|
84
|
+
if (parentCheck.rows.length === 0) {
|
|
85
|
+
return NextResponse.json({
|
|
86
|
+
success: false,
|
|
87
|
+
error: 'Parent category not found'
|
|
88
|
+
}, { status: 400 })
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Insert category (type is hardcoded to 'post_category')
|
|
93
|
+
const result = await dbQuery(
|
|
94
|
+
`INSERT INTO taxonomies (
|
|
95
|
+
type, slug, name, description, icon, color, "parentId", "order", "isDefault", "userId"
|
|
96
|
+
) VALUES ('post_category', $1, $2, $3, $4, $5, $6, $7, $8, $9)
|
|
97
|
+
RETURNING *`,
|
|
98
|
+
[
|
|
99
|
+
slug,
|
|
100
|
+
data.name,
|
|
101
|
+
data.description || null,
|
|
102
|
+
data.icon || null,
|
|
103
|
+
data.color || null,
|
|
104
|
+
data.parentId || null,
|
|
105
|
+
data.order,
|
|
106
|
+
data.isDefault,
|
|
107
|
+
authResult.user.id
|
|
108
|
+
]
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
return NextResponse.json({ success: true, data: result.rows[0] }, { status: 201 })
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (error instanceof z.ZodError) {
|
|
114
|
+
return NextResponse.json({ success: false, error: 'Validation error', details: error.issues }, { status: 400 })
|
|
115
|
+
}
|
|
116
|
+
console.error('Error creating post category:', error)
|
|
117
|
+
return NextResponse.json({ success: false, error: 'Internal server error' }, { status: 500 })
|
|
118
|
+
}
|
|
119
|
+
}
|