create-pet-adopt 0.0.0 → 0.3.0
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/LICENSE +21 -0
- package/README.md +120 -0
- package/index.js +920 -0
- package/package.json +43 -1
- package/template/.env.example +136 -0
- package/template/.pet-adopt/template.json +581 -0
- package/template/LICENSE +21 -0
- package/template/README.md +109 -0
- package/template/_gitignore +28 -0
- package/template/_pnpm-lock.yaml +9251 -0
- package/template/assets/sample-pet.png +0 -0
- package/template/components.json +25 -0
- package/template/docker-compose.yml +110 -0
- package/template/drizzle/pg/0000_initial.sql +176 -0
- package/template/drizzle/pg/0001_greedy_the_renegades.sql +1 -0
- package/template/drizzle/pg/0002_fuzzy_the_renegades.sql +1 -0
- package/template/drizzle/pg/0003_thin_multiple_man.sql +1 -0
- package/template/drizzle/pg/0004_boring_norman_osborn.sql +15 -0
- package/template/drizzle/pg/0005_bitter_proemial_gods.sql +3 -0
- package/template/drizzle/pg/0006_friendly_black_knight.sql +2 -0
- package/template/drizzle/pg/0007_wise_ozymandias.sql +11 -0
- package/template/drizzle/pg/0008_messy_human_fly.sql +2 -0
- package/template/drizzle/pg/0009_amused_lady_bullseye.sql +1 -0
- package/template/drizzle/pg/0010_cute_mauler.sql +7 -0
- package/template/drizzle/pg/0011_clear_purple_man.sql +3 -0
- package/template/drizzle/pg/0012_tiresome_gunslinger.sql +2 -0
- package/template/drizzle/pg/0013_awesome_wong.sql +18 -0
- package/template/drizzle/pg/0014_fantastic_sumo.sql +12 -0
- package/template/drizzle/pg/0015_pink_carnage.sql +12 -0
- package/template/drizzle/pg/0016_sloppy_king_bedlam.sql +2 -0
- package/template/drizzle/pg/0017_steep_warhawk.sql +15 -0
- package/template/drizzle/pg/0018_mixed_otto_octavius.sql +4 -0
- package/template/drizzle/pg/0019_talented_rocket_raccoon.sql +1 -0
- package/template/drizzle/pg/0020_worthless_zodiak.sql +19 -0
- package/template/drizzle/pg/0021_adorable_squadron_supreme.sql +1 -0
- package/template/drizzle/pg/0022_soft_pixie.sql +5 -0
- package/template/drizzle/pg/0023_fluffy_quasar.sql +1 -0
- package/template/drizzle/pg/0024_uneven_ken_ellis.sql +2 -0
- package/template/drizzle/pg/0025_rich_white_queen.sql +3 -0
- package/template/drizzle/pg/0026_spooky_komodo.sql +16 -0
- package/template/drizzle/pg/0027_big_thunderbolts.sql +2 -0
- package/template/drizzle/pg/meta/0000_snapshot.json +1265 -0
- package/template/drizzle/pg/meta/0001_snapshot.json +1272 -0
- package/template/drizzle/pg/meta/0002_snapshot.json +1278 -0
- package/template/drizzle/pg/meta/0003_snapshot.json +1284 -0
- package/template/drizzle/pg/meta/0004_snapshot.json +1401 -0
- package/template/drizzle/pg/meta/0005_snapshot.json +1401 -0
- package/template/drizzle/pg/meta/0006_snapshot.json +1414 -0
- package/template/drizzle/pg/meta/0007_snapshot.json +1485 -0
- package/template/drizzle/pg/meta/0008_snapshot.json +1504 -0
- package/template/drizzle/pg/meta/0009_snapshot.json +1510 -0
- package/template/drizzle/pg/meta/0010_snapshot.json +1556 -0
- package/template/drizzle/pg/meta/0011_snapshot.json +1574 -0
- package/template/drizzle/pg/meta/0012_snapshot.json +1586 -0
- package/template/drizzle/pg/meta/0013_snapshot.json +1730 -0
- package/template/drizzle/pg/meta/0014_snapshot.json +1805 -0
- package/template/drizzle/pg/meta/0015_snapshot.json +1883 -0
- package/template/drizzle/pg/meta/0016_snapshot.json +1897 -0
- package/template/drizzle/pg/meta/0017_snapshot.json +2013 -0
- package/template/drizzle/pg/meta/0018_snapshot.json +1988 -0
- package/template/drizzle/pg/meta/0019_snapshot.json +1994 -0
- package/template/drizzle/pg/meta/0020_snapshot.json +2108 -0
- package/template/drizzle/pg/meta/0021_snapshot.json +2114 -0
- package/template/drizzle/pg/meta/0022_snapshot.json +2126 -0
- package/template/drizzle/pg/meta/0023_snapshot.json +2132 -0
- package/template/drizzle/pg/meta/0024_snapshot.json +2151 -0
- package/template/drizzle/pg/meta/0025_snapshot.json +2169 -0
- package/template/drizzle/pg/meta/0026_snapshot.json +2294 -0
- package/template/drizzle/pg/meta/0027_snapshot.json +2330 -0
- package/template/drizzle/pg/meta/_journal.json +202 -0
- package/template/drizzle/sqlite/0000_initial.sql +176 -0
- package/template/drizzle/sqlite/0001_easy_sebastian_shaw.sql +1 -0
- package/template/drizzle/sqlite/0002_past_king_cobra.sql +1 -0
- package/template/drizzle/sqlite/0003_organic_masked_marvel.sql +1 -0
- package/template/drizzle/sqlite/0004_panoramic_inhumans.sql +15 -0
- package/template/drizzle/sqlite/0005_small_sunset_bain.sql +19 -0
- package/template/drizzle/sqlite/0006_narrow_medusa.sql +2 -0
- package/template/drizzle/sqlite/0007_gray_grandmaster.sql +10 -0
- package/template/drizzle/sqlite/0008_chief_toxin.sql +1 -0
- package/template/drizzle/sqlite/0009_vengeful_tag.sql +1 -0
- package/template/drizzle/sqlite/0010_kind_klaw.sql +7 -0
- package/template/drizzle/sqlite/0011_overrated_meltdown.sql +3 -0
- package/template/drizzle/sqlite/0012_robust_next_avengers.sql +2 -0
- package/template/drizzle/sqlite/0013_melodic_kitty_pryde.sql +18 -0
- package/template/drizzle/sqlite/0014_stormy_cyclops.sql +12 -0
- package/template/drizzle/sqlite/0015_parallel_mongu.sql +11 -0
- package/template/drizzle/sqlite/0016_grey_quicksilver.sql +2 -0
- package/template/drizzle/sqlite/0017_daily_psylocke.sql +15 -0
- package/template/drizzle/sqlite/0018_whole_redwing.sql +4 -0
- package/template/drizzle/sqlite/0019_spotty_mandroid.sql +1 -0
- package/template/drizzle/sqlite/0020_wild_wendell_rand.sql +19 -0
- package/template/drizzle/sqlite/0021_calm_lockheed.sql +1 -0
- package/template/drizzle/sqlite/0022_lonely_emma_frost.sql +5 -0
- package/template/drizzle/sqlite/0023_elite_tony_stark.sql +1 -0
- package/template/drizzle/sqlite/0024_little_lily_hollister.sql +1 -0
- package/template/drizzle/sqlite/0025_tough_shotgun.sql +3 -0
- package/template/drizzle/sqlite/0026_faithful_mephistopheles.sql +16 -0
- package/template/drizzle/sqlite/0027_rapid_arclight.sql +2 -0
- package/template/drizzle/sqlite/meta/0000_snapshot.json +1237 -0
- package/template/drizzle/sqlite/meta/0001_snapshot.json +1245 -0
- package/template/drizzle/sqlite/meta/0002_snapshot.json +1252 -0
- package/template/drizzle/sqlite/meta/0003_snapshot.json +1259 -0
- package/template/drizzle/sqlite/meta/0004_snapshot.json +1369 -0
- package/template/drizzle/sqlite/meta/0005_snapshot.json +1369 -0
- package/template/drizzle/sqlite/meta/0006_snapshot.json +1384 -0
- package/template/drizzle/sqlite/meta/0007_snapshot.json +1459 -0
- package/template/drizzle/sqlite/meta/0008_snapshot.json +1479 -0
- package/template/drizzle/sqlite/meta/0009_snapshot.json +1486 -0
- package/template/drizzle/sqlite/meta/0010_snapshot.json +1533 -0
- package/template/drizzle/sqlite/meta/0011_snapshot.json +1554 -0
- package/template/drizzle/sqlite/meta/0012_snapshot.json +1568 -0
- package/template/drizzle/sqlite/meta/0013_snapshot.json +1687 -0
- package/template/drizzle/sqlite/meta/0014_snapshot.json +1769 -0
- package/template/drizzle/sqlite/meta/0015_snapshot.json +1852 -0
- package/template/drizzle/sqlite/meta/0016_snapshot.json +1867 -0
- package/template/drizzle/sqlite/meta/0017_snapshot.json +1973 -0
- package/template/drizzle/sqlite/meta/0018_snapshot.json +1944 -0
- package/template/drizzle/sqlite/meta/0019_snapshot.json +1951 -0
- package/template/drizzle/sqlite/meta/0020_snapshot.json +2077 -0
- package/template/drizzle/sqlite/meta/0021_snapshot.json +2084 -0
- package/template/drizzle/sqlite/meta/0022_snapshot.json +2098 -0
- package/template/drizzle/sqlite/meta/0023_snapshot.json +2105 -0
- package/template/drizzle/sqlite/meta/0024_snapshot.json +2125 -0
- package/template/drizzle/sqlite/meta/0025_snapshot.json +2146 -0
- package/template/drizzle/sqlite/meta/0026_snapshot.json +2265 -0
- package/template/drizzle/sqlite/meta/0027_snapshot.json +2280 -0
- package/template/drizzle/sqlite/meta/_journal.json +202 -0
- package/template/drizzle.pg.config.ts +8 -0
- package/template/drizzle.sqlite.config.ts +8 -0
- package/template/eslint.config.mjs +22 -0
- package/template/next.config.ts +153 -0
- package/template/package.json +102 -0
- package/template/pet-adopt.blocks.ts +9 -0
- package/template/pet-adopt.config.ts +17 -0
- package/template/pnpm-workspace.yaml +19 -0
- package/template/postcss.config.mjs +5 -0
- package/template/scripts/check-routes.ts +405 -0
- package/template/scripts/check-schemas.ts +58 -0
- package/template/scripts/migrate-all.ts +25 -0
- package/template/scripts/migrate-on-build.ts +71 -0
- package/template/scripts/migrate.ts +20 -0
- package/template/scripts/plugin-generate.ts +92 -0
- package/template/scripts/reset-password.ts +45 -0
- package/template/scripts/reset-two-factor.ts +53 -0
- package/template/scripts/seed.ts +79 -0
- package/template/scripts/setup-env.ts +91 -0
- package/template/scripts/storage-check.ts +53 -0
- package/template/src/app/(admin)/admin/account/AccountForms.tsx +194 -0
- package/template/src/app/(admin)/admin/account/page.tsx +59 -0
- package/template/src/app/(admin)/admin/activity/page.tsx +76 -0
- package/template/src/app/(admin)/admin/authentication/archived/page.tsx +24 -0
- package/template/src/app/(admin)/admin/authentication/layout.tsx +20 -0
- package/template/src/app/(admin)/admin/authentication/page.tsx +36 -0
- package/template/src/app/(admin)/admin/authentication/providers/page.tsx +33 -0
- package/template/src/app/(admin)/admin/email/layout.tsx +21 -0
- package/template/src/app/(admin)/admin/email/page.tsx +43 -0
- package/template/src/app/(admin)/admin/email/templates/page.tsx +38 -0
- package/template/src/app/(admin)/admin/error.tsx +36 -0
- package/template/src/app/(admin)/admin/layout.tsx +26 -0
- package/template/src/app/(admin)/admin/loading.tsx +9 -0
- package/template/src/app/(admin)/admin/media/[id]/page.tsx +97 -0
- package/template/src/app/(admin)/admin/media/page.tsx +34 -0
- package/template/src/app/(admin)/admin/media/search-params.ts +16 -0
- package/template/src/app/(admin)/admin/page.tsx +79 -0
- package/template/src/app/(admin)/admin/pages/PageForm.tsx +604 -0
- package/template/src/app/(admin)/admin/pages/[id]/page.tsx +51 -0
- package/template/src/app/(admin)/admin/pages/new/page.tsx +19 -0
- package/template/src/app/(admin)/admin/pages/page.tsx +49 -0
- package/template/src/app/(admin)/admin/pets/PetForm.tsx +437 -0
- package/template/src/app/(admin)/admin/pets/[id]/page.tsx +41 -0
- package/template/src/app/(admin)/admin/pets/new/page.tsx +26 -0
- package/template/src/app/(admin)/admin/pets/page.tsx +70 -0
- package/template/src/app/(admin)/admin/pets/search-params.ts +16 -0
- package/template/src/app/(admin)/admin/plugins/[plugin]/[[...path]]/page.tsx +73 -0
- package/template/src/app/(admin)/admin/plugins/page.tsx +66 -0
- package/template/src/app/(admin)/admin/settings/SettingsForm.tsx +644 -0
- package/template/src/app/(admin)/admin/settings/email/page.tsx +9 -0
- package/template/src/app/(admin)/admin/settings/page.tsx +40 -0
- package/template/src/app/(admin)/admin/settings/templates/page.tsx +9 -0
- package/template/src/app/(admin)/admin/theme/[id]/page.tsx +28 -0
- package/template/src/app/(admin)/admin/theme/page.tsx +30 -0
- package/template/src/app/(admin)/admin/users/page.tsx +33 -0
- package/template/src/app/(admin)/layout.tsx +75 -0
- package/template/src/app/(admin)/providers.tsx +42 -0
- package/template/src/app/(auth)/admin/confirm-email/page.tsx +40 -0
- package/template/src/app/(auth)/admin/invite/page.tsx +38 -0
- package/template/src/app/(auth)/admin/login/DemoSignIn.tsx +69 -0
- package/template/src/app/(auth)/admin/login/page.tsx +83 -0
- package/template/src/app/(auth)/admin/reset-password/page.tsx +73 -0
- package/template/src/app/(auth)/error.tsx +9 -0
- package/template/src/app/(auth)/layout.tsx +71 -0
- package/template/src/app/(editor)/EditorToast.tsx +43 -0
- package/template/src/app/(editor)/edit/[id]/PageEditor.tsx +586 -0
- package/template/src/app/(editor)/edit/[id]/actions.ts +139 -0
- package/template/src/app/(editor)/edit/[id]/page.tsx +76 -0
- package/template/src/app/(editor)/edit/[id]/preview/page.tsx +81 -0
- package/template/src/app/(editor)/edit/email/[id]/EmailEditor.tsx +236 -0
- package/template/src/app/(editor)/edit/email/[id]/page.tsx +64 -0
- package/template/src/app/(editor)/edit/theme-preview/page.tsx +94 -0
- package/template/src/app/(editor)/editor.css +223 -0
- package/template/src/app/(editor)/error.tsx +32 -0
- package/template/src/app/(editor)/layout.tsx +67 -0
- package/template/src/app/(frontend)/[slug]/page.tsx +53 -0
- package/template/src/app/(frontend)/fonts.ts +8 -0
- package/template/src/app/(frontend)/layout.tsx +107 -0
- package/template/src/app/(frontend)/not-found.tsx +16 -0
- package/template/src/app/(frontend)/page.tsx +42 -0
- package/template/src/app/(frontend)/pets/[slug]/page.tsx +92 -0
- package/template/src/app/(frontend)/pets/page.tsx +42 -0
- package/template/src/app/(frontend)/styles.css +537 -0
- package/template/src/app/(setup)/error.tsx +9 -0
- package/template/src/app/(setup)/layout.tsx +41 -0
- package/template/src/app/(setup)/setup/page.tsx +105 -0
- package/template/src/app/(setup)/setup/storage-check.ts +43 -0
- package/template/src/app/api/auth/[...all]/route.ts +144 -0
- package/template/src/app/health/route.ts +9 -0
- package/template/src/app/media/[...path]/route.ts +45 -0
- package/template/src/app/media/email/[name]/route.ts +60 -0
- package/template/src/app/robots.ts +19 -0
- package/template/src/app/sitemap.ts +24 -0
- package/template/src/components/admin/AdminNav.tsx +153 -0
- package/template/src/components/admin/AdminShell.tsx +107 -0
- package/template/src/components/admin/DemoNotice.tsx +31 -0
- package/template/src/components/admin/EmailConfirmBanner.tsx +44 -0
- package/template/src/components/admin/EmptyState.tsx +10 -0
- package/template/src/components/admin/ErrorSummary.tsx +72 -0
- package/template/src/components/admin/MediaDetails.tsx +218 -0
- package/template/src/components/admin/MediaGrid.tsx +307 -0
- package/template/src/components/admin/MediaLibrary.tsx +103 -0
- package/template/src/components/admin/MediaPager.tsx +66 -0
- package/template/src/components/admin/PageHeader.tsx +22 -0
- package/template/src/components/admin/PhoneInput.tsx +128 -0
- package/template/src/components/admin/PluginWidgetBoundary.tsx +38 -0
- package/template/src/components/admin/PluginWidgets.tsx +51 -0
- package/template/src/components/admin/RemountOnNavigate.tsx +37 -0
- package/template/src/components/admin/StatusBadge.tsx +16 -0
- package/template/src/components/admin/UploadPhotosDialog.tsx +387 -0
- package/template/src/components/admin/UserAvatar.tsx +18 -0
- package/template/src/components/admin/UserMenu.tsx +118 -0
- package/template/src/components/admin/ViewSiteLink.tsx +24 -0
- package/template/src/components/admin/account/ConnectedProviders.tsx +91 -0
- package/template/src/components/admin/account/DeleteAccountCard.tsx +136 -0
- package/template/src/components/admin/account/EmailCard.tsx +137 -0
- package/template/src/components/admin/account/ProfilePicture.tsx +159 -0
- package/template/src/components/admin/activity/ActivityFilters.tsx +146 -0
- package/template/src/components/admin/activity/ActivityLog.tsx +159 -0
- package/template/src/components/admin/activity/RecentActivity.tsx +52 -0
- package/template/src/components/admin/demo-mode.tsx +17 -0
- package/template/src/components/admin/nav-items.ts +47 -0
- package/template/src/components/admin/pages/PageDetails.tsx +198 -0
- package/template/src/components/admin/pages/PageVersions.tsx +296 -0
- package/template/src/components/admin/pages/PagesTable.tsx +467 -0
- package/template/src/components/admin/pets/FilterBar.tsx +154 -0
- package/template/src/components/admin/pets/PetCard.tsx +170 -0
- package/template/src/components/admin/pets/PetList.tsx +112 -0
- package/template/src/components/admin/pets/PetListSkeleton.tsx +84 -0
- package/template/src/components/admin/pets/PetPagination.tsx +91 -0
- package/template/src/components/admin/pets/form/AgeFields.tsx +132 -0
- package/template/src/components/admin/pets/form/LocationFields.tsx +231 -0
- package/template/src/components/admin/pets/form/MediaPickerDialog.tsx +359 -0
- package/template/src/components/admin/pets/form/PhotosField.tsx +176 -0
- package/template/src/components/admin/pets/form/RichTextField.tsx +438 -0
- package/template/src/components/admin/pets/form/SeoImageField.tsx +87 -0
- package/template/src/components/admin/pets/form/SeoPreview.tsx +142 -0
- package/template/src/components/admin/pets/form/fields.tsx +434 -0
- package/template/src/components/admin/pets/form/rich-text-extensions.ts +45 -0
- package/template/src/components/admin/pets/timeline/PetTimeline.tsx +297 -0
- package/template/src/components/admin/pets/timeline/TimelineEntryForm.tsx +289 -0
- package/template/src/components/admin/pets/timeline/TimelinePhotosField.tsx +173 -0
- package/template/src/components/admin/plugins/PluginNotReady.tsx +28 -0
- package/template/src/components/admin/plugins/PluginOverview.tsx +121 -0
- package/template/src/components/admin/plugins/SendTestEmail.tsx +70 -0
- package/template/src/components/admin/settings/AuthProviders.tsx +373 -0
- package/template/src/components/admin/settings/AuthenticationNav.tsx +42 -0
- package/template/src/components/admin/settings/EmailNav.tsx +40 -0
- package/template/src/components/admin/settings/EmailSettingsForm.tsx +325 -0
- package/template/src/components/admin/settings/EmailTemplates.tsx +551 -0
- package/template/src/components/admin/settings/RegionFields.tsx +203 -0
- package/template/src/components/admin/site-time.tsx +26 -0
- package/template/src/components/admin/theme/ThemeEditor.tsx +467 -0
- package/template/src/components/admin/theme/ThemeLibrary.tsx +339 -0
- package/template/src/components/admin/theme/ThemeSwatches.tsx +30 -0
- package/template/src/components/admin/theme/theme-utils.ts +32 -0
- package/template/src/components/admin/two-factor/BackupCodeList.tsx +54 -0
- package/template/src/components/admin/two-factor/TwoFactorCard.tsx +237 -0
- package/template/src/components/admin/two-factor/TwoFactorRequired.tsx +52 -0
- package/template/src/components/admin/two-factor/TwoFactorSetup.tsx +180 -0
- package/template/src/components/admin/use-unsaved-changes.tsx +101 -0
- package/template/src/components/admin/users/ArchivedAccounts.tsx +159 -0
- package/template/src/components/admin/users/InviteDialogs.tsx +131 -0
- package/template/src/components/admin/users/TwoFactorRoles.tsx +80 -0
- package/template/src/components/admin/users/UserDialogs.tsx +681 -0
- package/template/src/components/admin/users/UsersTable.tsx +374 -0
- package/template/src/components/admin/view-only.tsx +43 -0
- package/template/src/components/auth/AcceptInviteForm.tsx +123 -0
- package/template/src/components/auth/AuthNav.tsx +80 -0
- package/template/src/components/auth/ConfirmEmailForm.tsx +73 -0
- package/template/src/components/auth/LoginForm.tsx +250 -0
- package/template/src/components/auth/PageError.tsx +37 -0
- package/template/src/components/auth/ProviderSignIn.tsx +53 -0
- package/template/src/components/auth/ResetPasswordForm.tsx +267 -0
- package/template/src/components/demo/DemoBanner.tsx +38 -0
- package/template/src/components/demo/SiteDemoBanner.tsx +22 -0
- package/template/src/components/demo/wording.ts +21 -0
- package/template/src/components/setup/SetupAccountForm.tsx +93 -0
- package/template/src/components/setup/SetupDone.tsx +95 -0
- package/template/src/components/setup/SetupNav.tsx +49 -0
- package/template/src/components/setup/SetupSampleContent.tsx +67 -0
- package/template/src/components/setup/SetupSiteForm.tsx +104 -0
- package/template/src/components/setup/SetupThemePicker.tsx +73 -0
- package/template/src/components/setup/SkipSetup.tsx +35 -0
- package/template/src/components/site/BuilderContent.tsx +46 -0
- package/template/src/components/site/CopyButton.tsx +28 -0
- package/template/src/components/site/ImageCarousel.tsx +52 -0
- package/template/src/components/site/PetCard.tsx +32 -0
- package/template/src/components/site/PetCatalog.tsx +106 -0
- package/template/src/components/site/PetGallery.tsx +75 -0
- package/template/src/components/site/PetTimeline.tsx +82 -0
- package/template/src/components/site/RemountOnNavigate.tsx +13 -0
- package/template/src/components/site/RichText.tsx +56 -0
- package/template/src/components/site/SmartLink.tsx +37 -0
- package/template/src/components/site/SocialIcons.tsx +26 -0
- package/template/src/components/site/ThemePreviewBridge.tsx +29 -0
- package/template/src/components/site/ThemeStyle.tsx +22 -0
- package/template/src/components/site/ThemeToggle.tsx +36 -0
- package/template/src/components/site/WhatsAppButton.tsx +27 -0
- package/template/src/components/site/timeline-format.ts +20 -0
- package/template/src/db/client.ts +702 -0
- package/template/src/db/compare-tables.ts +41 -0
- package/template/src/db/migrate.ts +28 -0
- package/template/src/db/plugin-migrations.ts +167 -0
- package/template/src/db/schema/pg.ts +484 -0
- package/template/src/db/schema/sqlite.ts +492 -0
- package/template/src/instrumentation.ts +110 -0
- package/template/src/lib/activity.ts +29 -0
- package/template/src/lib/admin/call-action.ts +19 -0
- package/template/src/lib/admin/initials.ts +9 -0
- package/template/src/lib/admin/media-cache.ts +16 -0
- package/template/src/lib/admin/media-page.ts +3 -0
- package/template/src/lib/admin/pet-form.ts +242 -0
- package/template/src/lib/admin/pets-cache.ts +22 -0
- package/template/src/lib/admin/unwrap-client.ts +11 -0
- package/template/src/lib/admin/unwrap.ts +38 -0
- package/template/src/lib/admin/use-media-list.ts +41 -0
- package/template/src/lib/admin/use-pet-list.ts +58 -0
- package/template/src/lib/age.ts +117 -0
- package/template/src/lib/auth-provider-errors.ts +38 -0
- package/template/src/lib/cache.ts +69 -0
- package/template/src/lib/color-mode.ts +48 -0
- package/template/src/lib/demo.ts +78 -0
- package/template/src/lib/email-address.ts +9 -0
- package/template/src/lib/email-template.ts +691 -0
- package/template/src/lib/links.ts +78 -0
- package/template/src/lib/mail-error.ts +38 -0
- package/template/src/lib/media-name.ts +31 -0
- package/template/src/lib/options.ts +134 -0
- package/template/src/lib/pagination.ts +28 -0
- package/template/src/lib/pet-placeholders.ts +34 -0
- package/template/src/lib/pet-seo.ts +40 -0
- package/template/src/lib/pet-timeline.ts +62 -0
- package/template/src/lib/phone.ts +129 -0
- package/template/src/lib/places.ts +84 -0
- package/template/src/lib/queries.ts +549 -0
- package/template/src/lib/revalidate.ts +32 -0
- package/template/src/lib/rich-text.ts +215 -0
- package/template/src/lib/seo.ts +121 -0
- package/template/src/lib/slugify.ts +11 -0
- package/template/src/lib/theme.ts +546 -0
- package/template/src/lib/utils.ts +2 -0
- package/template/src/lib/whatsapp.ts +29 -0
- package/template/src/lib/zod-schema/auth.ts +56 -0
- package/template/src/lib/zod-schema/page.ts +57 -0
- package/template/src/lib/zod-schema/pet-timeline.ts +118 -0
- package/template/src/lib/zod-schema/pet.ts +172 -0
- package/template/src/lib/zod-schema/settings.ts +162 -0
- package/template/src/plugins/host.ts +117 -0
- package/template/src/plugins/icon.ts +89 -0
- package/template/src/plugins/registry.ts +369 -0
- package/template/src/plugins/storage-rules.ts +87 -0
- package/template/src/plugins/storage.ts +184 -0
- package/template/src/puck/actions.ts +46 -0
- package/template/src/puck/config.tsx +1693 -0
- package/template/src/puck/data.ts +196 -0
- package/template/src/puck/demo-mode.tsx +20 -0
- package/template/src/puck/email-config.tsx +267 -0
- package/template/src/puck/icons.tsx +76 -0
- package/template/src/puck/media-picker.tsx +273 -0
- package/template/src/puck/padding.tsx +71 -0
- package/template/src/puck/pet-page-config.tsx +511 -0
- package/template/src/puck/pet-picker.tsx +40 -0
- package/template/src/puck/plugin-block-data.ts +91 -0
- package/template/src/puck/plugin-blocks.tsx +235 -0
- package/template/src/puck/plugin-choice-field.tsx +87 -0
- package/template/src/puck/sanitize.ts +107 -0
- package/template/src/puck/server.ts +36 -0
- package/template/src/puck/types.ts +41 -0
- package/template/src/server/actions/activity.ts +48 -0
- package/template/src/server/actions/auth-providers.ts +171 -0
- package/template/src/server/actions/auth.ts +217 -0
- package/template/src/server/actions/demo.ts +30 -0
- package/template/src/server/actions/email-change.ts +80 -0
- package/template/src/server/actions/email-templates.ts +144 -0
- package/template/src/server/actions/email.ts +70 -0
- package/template/src/server/actions/media.ts +127 -0
- package/template/src/server/actions/pages.ts +159 -0
- package/template/src/server/actions/password-reset.ts +80 -0
- package/template/src/server/actions/pet-timeline.ts +75 -0
- package/template/src/server/actions/pets.ts +74 -0
- package/template/src/server/actions/places.ts +36 -0
- package/template/src/server/actions/settings.ts +29 -0
- package/template/src/server/actions/setup.ts +72 -0
- package/template/src/server/actions/themes.ts +80 -0
- package/template/src/server/actions/two-factor.ts +306 -0
- package/template/src/server/actions/users.ts +200 -0
- package/template/src/server/activity.ts +409 -0
- package/template/src/server/auth-errors.ts +17 -0
- package/template/src/server/auth-providers.ts +359 -0
- package/template/src/server/auth.ts +266 -0
- package/template/src/server/avatars.ts +263 -0
- package/template/src/server/demo-site.ts +169 -0
- package/template/src/server/email-change.ts +278 -0
- package/template/src/server/email-templates.ts +350 -0
- package/template/src/server/email.ts +442 -0
- package/template/src/server/invites.ts +143 -0
- package/template/src/server/media-url.ts +20 -0
- package/template/src/server/media.ts +236 -0
- package/template/src/server/pages.ts +812 -0
- package/template/src/server/password-reset.ts +158 -0
- package/template/src/server/pending-links.ts +46 -0
- package/template/src/server/pet-timeline.ts +181 -0
- package/template/src/server/pets.ts +555 -0
- package/template/src/server/places.ts +113 -0
- package/template/src/server/privacy.ts +21 -0
- package/template/src/server/provider-endpoints.ts +94 -0
- package/template/src/server/provider-guard.ts +157 -0
- package/template/src/server/result.ts +280 -0
- package/template/src/server/sample-content.ts +368 -0
- package/template/src/server/search-text.ts +43 -0
- package/template/src/server/secret-box.ts +38 -0
- package/template/src/server/session.ts +154 -0
- package/template/src/server/settings.ts +361 -0
- package/template/src/server/setup.ts +110 -0
- package/template/src/server/sitemap.ts +88 -0
- package/template/src/server/storage.ts +267 -0
- package/template/src/server/strip-metadata.ts +357 -0
- package/template/src/server/themes.ts +195 -0
- package/template/src/server/throttle.ts +258 -0
- package/template/src/server/two-factor-codes.ts +32 -0
- package/template/src/server/two-factor.ts +158 -0
- package/template/src/server/types.ts +198 -0
- package/template/src/server/uploads.ts +137 -0
- package/template/src/server/users.ts +500 -0
- package/template/tsconfig.json +44 -0
- package/template/ui/components.json +25 -0
- package/template/ui/package.json +12 -0
- package/template/ui/src/components/alert-dialog.tsx +187 -0
- package/template/ui/src/components/avatar.tsx +108 -0
- package/template/ui/src/components/badge.tsx +51 -0
- package/template/ui/src/components/button.tsx +57 -0
- package/template/ui/src/components/card.tsx +102 -0
- package/template/ui/src/components/carousel.tsx +245 -0
- package/template/ui/src/components/checkbox.tsx +27 -0
- package/template/ui/src/components/combobox.tsx +297 -0
- package/template/ui/src/components/dialog.tsx +159 -0
- package/template/ui/src/components/dropdown-menu.tsx +265 -0
- package/template/ui/src/components/field.tsx +238 -0
- package/template/ui/src/components/input-group.tsx +158 -0
- package/template/ui/src/components/input.tsx +19 -0
- package/template/ui/src/components/label.tsx +19 -0
- package/template/ui/src/components/pagination.tsx +127 -0
- package/template/ui/src/components/popover.tsx +89 -0
- package/template/ui/src/components/radio-group.tsx +37 -0
- package/template/ui/src/components/select.tsx +200 -0
- package/template/ui/src/components/separator.tsx +24 -0
- package/template/ui/src/components/sheet.tsx +138 -0
- package/template/ui/src/components/sidebar.tsx +723 -0
- package/template/ui/src/components/skeleton.tsx +13 -0
- package/template/ui/src/components/switch.tsx +31 -0
- package/template/ui/src/components/table.tsx +115 -0
- package/template/ui/src/components/tabs.tsx +81 -0
- package/template/ui/src/components/textarea.tsx +17 -0
- package/template/ui/src/components/toggle.tsx +44 -0
- package/template/ui/src/components/tooltip.tsx +65 -0
- package/template/ui/src/hooks/use-mobile.ts +21 -0
- package/template/ui/src/lib/utils.ts +2 -0
- package/template/ui/src/styles/globals.css +145 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
|
|
3
|
+
import { RESERVED_SLUGS } from "@/lib/options";
|
|
4
|
+
import { SLUG_PATTERN } from "@/lib/slugify";
|
|
5
|
+
|
|
6
|
+
// The page settings form's rules, checked in the browser before anything is sent. They mirror
|
|
7
|
+
// `parseDetails` in src/server/pages.ts, which stays the authority.
|
|
8
|
+
|
|
9
|
+
const mediaRef = z.object({
|
|
10
|
+
id: z.number().int().positive(),
|
|
11
|
+
thumbnailUrl: z.string(),
|
|
12
|
+
alt: z.string(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const pageFormSchema = z.object({
|
|
16
|
+
title: z.string().trim().min(1, "Enter a title.").max(120, "Use at most 120 characters."),
|
|
17
|
+
slug: z
|
|
18
|
+
.string()
|
|
19
|
+
.trim()
|
|
20
|
+
.min(1, "Enter an address.")
|
|
21
|
+
.max(80, "Use at most 80 characters.")
|
|
22
|
+
.regex(SLUG_PATTERN, "Use lowercase letters, numbers and single dashes only.")
|
|
23
|
+
.refine((value) => !RESERVED_SLUGS.includes(value), {
|
|
24
|
+
message: "This address is used by the site itself. Pick another one.",
|
|
25
|
+
}),
|
|
26
|
+
seoDescription: z.string().max(200, "Use at most 200 characters."),
|
|
27
|
+
seoImage: mediaRef.nullable(),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export type PageFormValues = z.infer<typeof pageFormSchema>;
|
|
31
|
+
export type PageFormField = keyof PageFormValues;
|
|
32
|
+
|
|
33
|
+
/** In the order they appear, for the error summary. */
|
|
34
|
+
export const PAGE_FIELD_ORDER: PageFormField[] = ["title", "slug", "seoDescription", "seoImage"];
|
|
35
|
+
|
|
36
|
+
export const PAGE_FIELD_LABELS: Record<PageFormField, string> = {
|
|
37
|
+
title: "Title",
|
|
38
|
+
slug: "Address",
|
|
39
|
+
seoDescription: "Search description",
|
|
40
|
+
seoImage: "Share image",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** The server's field names (`seoImageId`) on the form's fields. */
|
|
44
|
+
export function pageFormFieldFor(key: string): PageFormField | null {
|
|
45
|
+
if (key === "seoImageId") return "seoImage";
|
|
46
|
+
return (PAGE_FIELD_ORDER as string[]).includes(key) ? (key as PageFormField) : null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The payload for `savePageDetailsAction`. Blank description becomes null. */
|
|
50
|
+
export function toPageInput(values: PageFormValues) {
|
|
51
|
+
return {
|
|
52
|
+
title: values.title.trim(),
|
|
53
|
+
slug: values.slug.trim(),
|
|
54
|
+
seoDescription: values.seoDescription.trim() || null,
|
|
55
|
+
seoImageId: values.seoImage?.id ?? null,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
TIME_PATTERN,
|
|
5
|
+
TIMELINE_MAX_PHOTOS,
|
|
6
|
+
TIMELINE_TEXT_MAX_CHARS,
|
|
7
|
+
TIMELINE_TITLE_MAX,
|
|
8
|
+
type TimelineEntry,
|
|
9
|
+
type TimelineEntryInput,
|
|
10
|
+
} from "@/lib/pet-timeline";
|
|
11
|
+
import { validateRichText, type RichTextDoc } from "@/lib/rich-text";
|
|
12
|
+
|
|
13
|
+
// The timeline update form's rules (Timeline section of a pet's edit page), checked in the browser
|
|
14
|
+
// before anything is sent. They reuse the shared limits and the rich-text validator, so they match
|
|
15
|
+
// the server's rules (src/server/pet-timeline.ts), which stay the authority: its `fieldErrors`
|
|
16
|
+
// (keys date, time, title, body, photoIds) are shown on the same fields.
|
|
17
|
+
|
|
18
|
+
/** `2026-02-31` rolls over in Date.parse, so require that the date survives a round trip. */
|
|
19
|
+
function isCalendarDate(value: string) {
|
|
20
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value) || Number.isNaN(Date.parse(value))) return false;
|
|
21
|
+
return new Date(`${value}T00:00:00Z`).toISOString().slice(0, 10) === value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A photo chosen from the media library, as the form shows it. */
|
|
25
|
+
const photoRef = z.object({
|
|
26
|
+
id: z.number().int().positive(),
|
|
27
|
+
url: z.string(),
|
|
28
|
+
thumbnailUrl: z.string(),
|
|
29
|
+
alt: z.string(),
|
|
30
|
+
});
|
|
31
|
+
export type TimelineFormPhoto = z.infer<typeof photoRef>;
|
|
32
|
+
|
|
33
|
+
export const timelineEntrySchema = z.object({
|
|
34
|
+
date: z
|
|
35
|
+
.string()
|
|
36
|
+
.trim()
|
|
37
|
+
.min(1, "Enter the date.")
|
|
38
|
+
.refine((value) => value === "" || isCalendarDate(value), "Enter a real date."),
|
|
39
|
+
time: z
|
|
40
|
+
.string()
|
|
41
|
+
.trim()
|
|
42
|
+
.refine((value) => value === "" || TIME_PATTERN.test(value), "Enter a time like 14:30, or leave it empty."),
|
|
43
|
+
title: z
|
|
44
|
+
.string()
|
|
45
|
+
.trim()
|
|
46
|
+
.min(1, "Enter a title.")
|
|
47
|
+
.max(TIMELINE_TITLE_MAX, `The title must be at most ${TIMELINE_TITLE_MAX} characters.`),
|
|
48
|
+
body: z.custom<RichTextDoc | null>().superRefine((value, context) => {
|
|
49
|
+
if (value === null || value === undefined) return;
|
|
50
|
+
const result = validateRichText(value, { maxChars: TIMELINE_TEXT_MAX_CHARS });
|
|
51
|
+
if (!result.ok) context.addIssue({ code: "custom", message: result.error });
|
|
52
|
+
}),
|
|
53
|
+
photos: z.array(photoRef).max(TIMELINE_MAX_PHOTOS, `Use at most ${TIMELINE_MAX_PHOTOS} photos.`),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export type TimelineEntryFormValues = z.infer<typeof timelineEntrySchema>;
|
|
57
|
+
|
|
58
|
+
export const TIMELINE_FIELD_LABELS: Record<keyof TimelineEntryFormValues, string> = {
|
|
59
|
+
date: "Date",
|
|
60
|
+
time: "Time",
|
|
61
|
+
title: "Title",
|
|
62
|
+
body: "Text",
|
|
63
|
+
photos: "Photos",
|
|
64
|
+
};
|
|
65
|
+
export const TIMELINE_FIELD_ORDER = ["date", "time", "title", "body", "photos"] as const;
|
|
66
|
+
|
|
67
|
+
/** A server field error key (`photoIds`, `photoIds.2`, `body`) mapped to the form's field. */
|
|
68
|
+
export function timelineFieldFor(key: string): keyof TimelineEntryFormValues | null {
|
|
69
|
+
const head = key.split(".")[0];
|
|
70
|
+
if (head === "photoIds") return "photos";
|
|
71
|
+
return (TIMELINE_FIELD_ORDER as readonly string[]).includes(head) ? (head as keyof TimelineEntryFormValues) : null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The form's values for a new update (today, no time) or an existing one. */
|
|
75
|
+
export function timelineToFormValues(entry: TimelineEntry | null, today: string): TimelineEntryFormValues {
|
|
76
|
+
if (!entry) return { date: today, time: "", title: "", body: null, photos: [] };
|
|
77
|
+
return {
|
|
78
|
+
date: entry.date,
|
|
79
|
+
time: entry.time ?? "",
|
|
80
|
+
title: entry.title,
|
|
81
|
+
body: entry.body,
|
|
82
|
+
photos: photosOf(entry),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The entry's photos with their ids, for editing. `photos` leaves out deleted images, so it is only
|
|
88
|
+
* paired with `photoIds` when nothing is missing (or when the server sends each photo's id).
|
|
89
|
+
*/
|
|
90
|
+
function photosOf(entry: TimelineEntry): TimelineFormPhoto[] {
|
|
91
|
+
const withIds = entry.photos.every((photo) => typeof (photo as { id?: unknown }).id === "number");
|
|
92
|
+
if (withIds) {
|
|
93
|
+
return entry.photos.map((photo) => ({
|
|
94
|
+
id: (photo as unknown as { id: number }).id,
|
|
95
|
+
url: photo.url,
|
|
96
|
+
thumbnailUrl: photo.thumbnailUrl ?? photo.url,
|
|
97
|
+
alt: photo.alt,
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
if (entry.photos.length !== entry.photoIds.length) return [];
|
|
101
|
+
return entry.photos.map((photo, index) => ({
|
|
102
|
+
id: entry.photoIds[index],
|
|
103
|
+
url: photo.url,
|
|
104
|
+
thumbnailUrl: photo.thumbnailUrl ?? photo.url,
|
|
105
|
+
alt: photo.alt,
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** What the actions receive. */
|
|
110
|
+
export function toTimelineInput(values: TimelineEntryFormValues): TimelineEntryInput {
|
|
111
|
+
return {
|
|
112
|
+
date: values.date.trim(),
|
|
113
|
+
time: values.time.trim() || null,
|
|
114
|
+
title: values.title.trim(),
|
|
115
|
+
body: values.body,
|
|
116
|
+
photoIds: values.photos.map((photo) => photo.id),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
|
|
3
|
+
import { estimateBirthDate, todayISO, type AgeUnit } from "@/lib/age";
|
|
4
|
+
import { validateHttpsUrl } from "@/lib/links";
|
|
5
|
+
import {
|
|
6
|
+
AGE_GROUPS,
|
|
7
|
+
AGE_UNITS,
|
|
8
|
+
GOOD_WITH,
|
|
9
|
+
normalizeSpecies,
|
|
10
|
+
PET_STATUS_VALUES,
|
|
11
|
+
SEXES,
|
|
12
|
+
SIZES,
|
|
13
|
+
SPECIES_MAX_LENGTH,
|
|
14
|
+
TEMPERAMENTS,
|
|
15
|
+
} from "@/lib/options";
|
|
16
|
+
import { DESCRIPTION_MAX_CHARS, validateRichText, type RichTextDoc } from "@/lib/rich-text";
|
|
17
|
+
import { SLUG_PATTERN } from "@/lib/slugify";
|
|
18
|
+
import { normalizePhone } from "@/lib/whatsapp";
|
|
19
|
+
|
|
20
|
+
// The pet form's rules, checked in the browser before anything is sent. They reuse the server's own
|
|
21
|
+
// pure validators (links, phone numbers, slugs, species, age), so the two cannot drift apart; the
|
|
22
|
+
// server (`savePet`) is still the authority and its `fieldErrors` are shown on the same fields.
|
|
23
|
+
// Form values are strings, booleans and small objects with no transforms: what the person typed.
|
|
24
|
+
// `toPetInput` (src/lib/admin/pet-form.ts) turns them into the payload.
|
|
25
|
+
|
|
26
|
+
/** Same as MAX_PHOTOS in src/server/pets.ts (a server module, so it cannot be imported here). */
|
|
27
|
+
export const PET_MAX_PHOTOS = 10;
|
|
28
|
+
|
|
29
|
+
/** How the age is entered: keep what is stored, a birth date, "about N months", or not known. */
|
|
30
|
+
export const AGE_MODES = ["keep", "date", "estimate", "none"] as const;
|
|
31
|
+
|
|
32
|
+
const valuesOf = <T extends readonly { value: string }[]>(list: T) =>
|
|
33
|
+
list.map((option) => option.value) as [T[number]["value"], ...T[number]["value"][]];
|
|
34
|
+
|
|
35
|
+
/** A select that may be left unset (the empty string). */
|
|
36
|
+
const optionalOf = <T extends readonly { value: string }[]>(list: T) =>
|
|
37
|
+
z.enum(valuesOf(list)).or(z.literal(""));
|
|
38
|
+
|
|
39
|
+
const text = (max: number, what: string) =>
|
|
40
|
+
z.string().trim().max(max, `${what} must be at most ${max} characters.`);
|
|
41
|
+
|
|
42
|
+
/** `2026-02-31` rolls over in Date.parse, so require that the date survives a round trip. */
|
|
43
|
+
function isCalendarDate(value: string) {
|
|
44
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value) || Number.isNaN(Date.parse(value))) return false;
|
|
45
|
+
return new Date(`${value}T00:00:00Z`).toISOString().slice(0, 10) === value;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const optionalDate = z
|
|
49
|
+
.string()
|
|
50
|
+
.trim()
|
|
51
|
+
.refine((value) => value === "" || isCalendarDate(value), "Enter a real date.");
|
|
52
|
+
|
|
53
|
+
/** An image chosen from the media library: just what the form needs to show it. */
|
|
54
|
+
const mediaRef = z.object({
|
|
55
|
+
id: z.number().int().positive(),
|
|
56
|
+
/** The original (logos and icons are previewed whole; thumbnails are 4:3 crops). */
|
|
57
|
+
url: z.string(),
|
|
58
|
+
thumbnailUrl: z.string(),
|
|
59
|
+
alt: z.string(),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export const petFormSchema = z
|
|
63
|
+
.object({
|
|
64
|
+
name: z.string().trim().min(1, "Enter the pet's name.").max(60, "The name must be at most 60 characters."),
|
|
65
|
+
species: z
|
|
66
|
+
.string()
|
|
67
|
+
.trim()
|
|
68
|
+
.min(1, "Enter the species, for example cat or dog.")
|
|
69
|
+
.max(SPECIES_MAX_LENGTH, `The species must be at most ${SPECIES_MAX_LENGTH} characters.`)
|
|
70
|
+
.refine((value) => value === "" || normalizeSpecies(value) !== "", "Use letters or numbers."),
|
|
71
|
+
sex: optionalOf(SEXES),
|
|
72
|
+
size: optionalOf(SIZES),
|
|
73
|
+
breed: text(80, "The breed"),
|
|
74
|
+
color: text(60, "The colour"),
|
|
75
|
+
city: text(60, "The city"),
|
|
76
|
+
state: text(60, "The state"),
|
|
77
|
+
/** ISO 3166-1 alpha-2, picked from a list (the server checks it is a real one). */
|
|
78
|
+
country: z.string().trim().regex(/^([A-Za-z]{2})?$/, "Pick a country from the list."),
|
|
79
|
+
location: text(120, "The location"),
|
|
80
|
+
|
|
81
|
+
ageMode: z.enum(AGE_MODES),
|
|
82
|
+
birthDate: z.string().trim(),
|
|
83
|
+
ageValue: z.string().trim(),
|
|
84
|
+
ageUnit: optionalOf(AGE_UNITS),
|
|
85
|
+
ageDescription: text(40, "The age description"),
|
|
86
|
+
ageGroup: optionalOf(AGE_GROUPS),
|
|
87
|
+
|
|
88
|
+
vaccinated: z.boolean(),
|
|
89
|
+
neutered: z.boolean(),
|
|
90
|
+
microchipped: z.boolean(),
|
|
91
|
+
houseTrained: z.boolean(),
|
|
92
|
+
specialNeeds: z.boolean(),
|
|
93
|
+
// A rich-text document (paragraphs, lists, bold/italic/underline, links) or null. Checked with the
|
|
94
|
+
// same rules as the server (src/lib/rich-text.ts), which also caps the length.
|
|
95
|
+
healthNotes: z.custom<RichTextDoc | null>().superRefine((value, context) => {
|
|
96
|
+
if (value === null || value === undefined) return;
|
|
97
|
+
const result = validateRichText(value);
|
|
98
|
+
if (!result.ok) context.addIssue({ code: "custom", message: result.error });
|
|
99
|
+
}),
|
|
100
|
+
// Same rules and cap as the health notes.
|
|
101
|
+
personalityNotes: z.custom<RichTextDoc | null>().superRefine((value, context) => {
|
|
102
|
+
if (value === null || value === undefined) return;
|
|
103
|
+
const result = validateRichText(value);
|
|
104
|
+
if (!result.ok) context.addIssue({ code: "custom", message: result.error });
|
|
105
|
+
}),
|
|
106
|
+
temperament: z.array(z.enum(valuesOf(TEMPERAMENTS))),
|
|
107
|
+
goodWith: z.array(z.enum(valuesOf(GOOD_WITH))),
|
|
108
|
+
|
|
109
|
+
photos: z
|
|
110
|
+
.array(mediaRef)
|
|
111
|
+
.min(1, "Add at least 1 photo.")
|
|
112
|
+
.max(PET_MAX_PHOTOS, `Use at most ${PET_MAX_PHOTOS} photos.`),
|
|
113
|
+
// A rich-text document or null, checked with the server's rules and its 5000-character cap.
|
|
114
|
+
description: z.custom<RichTextDoc | null>().superRefine((value, context) => {
|
|
115
|
+
if (value === null || value === undefined) return;
|
|
116
|
+
const result = validateRichText(value, { maxChars: DESCRIPTION_MAX_CHARS });
|
|
117
|
+
if (!result.ok) context.addIssue({ code: "custom", message: result.error });
|
|
118
|
+
}),
|
|
119
|
+
videoUrl: text(300, "The video link").refine(
|
|
120
|
+
(value) => validateHttpsUrl(value) === true,
|
|
121
|
+
"Enter a full link starting with https://",
|
|
122
|
+
),
|
|
123
|
+
|
|
124
|
+
adoptionFee: z
|
|
125
|
+
.string()
|
|
126
|
+
.trim()
|
|
127
|
+
.refine(
|
|
128
|
+
(value) => value === "" || (/^\d+(\.\d+)?$/.test(value) && Number(value) <= 1e9),
|
|
129
|
+
"Enter an amount such as 150 or 150.50.",
|
|
130
|
+
),
|
|
131
|
+
rescuedAt: optionalDate,
|
|
132
|
+
contactWhatsApp: text(40, "The number").refine(
|
|
133
|
+
(value) => value === "" || normalizePhone(value) !== "",
|
|
134
|
+
"Enter a valid number, for example +60 12-345 6789.",
|
|
135
|
+
),
|
|
136
|
+
|
|
137
|
+
seoTitle: text(70, "The search title"),
|
|
138
|
+
seoDescription: text(160, "The search description"),
|
|
139
|
+
seoImage: mediaRef.nullable(),
|
|
140
|
+
|
|
141
|
+
status: z.enum(PET_STATUS_VALUES),
|
|
142
|
+
featured: z.boolean(),
|
|
143
|
+
unlisted: z.boolean(),
|
|
144
|
+
urgent: z.boolean(),
|
|
145
|
+
slug: text(80, "The address").refine(
|
|
146
|
+
(value) => value === "" || SLUG_PATTERN.test(value),
|
|
147
|
+
"Use lowercase letters, numbers and single dashes only.",
|
|
148
|
+
),
|
|
149
|
+
})
|
|
150
|
+
.superRefine((values, context) => {
|
|
151
|
+
const add = (path: string, message: string) => context.addIssue({ code: "custom", path: [path], message });
|
|
152
|
+
|
|
153
|
+
// Only the fields of the chosen way of entering the age are checked: the others are not sent.
|
|
154
|
+
if (values.ageMode === "date" && values.birthDate !== "") {
|
|
155
|
+
if (!isCalendarDate(values.birthDate)) add("birthDate", "Enter a real date.");
|
|
156
|
+
else if (values.birthDate > todayISO()) add("birthDate", "The birth date cannot be in the future.");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (values.ageMode === "estimate" && values.ageValue !== "") {
|
|
160
|
+
const amount = Number(values.ageValue);
|
|
161
|
+
if (!/^\d+$/.test(values.ageValue) || amount < 1 || amount > 200) {
|
|
162
|
+
add("ageValue", "Use a whole number from 1 to 200.");
|
|
163
|
+
} else if (values.ageUnit === "") {
|
|
164
|
+
add("ageUnit", "Pick weeks, months or years.");
|
|
165
|
+
} else if (estimateBirthDate(amount, values.ageUnit as AgeUnit) < "1850-01-01") {
|
|
166
|
+
add("ageValue", "That is too old.");
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
export type PetFormValues = z.infer<typeof petFormSchema>;
|
|
172
|
+
export type PetFormMedia = z.infer<typeof mediaRef>;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { isTimeZone } from "@pet-adopt/plugin-sdk";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
|
|
4
|
+
import { validateLink, validateWebUrl } from "@/lib/links";
|
|
5
|
+
import { SOCIAL_PLATFORMS } from "@/lib/options";
|
|
6
|
+
import { validatePhone } from "@/lib/phone";
|
|
7
|
+
import type { SiteSetting } from "@/server/types";
|
|
8
|
+
|
|
9
|
+
// The site settings form's rules, checked in the browser before anything is sent. They reuse the
|
|
10
|
+
// server's own validators (src/server/settings.ts stays the authority). The theme is not here: it
|
|
11
|
+
// has its own screen (/admin/theme).
|
|
12
|
+
|
|
13
|
+
const MAX_LIST_ITEMS = 20;
|
|
14
|
+
// `url` is the original: logos and icons are previewed whole (thumbnails are 4:3 crops).
|
|
15
|
+
const mediaRef = z.object({ id: z.number().int().positive(), url: z.string(), thumbnailUrl: z.string(), alt: z.string() });
|
|
16
|
+
const check = (result: true | string) => result === true;
|
|
17
|
+
const platformValues = SOCIAL_PLATFORMS.map((option) => option.value) as [string, ...string[]];
|
|
18
|
+
|
|
19
|
+
export const settingsFormSchema = z.object({
|
|
20
|
+
siteName: z.string().trim().min(1, "Enter the site's name.").max(80, "Use at most 80 characters."),
|
|
21
|
+
tagline: z.string().max(160, "Use at most 160 characters."),
|
|
22
|
+
logo: mediaRef.nullable(),
|
|
23
|
+
/** Checked for size and shape on the server (the picker does not send the image's dimensions). */
|
|
24
|
+
favicon: mediaRef.nullable(),
|
|
25
|
+
allowModeToggle: z.boolean(),
|
|
26
|
+
whatsappNumber: z
|
|
27
|
+
.string()
|
|
28
|
+
.max(40, "Use at most 40 characters.")
|
|
29
|
+
// The same libphonenumber check as the server. The phone input sends E.164 ("+60123456789").
|
|
30
|
+
.superRefine((value, ctx) => {
|
|
31
|
+
const result = value.trim() ? validatePhone(value) : true;
|
|
32
|
+
if (result !== true) ctx.addIssue({ code: "custom", message: result });
|
|
33
|
+
}),
|
|
34
|
+
whatsappMessage: z.string().max(300, "Use at most 300 characters."),
|
|
35
|
+
address: z.string().max(500, "Use at most 500 characters."),
|
|
36
|
+
openingHours: z.string().max(500, "Use at most 500 characters."),
|
|
37
|
+
socials: z
|
|
38
|
+
.array(
|
|
39
|
+
z.object({
|
|
40
|
+
platform: z.enum(platformValues, "Choose a platform."),
|
|
41
|
+
url: z
|
|
42
|
+
.string()
|
|
43
|
+
.trim()
|
|
44
|
+
.min(1, "Enter the link.")
|
|
45
|
+
.max(300, "Use at most 300 characters.")
|
|
46
|
+
.refine((value) => check(validateWebUrl(value)), "Enter a full link starting with https://"),
|
|
47
|
+
}),
|
|
48
|
+
)
|
|
49
|
+
.max(MAX_LIST_ITEMS, `Use at most ${MAX_LIST_ITEMS} links.`),
|
|
50
|
+
nav: z
|
|
51
|
+
.array(
|
|
52
|
+
z.object({
|
|
53
|
+
label: z.string().trim().min(1, "Enter the link text.").max(40, "Use at most 40 characters."),
|
|
54
|
+
href: z
|
|
55
|
+
.string()
|
|
56
|
+
.trim()
|
|
57
|
+
.min(1, "Enter where the link goes.")
|
|
58
|
+
.max(300, "Use at most 300 characters.")
|
|
59
|
+
.refine((value) => check(validateLink(value)), "Use a path like /pets, or a full link starting with https://"),
|
|
60
|
+
}),
|
|
61
|
+
)
|
|
62
|
+
.max(MAX_LIST_ITEMS, `Use at most ${MAX_LIST_ITEMS} menu links.`),
|
|
63
|
+
footerText: z.string().max(500, "Use at most 500 characters."),
|
|
64
|
+
/** The privacy policy's page id as text ("" for none), for the select. */
|
|
65
|
+
privacyPageId: z.string(),
|
|
66
|
+
/** ISO 3166-1 alpha-2, or "" for the default country. Picked from a list; the server checks it. */
|
|
67
|
+
country: z.string().regex(/^([A-Za-z]{2})?$/, "Pick a country from the list."),
|
|
68
|
+
/** An IANA time zone, or "" for each person's own device time. */
|
|
69
|
+
timeZone: z.string().refine((value) => value === "" || isTimeZone(value), "Pick a time zone from the list."),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export type SettingsFormValues = z.infer<typeof settingsFormSchema>;
|
|
73
|
+
|
|
74
|
+
export function settingsToFormValues(settings: SiteSetting): SettingsFormValues {
|
|
75
|
+
return {
|
|
76
|
+
siteName: settings.siteName ?? "",
|
|
77
|
+
tagline: settings.tagline ?? "",
|
|
78
|
+
logo: settings.logo ? { id: settings.logo.id, url: settings.logo.url, thumbnailUrl: settings.logo.thumbnailUrl, alt: settings.logo.alt } : null,
|
|
79
|
+
favicon: settings.favicon ? { id: settings.favicon.id, url: settings.favicon.url, thumbnailUrl: settings.favicon.thumbnailUrl, alt: settings.favicon.alt } : null,
|
|
80
|
+
allowModeToggle: settings.allowModeToggle,
|
|
81
|
+
whatsappNumber: settings.whatsappNumber ?? "",
|
|
82
|
+
whatsappMessage: settings.whatsappMessage ?? "",
|
|
83
|
+
address: settings.address ?? "",
|
|
84
|
+
openingHours: settings.openingHours ?? "",
|
|
85
|
+
socials: (settings.socials ?? []).map((item) => ({ platform: item.platform, url: item.url })),
|
|
86
|
+
nav: (settings.nav ?? []).map((item) => ({ label: item.label, href: item.href })),
|
|
87
|
+
footerText: settings.footerText ?? "",
|
|
88
|
+
privacyPageId: settings.privacyPageId ? String(settings.privacyPageId) : "",
|
|
89
|
+
country: settings.country ?? "",
|
|
90
|
+
timeZone: settings.timeZone ?? "",
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const orNull = (value: string) => (value.trim() ? value.trim() : null);
|
|
95
|
+
|
|
96
|
+
/** The payload for `updateSettingsAction`. Blank text becomes null; lists are sent whole. */
|
|
97
|
+
export function toSettingsInput(values: SettingsFormValues) {
|
|
98
|
+
return {
|
|
99
|
+
siteName: values.siteName.trim(),
|
|
100
|
+
tagline: orNull(values.tagline),
|
|
101
|
+
logoId: values.logo?.id ?? null,
|
|
102
|
+
faviconId: values.favicon?.id ?? null,
|
|
103
|
+
allowModeToggle: values.allowModeToggle,
|
|
104
|
+
whatsappNumber: orNull(values.whatsappNumber),
|
|
105
|
+
whatsappMessage: orNull(values.whatsappMessage),
|
|
106
|
+
address: orNull(values.address),
|
|
107
|
+
openingHours: orNull(values.openingHours),
|
|
108
|
+
socials: values.socials.map((item) => ({ platform: item.platform, url: item.url.trim() })),
|
|
109
|
+
nav: values.nav.map((item) => ({ label: item.label.trim(), href: item.href.trim() })),
|
|
110
|
+
footerText: orNull(values.footerText),
|
|
111
|
+
privacyPageId: values.privacyPageId ? Number(values.privacyPageId) : null,
|
|
112
|
+
country: orNull(values.country),
|
|
113
|
+
timeZone: orNull(values.timeZone),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type SettingsTab = "brand" | "contact" | "region" | "navigation";
|
|
118
|
+
|
|
119
|
+
/** Which tab a field (or a list row's field, `socials.2.url`) is on, and its name in error messages. */
|
|
120
|
+
export function settingsFieldInfo(name: string): { tab: SettingsTab; label: string } {
|
|
121
|
+
const [head, index, sub] = name.split(".");
|
|
122
|
+
const row = index !== undefined ? ` ${Number(index) + 1}` : "";
|
|
123
|
+
switch (head) {
|
|
124
|
+
case "siteName":
|
|
125
|
+
return { tab: "brand", label: "Site name" };
|
|
126
|
+
case "tagline":
|
|
127
|
+
return { tab: "brand", label: "Tagline" };
|
|
128
|
+
case "logo":
|
|
129
|
+
case "logoId":
|
|
130
|
+
return { tab: "brand", label: "Logo" };
|
|
131
|
+
case "favicon":
|
|
132
|
+
case "faviconId":
|
|
133
|
+
return { tab: "brand", label: "Site icon" };
|
|
134
|
+
case "allowModeToggle":
|
|
135
|
+
return { tab: "brand", label: "Light and dark switch" };
|
|
136
|
+
case "whatsappNumber":
|
|
137
|
+
return { tab: "contact", label: "WhatsApp number" };
|
|
138
|
+
case "whatsappMessage":
|
|
139
|
+
return { tab: "contact", label: "WhatsApp message" };
|
|
140
|
+
case "address":
|
|
141
|
+
return { tab: "contact", label: "Address" };
|
|
142
|
+
case "openingHours":
|
|
143
|
+
return { tab: "contact", label: "Opening hours" };
|
|
144
|
+
case "socials":
|
|
145
|
+
return { tab: "contact", label: `Social link${row}${sub === "platform" ? ", platform" : sub === "url" ? ", link" : ""}` };
|
|
146
|
+
case "country":
|
|
147
|
+
return { tab: "region", label: "Country" };
|
|
148
|
+
case "timeZone":
|
|
149
|
+
return { tab: "region", label: "Time zone" };
|
|
150
|
+
case "nav":
|
|
151
|
+
return { tab: "navigation", label: `Menu link${row}${sub === "label" ? ", text" : sub === "href" ? ", address" : ""}` };
|
|
152
|
+
case "footerText":
|
|
153
|
+
return { tab: "navigation", label: "Footer text" };
|
|
154
|
+
case "privacyPageId":
|
|
155
|
+
return { tab: "navigation", label: "Privacy policy page" };
|
|
156
|
+
default:
|
|
157
|
+
return { tab: "brand", label: name };
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Server error keys on the form's field names (`logoId` is the `logo` field, `faviconId` the `favicon`). */
|
|
162
|
+
export const settingsFormField = (key: string) => (key === "logoId" ? "logo" : key === "faviconId" ? "favicon" : key);
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// The app's services for plugins (`host()` in @pet-adopt/plugin-sdk): who is signed in, the action
|
|
2
|
+
// wrapper, the client address, rate limits, phone checks, email and safe logging. A plugin package
|
|
3
|
+
// cannot import the app, so it reaches these through the SDK. Loading this module registers them;
|
|
4
|
+
// registry.ts and instrumentation.ts load it before any plugin code runs.
|
|
5
|
+
import { provideHost } from '@pet-adopt/plugin-sdk'
|
|
6
|
+
import { headers } from 'next/headers'
|
|
7
|
+
|
|
8
|
+
import { tag, TAGS } from '@/lib/cache'
|
|
9
|
+
import { isDemo } from '@/lib/demo'
|
|
10
|
+
import { isEmailAddress } from '@/lib/email-address'
|
|
11
|
+
import { PetStatus } from '@/lib/options'
|
|
12
|
+
import { safeRevalidate } from '@/lib/revalidate'
|
|
13
|
+
import { SITE_URL } from '@/lib/seo'
|
|
14
|
+
import { toE164, validatePhone } from '@/lib/phone'
|
|
15
|
+
import { recordActivity } from '@/server/activity'
|
|
16
|
+
import { listEmailTemplates, sendPurposeEmail } from '@/server/email-templates'
|
|
17
|
+
import { logError, run } from '@/server/result'
|
|
18
|
+
import { listPetChoices } from '@/server/pets'
|
|
19
|
+
import { getSessionUser, requirePermission } from '@/server/session'
|
|
20
|
+
import { clientAddress, consumeAttempt } from '@/server/throttle'
|
|
21
|
+
|
|
22
|
+
import { getEmailSender } from '@/server/email'
|
|
23
|
+
import { getPrivacyPolicy } from '@/server/privacy'
|
|
24
|
+
import { getSettings } from '@/server/settings'
|
|
25
|
+
import { open, seal } from '@/server/secret-box'
|
|
26
|
+
|
|
27
|
+
import { getPluginInfo } from './registry'
|
|
28
|
+
|
|
29
|
+
/** `<plugin>.<thing>.<verb>`: lower-case words, starting with the name of a plugin in the config. */
|
|
30
|
+
const PLUGIN_ACTION = /^([a-z0-9-]+)(\.[a-z0-9-]+)+$/
|
|
31
|
+
|
|
32
|
+
provideHost({
|
|
33
|
+
requirePermission,
|
|
34
|
+
// Fail closed for plugins written before roles: "a user" means someone who can change the team's
|
|
35
|
+
// plugin content, so an audit (view-only) account cannot write through an older plugin's action.
|
|
36
|
+
requireUser: () => requirePermission('pluginContent:edit'),
|
|
37
|
+
requireAdmin: () => requirePermission('plugins:edit'),
|
|
38
|
+
run,
|
|
39
|
+
clientAddress: async () => clientAddress(await headers()),
|
|
40
|
+
// Namespaced, so a plugin cannot touch the sign-in counters (and so they are purged with the rest).
|
|
41
|
+
consumeAttempt: (key, rule) => consumeAttempt(`plugin:${key}`, rule),
|
|
42
|
+
phone: { validate: (raw) => validatePhone(raw), toE164: (raw) => toE164(raw) },
|
|
43
|
+
// choices, privacyPolicy and timeZone also run inside a block loader, whose result is cached
|
|
44
|
+
// (src/puck/plugin-block-data.ts): tagging what they read there expires that result with the data.
|
|
45
|
+
// Outside a cache scope (a plugin's server action) tag() does nothing.
|
|
46
|
+
choices: async (source) => {
|
|
47
|
+
if (source === 'pets') {
|
|
48
|
+
tag(TAGS.pets)
|
|
49
|
+
const pets = await listPetChoices()
|
|
50
|
+
return pets.map((pet) => ({ value: String(pet.id), label: pet.status === PetStatus.Pending ? `${pet.name} (adoption pending)` : pet.name }))
|
|
51
|
+
}
|
|
52
|
+
return []
|
|
53
|
+
},
|
|
54
|
+
emailSender: () => getEmailSender(),
|
|
55
|
+
// Async, so a refusal is a rejection like any other sending failure.
|
|
56
|
+
sendTemplatedEmail: async (message) => {
|
|
57
|
+
const purpose = message?.purpose
|
|
58
|
+
if (purpose !== 'team-notification' && purpose !== 'visitor-message') throw new Error(`plugins may send team notifications and visitor messages only, not "${String(purpose)}"`)
|
|
59
|
+
// One mailbox only: a typed "a@x.com, b@y.com" would otherwise reach both.
|
|
60
|
+
const to = typeof message.to === 'string' ? message.to.trim() : ''
|
|
61
|
+
if (!isEmailAddress(to)) throw new Error('sendTemplatedEmail needs one email address in `to`')
|
|
62
|
+
const values = Object.fromEntries(Object.entries(message.values ?? {}).filter(([, value]) => typeof value === 'string').map(([key, value]) => [key, value.slice(0, 500)]))
|
|
63
|
+
return sendPurposeEmail({
|
|
64
|
+
purpose,
|
|
65
|
+
templateId: typeof message.templateId === 'number' ? message.templateId : null,
|
|
66
|
+
fallback: typeof message.fallback === 'string' && /^[a-z0-9-]+:[a-z0-9-]+$/.test(message.fallback) ? message.fallback : null,
|
|
67
|
+
to,
|
|
68
|
+
values,
|
|
69
|
+
// A message to a visitor never carries details, whatever the plugin passes.
|
|
70
|
+
details: purpose === 'team-notification' ? message.details : undefined,
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
// Plugin purposes are kept apart from the site's own ("plugin:" + the plugin's purpose).
|
|
74
|
+
secrets: { seal: (plain, purpose) => seal(plain, `plugin:${purpose}`), open: (sealed, purpose) => open(sealed, `plugin:${purpose}`) },
|
|
75
|
+
privacyPolicy: async () => {
|
|
76
|
+
tag(TAGS.settings, TAGS.pages)
|
|
77
|
+
const policy = await getPrivacyPolicy()
|
|
78
|
+
return { policy: policy ? { title: policy.title, href: policy.href } : null, settingsHref: '/admin/settings?tab=navigation' }
|
|
79
|
+
},
|
|
80
|
+
timeZone: async () => {
|
|
81
|
+
tag(TAGS.settings)
|
|
82
|
+
return (await getSettings()).timeZone
|
|
83
|
+
},
|
|
84
|
+
siteUrl: () => SITE_URL,
|
|
85
|
+
isDemo: () => isDemo(),
|
|
86
|
+
// Every public page: a plugin's block can be on any of them. The tag expires every cached block
|
|
87
|
+
// loader result (src/puck/plugin-block-data.ts), wherever it is read (the editor's preview too).
|
|
88
|
+
revalidateSite: () => {
|
|
89
|
+
try {
|
|
90
|
+
safeRevalidate([['/', 'layout']], [TAGS.pluginBlocks])
|
|
91
|
+
} catch {
|
|
92
|
+
// Never a plugin's problem: pages then refresh when their cache lifetime runs out (a minute).
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
emailTemplates: async (purpose) => (await listEmailTemplates(purpose)).map(({ id, name, seedKey }) => ({ id, name, seedKey })),
|
|
96
|
+
logError,
|
|
97
|
+
// Plugins log changes made by the signed-in person, under the area `plugins`. An action must start
|
|
98
|
+
// with the name of a configured plugin, so a plugin cannot pass its entries off as the site's own.
|
|
99
|
+
recordActivity: async (entry) => {
|
|
100
|
+
try {
|
|
101
|
+
const match = typeof entry?.action === 'string' ? PLUGIN_ACTION.exec(entry.action) : null
|
|
102
|
+
if (!match || !getPluginInfo(match[1])) throw new Error(`activity action "${String(entry?.action)}" must start with a plugin's name`)
|
|
103
|
+
const user = await getSessionUser()
|
|
104
|
+
if (!user) return
|
|
105
|
+
await recordActivity({
|
|
106
|
+
actor: user,
|
|
107
|
+
action: entry.action,
|
|
108
|
+
area: 'plugins',
|
|
109
|
+
summary: String(entry.summary ?? ''),
|
|
110
|
+
subject: entry.subject ? { id: entry.subject.id, label: entry.subject.label ?? null } : null,
|
|
111
|
+
fields: Array.isArray(entry.fields) ? entry.fields.filter((field): field is string => typeof field === 'string') : null,
|
|
112
|
+
})
|
|
113
|
+
} catch (error) {
|
|
114
|
+
logError(error, 'a plugin could not record activity')
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
})
|