@react-consulting/rc-kit 0.0.0-stage → 0.13.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 +94 -2
- package/devkit/README.md +301 -0
- package/devkit/cli.test.ts +211 -0
- package/devkit/cli.ts +120 -0
- package/devkit/commands/build.ts +127 -0
- package/devkit/commands/checks.ts +123 -0
- package/devkit/commands/context.ts +47 -0
- package/devkit/commands/db.ts +154 -0
- package/devkit/commands/deploy.ts +46 -0
- package/devkit/commands/dev.ts +191 -0
- package/devkit/commands/doctor.ts +25 -0
- package/devkit/commands/kit.ts +45 -0
- package/devkit/commands/new.ts +81 -0
- package/devkit/commands/registry.ts +20 -0
- package/devkit/commands/secrets.ts +254 -0
- package/devkit/lib/args.ts +65 -0
- package/devkit/lib/audit.test.ts +405 -0
- package/devkit/lib/audit.ts +813 -0
- package/devkit/lib/config.test.ts +203 -0
- package/devkit/lib/config.ts +417 -0
- package/devkit/lib/database/index.test.ts +223 -0
- package/devkit/lib/database/index.ts +314 -0
- package/devkit/lib/database/neon.test.ts +233 -0
- package/devkit/lib/database/neon.ts +357 -0
- package/devkit/lib/database/prepare.ts +54 -0
- package/devkit/lib/deploy-config.test.ts +217 -0
- package/devkit/lib/deploy-config.ts +133 -0
- package/devkit/lib/deploy.test.ts +275 -0
- package/devkit/lib/deploy.ts +177 -0
- package/devkit/lib/dev-gateway.test.ts +128 -0
- package/devkit/lib/dev-gateway.ts +162 -0
- package/devkit/lib/dev-menu.test.ts +114 -0
- package/devkit/lib/dev-menu.ts +332 -0
- package/devkit/lib/dev-secrets.test.ts +156 -0
- package/devkit/lib/dev-secrets.ts +97 -0
- package/devkit/lib/dev.test.ts +194 -0
- package/devkit/lib/dev.ts +119 -0
- package/devkit/lib/doctor.test.ts +144 -0
- package/devkit/lib/doctor.ts +264 -0
- package/devkit/lib/env-file.test.ts +102 -0
- package/devkit/lib/env-file.ts +96 -0
- package/devkit/lib/glob.ts +31 -0
- package/devkit/lib/infisical.test.ts +208 -0
- package/devkit/lib/infisical.ts +139 -0
- package/devkit/lib/json-schema.ts +220 -0
- package/devkit/lib/jsonc.test.ts +53 -0
- package/devkit/lib/jsonc.ts +93 -0
- package/devkit/lib/kit-migrate.test.ts +212 -0
- package/devkit/lib/kit-migrate.ts +617 -0
- package/devkit/lib/kit-package.test.ts +83 -0
- package/devkit/lib/kit-package.ts +57 -0
- package/devkit/lib/kit-version.ts +22 -0
- package/devkit/lib/naming.test.ts +547 -0
- package/devkit/lib/naming.ts +796 -0
- package/devkit/lib/paths.ts +7 -0
- package/devkit/lib/process.ts +78 -0
- package/devkit/lib/project-checks.ts +86 -0
- package/devkit/lib/scaffold.test.ts +302 -0
- package/devkit/lib/scaffold.ts +315 -0
- package/devkit/lib/secrets.test.ts +101 -0
- package/devkit/lib/secrets.ts +125 -0
- package/devkit/lib/sourcemaps.test.ts +86 -0
- package/devkit/lib/sourcemaps.ts +98 -0
- package/devkit/lib/test-utils.ts +68 -0
- package/devkit/lib/workspace.ts +87 -0
- package/devkit/lib/wrangler.ts +231 -0
- package/docs/rc-config.md +93 -0
- package/package.json +86 -4
- package/presets/build.d.ts +15 -0
- package/presets/build.js +53 -0
- package/presets/vite-plus.d.ts +28 -0
- package/presets/vite-plus.js +153 -0
- package/registry/README.md +294 -0
- package/registry/public/r/avatar-stack.json +18 -0
- package/registry/public/r/avatar.json +20 -0
- package/registry/public/r/back-link.json +21 -0
- package/registry/public/r/badge.json +17 -0
- package/registry/public/r/button.json +18 -0
- package/registry/public/r/calendar-days.json +14 -0
- package/registry/public/r/calendar-popover.json +24 -0
- package/registry/public/r/calendar.json +23 -0
- package/registry/public/r/callout.json +20 -0
- package/registry/public/r/card.json +18 -0
- package/registry/public/r/character-counter.json +17 -0
- package/registry/public/r/checkbox.json +22 -0
- package/registry/public/r/choice-cards.json +22 -0
- package/registry/public/r/color-tag.json +17 -0
- package/registry/public/r/combobox.json +24 -0
- package/registry/public/r/confirm-button.json +24 -0
- package/registry/public/r/confirm-dialog.json +23 -0
- package/registry/public/r/copy-button.json +24 -0
- package/registry/public/r/date-picker.json +24 -0
- package/registry/public/r/date-range-picker.json +28 -0
- package/registry/public/r/detail-header.json +17 -0
- package/registry/public/r/detail-row.json +17 -0
- package/registry/public/r/dev-inbox-api.json +33 -0
- package/registry/public/r/dev-toolbar.json +109 -0
- package/registry/public/r/dev-tools-contract.json +15 -0
- package/registry/public/r/dialog.json +23 -0
- package/registry/public/r/empty-state.json +20 -0
- package/registry/public/r/error-state.json +23 -0
- package/registry/public/r/eyebrow.json +17 -0
- package/registry/public/r/fab.json +20 -0
- package/registry/public/r/field-error.json +17 -0
- package/registry/public/r/field-grid.json +17 -0
- package/registry/public/r/field.json +19 -0
- package/registry/public/r/file-picker.json +22 -0
- package/registry/public/r/filter-chips.json +17 -0
- package/registry/public/r/form-section.json +17 -0
- package/registry/public/r/form-sheet.json +22 -0
- package/registry/public/r/icon-button.json +23 -0
- package/registry/public/r/input.json +18 -0
- package/registry/public/r/label.json +18 -0
- package/registry/public/r/list-row.json +17 -0
- package/registry/public/r/loading-state.json +18 -0
- package/registry/public/r/localized-field.json +23 -0
- package/registry/public/r/markdown-text.json +17 -0
- package/registry/public/r/menu.json +21 -0
- package/registry/public/r/money-input.json +17 -0
- package/registry/public/r/month-day-select.json +18 -0
- package/registry/public/r/numbered-step.json +20 -0
- package/registry/public/r/page-actions.json +14 -0
- package/registry/public/r/page-header.json +17 -0
- package/registry/public/r/pending.json +17 -0
- package/registry/public/r/person-option.json +21 -0
- package/registry/public/r/popover.json +20 -0
- package/registry/public/r/progress-bar.json +17 -0
- package/registry/public/r/query-view.json +22 -0
- package/registry/public/r/registry.json +1352 -0
- package/registry/public/r/retry-button.json +21 -0
- package/registry/public/r/rich-text-editor.json +32 -0
- package/registry/public/r/save-bar.json +22 -0
- package/registry/public/r/search-input.json +23 -0
- package/registry/public/r/search-select.json +24 -0
- package/registry/public/r/section-tabs.json +17 -0
- package/registry/public/r/segmented.json +18 -0
- package/registry/public/r/select.json +23 -0
- package/registry/public/r/sheet.json +24 -0
- package/registry/public/r/skeleton.json +17 -0
- package/registry/public/r/spinner.json +20 -0
- package/registry/public/r/stale-notice.json +23 -0
- package/registry/public/r/stat-tile.json +23 -0
- package/registry/public/r/stepper.json +23 -0
- package/registry/public/r/suggestion-strip.json +21 -0
- package/registry/public/r/swatch-picker.json +22 -0
- package/registry/public/r/switch.json +21 -0
- package/registry/public/r/tabs.json +20 -0
- package/registry/public/r/textarea.json +18 -0
- package/registry/public/r/theme.json +15 -0
- package/registry/public/r/timezone-select.json +19 -0
- package/registry/public/r/toaster.json +21 -0
- package/registry/public/r/tooltip.json +17 -0
- package/registry/public/r/ui-labels.json +14 -0
- package/registry/public/r/use-copy-to-clipboard.json +20 -0
- package/registry/public/r/use-online.json +14 -0
- package/registry/public/r/use-stale-queries.json +17 -0
- package/registry/public/r/utils.json +18 -0
- package/registry/public/r/weekday-picker.json +19 -0
- package/registry/public/r/yes-no.json +20 -0
- package/registry/serve.ts +29 -0
- package/rules/architecture.md +47 -0
- package/rules/cloudflare.md +74 -0
- package/rules/code.md +12 -0
- package/rules/git.md +10 -0
- package/rules/index.md +14 -0
- package/rules/observability.md +13 -0
- package/rules/performance.md +39 -0
- package/rules/runtime.md +9 -0
- package/rules/secrets.md +11 -0
- package/rules/stack.md +33 -0
- package/rules/ui.md +23 -0
- package/runtime/ai.test.ts +106 -0
- package/runtime/ai.ts +125 -0
- package/runtime/observability/allowlists.ts +42 -0
- package/runtime/observability/anonymize.test.ts +111 -0
- package/runtime/observability/anonymize.ts +249 -0
- package/runtime/observability/browser.test.ts +46 -0
- package/runtime/observability/browser.ts +126 -0
- package/runtime/observability/server.test.ts +84 -0
- package/runtime/observability/server.ts +152 -0
- package/runtime/observability/tunnel.test.ts +276 -0
- package/runtime/observability/tunnel.ts +360 -0
- package/runtime/observability/user-agent.ts +51 -0
- package/schema/rc.config.schema.json +333 -0
- package/template/.gitattributes +1 -0
- package/template/.github/workflows/ci.yml +64 -0
- package/template/CLAUDE.md +48 -0
- package/template/README.md +50 -0
- package/template/apps/admin/.dev.vars.example +5 -0
- package/template/apps/admin/components.json +24 -0
- package/template/apps/admin/package.json +48 -0
- package/template/apps/admin/public/favicon.svg +1 -0
- package/template/apps/admin/src/components/app-shell.tsx +41 -0
- package/template/apps/admin/src/components/dev-sign-in-links.tsx +57 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-context.ts +13 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-environment-panel.tsx +105 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-inbox-list.tsx +54 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-inbox-message.tsx +104 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-inbox-panel.tsx +130 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-launcher.tsx +45 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-panel.tsx +90 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-types.ts +11 -0
- package/template/apps/admin/src/components/dev-toolbar/dev-toolbar.tsx +61 -0
- package/template/apps/admin/src/components/dev-toolbar/development-devtools.tsx +32 -0
- package/template/apps/admin/src/components/login-form.tsx +115 -0
- package/template/apps/admin/src/components/login-sent.tsx +23 -0
- package/template/apps/admin/src/components/message-list.tsx +44 -0
- package/template/apps/admin/src/components/turnstile-challenge.tsx +140 -0
- package/template/apps/admin/src/components/ui/button.tsx +87 -0
- package/template/apps/admin/src/components/ui/callout.tsx +84 -0
- package/template/apps/admin/src/components/ui/card.tsx +48 -0
- package/template/apps/admin/src/components/ui/eyebrow.tsx +33 -0
- package/template/apps/admin/src/components/ui/field-error.tsx +24 -0
- package/template/apps/admin/src/components/ui/field.tsx +100 -0
- package/template/apps/admin/src/components/ui/input.tsx +73 -0
- package/template/apps/admin/src/components/ui/label.tsx +39 -0
- package/template/apps/admin/src/components/ui/skeleton.tsx +225 -0
- package/template/apps/admin/src/components/ui/spinner.tsx +12 -0
- package/template/apps/admin/src/components/ui/toaster.tsx +33 -0
- package/template/apps/admin/src/components/ui/tooltip.tsx +51 -0
- package/template/apps/admin/src/hooks/use-dev-inbox.ts +25 -0
- package/template/apps/admin/src/hooks/use-dev-toolbar-state.ts +48 -0
- package/template/apps/admin/src/lib/api.ts +39 -0
- package/template/apps/admin/src/lib/auth-client.ts +7 -0
- package/template/apps/admin/src/lib/dev-inbox-links.ts +66 -0
- package/template/apps/admin/src/lib/dev-tools-client.ts +54 -0
- package/template/apps/admin/src/lib/dev-tools-contract.ts +52 -0
- package/template/apps/admin/src/lib/messages.ts +5 -0
- package/template/apps/admin/src/lib/query-keys.ts +3 -0
- package/template/apps/admin/src/lib/security-headers.ts +18 -0
- package/template/apps/admin/src/lib/session.ts +27 -0
- package/template/apps/admin/src/lib/site-url.ts +7 -0
- package/template/apps/admin/src/lib/turnstile.ts +70 -0
- package/template/apps/admin/src/lib/ui-labels.tsx +182 -0
- package/template/apps/admin/src/lib/utils.ts +6 -0
- package/template/apps/admin/src/routeTree.gen.ts +109 -0
- package/template/apps/admin/src/router.tsx +29 -0
- package/template/apps/admin/src/routes/__root.tsx +56 -0
- package/template/apps/admin/src/routes/_app/index.tsx +38 -0
- package/template/apps/admin/src/routes/_app.tsx +26 -0
- package/template/apps/admin/src/routes/login.tsx +48 -0
- package/template/apps/admin/src/styles/app.css +11 -0
- package/template/apps/admin/src/worker.ts +88 -0
- package/template/apps/admin/tsconfig.json +19 -0
- package/template/apps/admin/vite.config.ts +69 -0
- package/template/apps/admin/wrangler.jsonc +92 -0
- package/template/apps/web/.env.example +1 -0
- package/template/apps/web/astro.config.ts +46 -0
- package/template/apps/web/package.json +33 -0
- package/template/apps/web/public/favicon.svg +1 -0
- package/template/apps/web/src/components/ContactForm.astro +78 -0
- package/template/apps/web/src/env.d.ts +11 -0
- package/template/apps/web/src/layouts/BaseLayout.astro +32 -0
- package/template/apps/web/src/lib/api.ts +8 -0
- package/template/apps/web/src/pages/api/messages.ts +32 -0
- package/template/apps/web/src/pages/index.astro +26 -0
- package/template/apps/web/src/pages/media/[...key].ts +4 -0
- package/template/apps/web/src/scripts/contact-form.ts +105 -0
- package/template/apps/web/src/scripts/error-reporting.ts +4 -0
- package/template/apps/web/src/scripts/turnstile.ts +177 -0
- package/template/apps/web/src/styles/global.css +11 -0
- package/template/apps/web/src/worker.ts +34 -0
- package/template/apps/web/tsconfig.json +11 -0
- package/template/apps/web/wrangler.jsonc +45 -0
- package/template/bun.lock +1925 -0
- package/template/bunfig.toml +2 -0
- package/template/gitignore +23 -0
- package/template/package.json +74 -0
- package/template/packages/api/components.json +21 -0
- package/template/packages/api/package.json +30 -0
- package/template/packages/api/src/client.ts +13 -0
- package/template/packages/api/src/cloudflare-env.d.ts +26 -0
- package/template/packages/api/src/emails/escape-html.ts +13 -0
- package/template/packages/api/src/emails/layout.ts +22 -0
- package/template/packages/api/src/emails/magic-link.ts +32 -0
- package/template/packages/api/src/emails/new-message.ts +32 -0
- package/template/packages/api/src/emails/send.ts +14 -0
- package/template/packages/api/src/lib/auth-guard.ts +16 -0
- package/template/packages/api/src/lib/auth.ts +108 -0
- package/template/packages/api/src/lib/context.ts +7 -0
- package/template/packages/api/src/lib/dev-inbox/routes.ts +77 -0
- package/template/packages/api/src/lib/dev-inbox/send.ts +57 -0
- package/template/packages/api/src/lib/dev-inbox/store.ts +185 -0
- package/template/packages/api/src/lib/dev-inbox.ts +6 -0
- package/template/packages/api/src/lib/dev-tools-contract.ts +52 -0
- package/template/packages/api/src/lib/environment.ts +17 -0
- package/template/packages/api/src/lib/turnstile.ts +33 -0
- package/template/packages/api/src/media.ts +45 -0
- package/template/packages/api/src/routes/admin-messages.ts +21 -0
- package/template/packages/api/src/routes/dev.ts +31 -0
- package/template/packages/api/src/routes/health.ts +7 -0
- package/template/packages/api/src/routes/messages.ts +58 -0
- package/template/packages/api/src/schemas.ts +18 -0
- package/template/packages/api/src/server.ts +29 -0
- package/template/packages/api/tsconfig.json +10 -0
- package/template/packages/db/migrations/0001_init.sql +79 -0
- package/template/packages/db/package.json +34 -0
- package/template/packages/db/prisma/schema.prisma +95 -0
- package/template/packages/db/prisma.config.ts +9 -0
- package/template/packages/db/scripts/migrate.ts +15 -0
- package/template/packages/db/scripts/new-migration.ts +185 -0
- package/template/packages/db/scripts/reset.ts +54 -0
- package/template/packages/db/scripts/seed.ts +44 -0
- package/template/packages/db/scripts/wrangler.ts +35 -0
- package/template/packages/db/src/d1.ts +7 -0
- package/template/packages/db/src/migration-guard.test.ts +43 -0
- package/template/packages/db/src/migration-guard.ts +51 -0
- package/template/packages/db/src/new-migration.test.ts +16 -0
- package/template/packages/db/src/scope.ts +38 -0
- package/template/packages/db/src/seed.ts +30 -0
- package/template/packages/db/src/sql.ts +42 -0
- package/template/packages/db/tsconfig.json +8 -0
- package/template/packages/shared/components.json +21 -0
- package/template/packages/shared/package.json +33 -0
- package/template/packages/shared/src/edge/origins.ts +20 -0
- package/template/packages/shared/src/edge/turnstile.ts +11 -0
- package/template/packages/shared/src/locales.ts +13 -0
- package/template/packages/shared/src/message-rules.ts +16 -0
- package/template/packages/shared/src/messages.test.ts +26 -0
- package/template/packages/shared/src/messages.ts +30 -0
- package/template/packages/shared/src/observability/build-release.ts +9 -0
- package/template/packages/shared/src/observability/error-reporting.ts +31 -0
- package/template/packages/shared/src/observability/error-tunnel.ts +20 -0
- package/template/packages/shared/src/observability/sentry-browser.ts +1 -0
- package/template/packages/shared/src/observability/server-errors.ts +74 -0
- package/template/packages/shared/src/project.ts +1 -0
- package/template/packages/shared/src/styles/rc-theme.css +138 -0
- package/template/packages/shared/src/styles/theme.css +9 -0
- package/template/packages/shared/tsconfig.json +10 -0
- package/template/rc.config.json +25 -0
- package/template/scripts/bootstrap-local.ts +42 -0
- package/template/tsconfig.base.json +20 -0
- package/template/tsconfig.json +8 -0
- package/template/tsconfig.worker.json +7 -0
- package/template/turbo.json +40 -0
- package/template/vite.config.ts +8 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const ANCHOR_RE = /<a\b[^>]*\bhref\s*=\s*(["'])(.*?)\1[^>]*>([\s\S]*?)<\/a>/gi
|
|
2
|
+
const TAG_RE = /<[^>]+>/g
|
|
3
|
+
const WHITESPACE_RE = /\s+/g
|
|
4
|
+
const BARE_URL_RE = /https?:\/\/[^\s"'<>]+/g
|
|
5
|
+
const ACTION_PATH_RE =
|
|
6
|
+
/\/(auth|invitation|magic-link|verify|reset)\b|[?&](token|code)=/i
|
|
7
|
+
const NUMERIC_ENTITY_RE = /&#(x[0-9a-f]+|\d+);/gi
|
|
8
|
+
const MAX_ACTION_LINKS = 3
|
|
9
|
+
|
|
10
|
+
export interface DevInboxActionLink {
|
|
11
|
+
href: string
|
|
12
|
+
label: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function decodeEntities(value: string): string {
|
|
16
|
+
return value
|
|
17
|
+
.replace(NUMERIC_ENTITY_RE, (_match, code: string) =>
|
|
18
|
+
String.fromCodePoint(
|
|
19
|
+
code.startsWith("x") ? Number.parseInt(code.slice(1), 16) : Number(code)
|
|
20
|
+
)
|
|
21
|
+
)
|
|
22
|
+
.replaceAll("&", "&")
|
|
23
|
+
.replaceAll(""", '"')
|
|
24
|
+
.replaceAll("'", "'")
|
|
25
|
+
.replaceAll("<", "<")
|
|
26
|
+
.replaceAll(">", ">")
|
|
27
|
+
.replaceAll(" ", " ")
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function toPlainText(html: string): string {
|
|
31
|
+
return decodeEntities(html.replace(TAG_RE, " "))
|
|
32
|
+
.replace(WHITESPACE_RE, " ")
|
|
33
|
+
.trim()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The buttons a mail asks its reader to press (sign-in, invitation, reset), so the toolbar opens them in one click. */
|
|
37
|
+
export function extractActionLinks(
|
|
38
|
+
html: string | null,
|
|
39
|
+
text: string
|
|
40
|
+
): DevInboxActionLink[] {
|
|
41
|
+
const links: DevInboxActionLink[] = []
|
|
42
|
+
const seen = new Set<string>()
|
|
43
|
+
|
|
44
|
+
const add = (href: string, label: string) => {
|
|
45
|
+
if (
|
|
46
|
+
!href.startsWith("http") ||
|
|
47
|
+
seen.has(href) ||
|
|
48
|
+
!ACTION_PATH_RE.test(href)
|
|
49
|
+
) {
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
seen.add(href)
|
|
54
|
+
links.push({ href, label: label || href })
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
for (const match of (html ?? "").matchAll(ANCHOR_RE)) {
|
|
58
|
+
add(decodeEntities(match[2] ?? "").trim(), toPlainText(match[3] ?? ""))
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
for (const match of text.matchAll(BARE_URL_RE)) {
|
|
62
|
+
add(match[0], "")
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return links.slice(0, MAX_ACTION_LINKS)
|
|
66
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEV_API_PREFIX,
|
|
3
|
+
DEV_ROUTES,
|
|
4
|
+
type DevEnvironment,
|
|
5
|
+
type DevInboxMessage,
|
|
6
|
+
type DevInboxSummary,
|
|
7
|
+
type DevOk,
|
|
8
|
+
} from "@/lib/dev-tools-contract"
|
|
9
|
+
|
|
10
|
+
export class DevToolsRequestError extends Error {
|
|
11
|
+
readonly status: number
|
|
12
|
+
|
|
13
|
+
constructor(path: string, status: number) {
|
|
14
|
+
super(`${path} → ${status}`)
|
|
15
|
+
this.name = "DevToolsRequestError"
|
|
16
|
+
this.status = status
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function createDevToolsClient(base: string = DEV_API_PREFIX) {
|
|
21
|
+
const request = async <T>(path: string, method = "GET"): Promise<T> => {
|
|
22
|
+
const response = await fetch(`${base}${path}`, {
|
|
23
|
+
credentials: "include",
|
|
24
|
+
headers: { accept: "application/json" },
|
|
25
|
+
method,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
throw new DevToolsRequestError(path, response.status)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (await response.json()) as T
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
base,
|
|
37
|
+
clearInbox: () => request<DevOk>(DEV_ROUTES.inbox, "DELETE"),
|
|
38
|
+
environment: () => request<DevEnvironment>(DEV_ROUTES.environment),
|
|
39
|
+
inbox: () => request<DevInboxSummary[]>(DEV_ROUTES.inbox),
|
|
40
|
+
inboxMessage: (id: string) =>
|
|
41
|
+
request<DevInboxMessage>(DEV_ROUTES.inboxMessage(id)),
|
|
42
|
+
inboxMessageHtmlUrl: (id: string) =>
|
|
43
|
+
`${base}${DEV_ROUTES.inboxMessageHtml(id)}`,
|
|
44
|
+
markRead: (id: string) =>
|
|
45
|
+
request<DevOk>(DEV_ROUTES.inboxMessageRead(id), "POST"),
|
|
46
|
+
queryKeys: {
|
|
47
|
+
environment: ["dev-tools", base, "environment"] as const,
|
|
48
|
+
inbox: ["dev-tools", base, "inbox"] as const,
|
|
49
|
+
inboxMessage: (id: string) => ["dev-tools", base, "inbox", id] as const,
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type DevToolsClient = ReturnType<typeof createDevToolsClient>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export const DEV_API_PREFIX = "/api/dev"
|
|
2
|
+
|
|
3
|
+
export const DEV_INBOX_KEY_PREFIX = "dev-inbox/"
|
|
4
|
+
|
|
5
|
+
export const DEV_ROUTES = {
|
|
6
|
+
environment: "/environment",
|
|
7
|
+
inbox: "/inbox",
|
|
8
|
+
inboxMessage: (id: string) => `/inbox/${encodeURIComponent(id)}`,
|
|
9
|
+
inboxMessageHtml: (id: string) => `/inbox/${encodeURIComponent(id)}/html`,
|
|
10
|
+
inboxMessageRead: (id: string) => `/inbox/${encodeURIComponent(id)}/read`,
|
|
11
|
+
} as const
|
|
12
|
+
|
|
13
|
+
export interface DevInboxSummary {
|
|
14
|
+
id: string
|
|
15
|
+
readAt: string | null
|
|
16
|
+
receivedAt: string
|
|
17
|
+
subject: string
|
|
18
|
+
to: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface DevInboxMessage extends DevInboxSummary {
|
|
22
|
+
html: string | null
|
|
23
|
+
text: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface DevEnvironmentEntry {
|
|
27
|
+
label: string
|
|
28
|
+
value: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface DevLink {
|
|
32
|
+
href: string
|
|
33
|
+
label: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface DevEnvironment {
|
|
37
|
+
/** The value of `ENVIRONMENT`: always "local" when the routes answer. */
|
|
38
|
+
environment: string
|
|
39
|
+
entries: DevEnvironmentEntry[]
|
|
40
|
+
links: DevLink[]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface DevOk {
|
|
44
|
+
ok: true
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface OutgoingEmail {
|
|
48
|
+
html?: string
|
|
49
|
+
subject: string
|
|
50
|
+
text: string
|
|
51
|
+
to: string
|
|
52
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const HEADERS: Record<string, string> = {
|
|
2
|
+
"referrer-policy": "same-origin",
|
|
3
|
+
"strict-transport-security": "max-age=31536000; includeSubDomains",
|
|
4
|
+
"x-content-type-options": "nosniff",
|
|
5
|
+
"x-frame-options": "DENY",
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function withSecurityHeaders(response: Response): Response {
|
|
9
|
+
const secured = new Response(response.body, response)
|
|
10
|
+
|
|
11
|
+
for (const [name, value] of Object.entries(HEADERS)) {
|
|
12
|
+
if (!secured.headers.has(name)) {
|
|
13
|
+
secured.headers.set(name, value)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return secured
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createServerFn } from "@tanstack/react-start"
|
|
2
|
+
import { getRequestHeaders } from "@tanstack/react-start/server"
|
|
3
|
+
|
|
4
|
+
export interface TSessionUser {
|
|
5
|
+
id: string
|
|
6
|
+
name: string
|
|
7
|
+
email: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const getSessionUser = createServerFn({ method: "GET" }).handler(
|
|
11
|
+
async (): Promise<TSessionUser | null> => {
|
|
12
|
+
const headers = getRequestHeaders()
|
|
13
|
+
if (!headers.get("cookie")) {
|
|
14
|
+
return null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { auth } = await import("@tpl/api/server")
|
|
18
|
+
const session = await auth().api.getSession({ headers })
|
|
19
|
+
if (!session?.user) {
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const { id, name, email } = session.user
|
|
24
|
+
|
|
25
|
+
return { id, name, email }
|
|
26
|
+
}
|
|
27
|
+
)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { TURNSTILE_TEST_SITE_KEY } from "@tpl/shared/edge/turnstile"
|
|
2
|
+
|
|
3
|
+
const SCRIPT_URL =
|
|
4
|
+
"https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit"
|
|
5
|
+
|
|
6
|
+
export interface TTurnstileRenderOptions {
|
|
7
|
+
sitekey: string
|
|
8
|
+
action?: string
|
|
9
|
+
appearance?: "always" | "execute" | "interaction-only"
|
|
10
|
+
language?: string
|
|
11
|
+
"refresh-expired"?: "auto" | "manual" | "never"
|
|
12
|
+
callback?: (token: string) => void
|
|
13
|
+
"error-callback"?: (code: string) => void
|
|
14
|
+
"expired-callback"?: () => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface TTurnstileApi {
|
|
18
|
+
render: (container: HTMLElement, options: TTurnstileRenderOptions) => string
|
|
19
|
+
reset: (widgetId: string) => void
|
|
20
|
+
remove: (widgetId: string) => void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare global {
|
|
24
|
+
interface Window {
|
|
25
|
+
turnstile?: TTurnstileApi
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function turnstileSiteKey(): string {
|
|
30
|
+
const configured = import.meta.env.VITE_TURNSTILE_SITE_KEY as
|
|
31
|
+
| string
|
|
32
|
+
| undefined
|
|
33
|
+
|
|
34
|
+
if (configured) {
|
|
35
|
+
return configured
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return import.meta.env.DEV ? TURNSTILE_TEST_SITE_KEY : ""
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let loading: Promise<TTurnstileApi> | null = null
|
|
42
|
+
|
|
43
|
+
export function loadTurnstile(): Promise<TTurnstileApi> {
|
|
44
|
+
if (window.turnstile) {
|
|
45
|
+
return Promise.resolve(window.turnstile)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
loading ??= new Promise<TTurnstileApi>((resolve, reject) => {
|
|
49
|
+
const script = document.createElement("script")
|
|
50
|
+
script.src = SCRIPT_URL
|
|
51
|
+
script.async = true
|
|
52
|
+
|
|
53
|
+
script.addEventListener("load", () => {
|
|
54
|
+
if (window.turnstile) {
|
|
55
|
+
resolve(window.turnstile)
|
|
56
|
+
} else {
|
|
57
|
+
reject(new Error("turnstile-unavailable"))
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
script.addEventListener("error", () => {
|
|
61
|
+
loading = null
|
|
62
|
+
script.remove()
|
|
63
|
+
reject(new Error("turnstile-unavailable"))
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
document.head.appendChild(script)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return loading
|
|
70
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { createContext, type ReactNode, useContext, useMemo } from "react"
|
|
2
|
+
|
|
3
|
+
export interface UiLabels {
|
|
4
|
+
/** An `Intl` locale for numbers, dates and sorting: "fr-FR", "en-GB". */
|
|
5
|
+
locale: string
|
|
6
|
+
cancel: string
|
|
7
|
+
save: string
|
|
8
|
+
close: string
|
|
9
|
+
confirm: string
|
|
10
|
+
ok: string
|
|
11
|
+
copy: string
|
|
12
|
+
copied: string
|
|
13
|
+
copyFailed: string
|
|
14
|
+
search: string
|
|
15
|
+
searchEmpty: string
|
|
16
|
+
clearSearch: string
|
|
17
|
+
loading: string
|
|
18
|
+
required: string
|
|
19
|
+
optional: string
|
|
20
|
+
retry: string
|
|
21
|
+
unsaved: string
|
|
22
|
+
details: string
|
|
23
|
+
stale: string
|
|
24
|
+
discardTitle: string
|
|
25
|
+
discardBody: string
|
|
26
|
+
discardKeep: string
|
|
27
|
+
discardLeave: string
|
|
28
|
+
decrease: (label: string) => string
|
|
29
|
+
increase: (label: string) => string
|
|
30
|
+
chooseFile: string
|
|
31
|
+
chooseFiles: string
|
|
32
|
+
dropFiles: string
|
|
33
|
+
removeFile: (name: string) => string
|
|
34
|
+
previousMonth: string
|
|
35
|
+
nextMonth: string
|
|
36
|
+
startTime: string
|
|
37
|
+
endTime: string
|
|
38
|
+
openEnd: string
|
|
39
|
+
pickStart: string
|
|
40
|
+
pickEnd: string
|
|
41
|
+
offlineTitle: string
|
|
42
|
+
offlineBody: string
|
|
43
|
+
forbiddenTitle: string
|
|
44
|
+
forbiddenBody: string
|
|
45
|
+
notFoundTitle: string
|
|
46
|
+
notFoundBody: string
|
|
47
|
+
errorTitle: string
|
|
48
|
+
errorBody: string
|
|
49
|
+
yes: string
|
|
50
|
+
no: string
|
|
51
|
+
useCustom: (value: string) => string
|
|
52
|
+
showSuggestions: string
|
|
53
|
+
untranslated: (language: string) => string
|
|
54
|
+
missingTranslation: string
|
|
55
|
+
languages: string
|
|
56
|
+
editor: {
|
|
57
|
+
toolbar: string
|
|
58
|
+
bold: string
|
|
59
|
+
italic: string
|
|
60
|
+
underline: string
|
|
61
|
+
bulletList: string
|
|
62
|
+
orderedList: string
|
|
63
|
+
blockquote: string
|
|
64
|
+
link: string
|
|
65
|
+
linkUrl: string
|
|
66
|
+
linkPlaceholder: string
|
|
67
|
+
linkInvalid: string
|
|
68
|
+
linkApply: string
|
|
69
|
+
linkRemove: string
|
|
70
|
+
clear: string
|
|
71
|
+
undo: string
|
|
72
|
+
redo: string
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const FRENCH_UI_LABELS: UiLabels = {
|
|
77
|
+
locale: "fr-FR",
|
|
78
|
+
cancel: "Annuler",
|
|
79
|
+
save: "Enregistrer",
|
|
80
|
+
close: "Fermer",
|
|
81
|
+
confirm: "Confirmer",
|
|
82
|
+
ok: "Valider",
|
|
83
|
+
copy: "Copier",
|
|
84
|
+
copied: "Copié",
|
|
85
|
+
copyFailed: "Copie impossible.",
|
|
86
|
+
search: "Rechercher",
|
|
87
|
+
searchEmpty: "Aucun résultat.",
|
|
88
|
+
clearSearch: "Effacer la recherche",
|
|
89
|
+
loading: "Chargement…",
|
|
90
|
+
required: "obligatoire",
|
|
91
|
+
optional: "facultatif",
|
|
92
|
+
retry: "Réessayer",
|
|
93
|
+
unsaved: "Modifications non enregistrées",
|
|
94
|
+
details: "Détails techniques",
|
|
95
|
+
stale:
|
|
96
|
+
"La dernière actualisation a échoué : les données affichées peuvent être anciennes.",
|
|
97
|
+
discardTitle: "Abandonner les modifications ?",
|
|
98
|
+
discardBody: "Ce que vous avez saisi sera perdu.",
|
|
99
|
+
discardKeep: "Continuer la saisie",
|
|
100
|
+
discardLeave: "Abandonner",
|
|
101
|
+
decrease: (label) => `Diminuer ${label}`,
|
|
102
|
+
increase: (label) => `Augmenter ${label}`,
|
|
103
|
+
chooseFile: "Choisir un fichier",
|
|
104
|
+
chooseFiles: "Choisir des fichiers",
|
|
105
|
+
dropFiles: "ou déposez-les ici",
|
|
106
|
+
removeFile: (name) => `Retirer ${name}`,
|
|
107
|
+
previousMonth: "Mois précédent",
|
|
108
|
+
nextMonth: "Mois suivant",
|
|
109
|
+
startTime: "Heure de début",
|
|
110
|
+
endTime: "Heure de fin",
|
|
111
|
+
openEnd: "Sans date de fin",
|
|
112
|
+
pickStart: "Choisissez le premier jour",
|
|
113
|
+
pickEnd: "Choisissez le dernier jour",
|
|
114
|
+
offlineTitle: "Hors ligne",
|
|
115
|
+
offlineBody: "Vérifiez la connexion, puis réessayez.",
|
|
116
|
+
forbiddenTitle: "Accès refusé",
|
|
117
|
+
forbiddenBody: "Votre compte n'a pas accès à cette page.",
|
|
118
|
+
notFoundTitle: "Introuvable",
|
|
119
|
+
notFoundBody: "Cet élément n'existe pas ou plus.",
|
|
120
|
+
errorTitle: "Chargement impossible",
|
|
121
|
+
errorBody: "Une erreur est survenue. Réessayez dans un instant.",
|
|
122
|
+
yes: "Oui",
|
|
123
|
+
no: "Non",
|
|
124
|
+
useCustom: (value) => `Utiliser « ${value} »`,
|
|
125
|
+
showSuggestions: "Afficher les suggestions",
|
|
126
|
+
untranslated: (language) => `${language} : à traduire`,
|
|
127
|
+
missingTranslation:
|
|
128
|
+
"Pas encore traduit : le texte de la première langue sera affiché.",
|
|
129
|
+
languages: "Langues",
|
|
130
|
+
editor: {
|
|
131
|
+
toolbar: "Mise en forme",
|
|
132
|
+
bold: "Gras",
|
|
133
|
+
italic: "Italique",
|
|
134
|
+
underline: "Souligné",
|
|
135
|
+
bulletList: "Liste à puces",
|
|
136
|
+
orderedList: "Liste numérotée",
|
|
137
|
+
blockquote: "Citation",
|
|
138
|
+
link: "Lien",
|
|
139
|
+
linkUrl: "Adresse du lien",
|
|
140
|
+
linkPlaceholder: "exemple.com",
|
|
141
|
+
linkInvalid: "Adresse web ou e-mail invalide.",
|
|
142
|
+
linkApply: "Appliquer",
|
|
143
|
+
linkRemove: "Retirer le lien",
|
|
144
|
+
clear: "Effacer la mise en forme",
|
|
145
|
+
undo: "Annuler",
|
|
146
|
+
redo: "Rétablir",
|
|
147
|
+
},
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const UiLabelsContext = createContext<UiLabels>(FRENCH_UI_LABELS)
|
|
151
|
+
|
|
152
|
+
export type UiLabelsOverrides = Partial<Omit<UiLabels, "editor">> & {
|
|
153
|
+
editor?: Partial<UiLabels["editor"]>
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Lets a project plug its own i18n into the shared components; unset keys keep the French defaults. */
|
|
157
|
+
export function UiLabelsProvider({
|
|
158
|
+
labels,
|
|
159
|
+
children,
|
|
160
|
+
}: {
|
|
161
|
+
children: ReactNode
|
|
162
|
+
labels: UiLabelsOverrides
|
|
163
|
+
}) {
|
|
164
|
+
const value = useMemo(
|
|
165
|
+
() => ({
|
|
166
|
+
...FRENCH_UI_LABELS,
|
|
167
|
+
...labels,
|
|
168
|
+
editor: { ...FRENCH_UI_LABELS.editor, ...labels.editor },
|
|
169
|
+
}),
|
|
170
|
+
[labels]
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<UiLabelsContext.Provider value={value}>
|
|
175
|
+
{children}
|
|
176
|
+
</UiLabelsContext.Provider>
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function useUiLabels(): UiLabels {
|
|
181
|
+
return useContext(UiLabelsContext)
|
|
182
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
|
|
5
|
+
// noinspection JSUnusedGlobalSymbols
|
|
6
|
+
|
|
7
|
+
// This file was automatically generated by TanStack Router.
|
|
8
|
+
// You should NOT make any changes in this file as it will be overwritten.
|
|
9
|
+
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|
10
|
+
|
|
11
|
+
import { Route as rootRouteImport } from './routes/__root'
|
|
12
|
+
import { Route as AppRouteImport } from './routes/_app'
|
|
13
|
+
import { Route as LoginRouteImport } from './routes/login'
|
|
14
|
+
import { Route as AppIndexRouteImport } from './routes/_app/index'
|
|
15
|
+
|
|
16
|
+
const AppRoute = AppRouteImport.update({
|
|
17
|
+
id: '/_app',
|
|
18
|
+
getParentRoute: () => rootRouteImport,
|
|
19
|
+
} as any)
|
|
20
|
+
const LoginRoute = LoginRouteImport.update({
|
|
21
|
+
id: '/login',
|
|
22
|
+
path: '/login',
|
|
23
|
+
getParentRoute: () => rootRouteImport,
|
|
24
|
+
} as any)
|
|
25
|
+
const AppIndexRoute = AppIndexRouteImport.update({
|
|
26
|
+
id: '/',
|
|
27
|
+
path: '/',
|
|
28
|
+
getParentRoute: () => AppRoute,
|
|
29
|
+
} as any)
|
|
30
|
+
|
|
31
|
+
export interface FileRoutesByFullPath {
|
|
32
|
+
'/': typeof AppIndexRoute
|
|
33
|
+
'/login': typeof LoginRoute
|
|
34
|
+
}
|
|
35
|
+
export interface FileRoutesByTo {
|
|
36
|
+
'/login': typeof LoginRoute
|
|
37
|
+
'/': typeof AppIndexRoute
|
|
38
|
+
}
|
|
39
|
+
export interface FileRoutesById {
|
|
40
|
+
__root__: typeof rootRouteImport
|
|
41
|
+
'/_app': typeof AppRouteWithChildren
|
|
42
|
+
'/login': typeof LoginRoute
|
|
43
|
+
'/_app/': typeof AppIndexRoute
|
|
44
|
+
}
|
|
45
|
+
export interface FileRouteTypes {
|
|
46
|
+
fileRoutesByFullPath: FileRoutesByFullPath
|
|
47
|
+
fullPaths: '/' | '/login'
|
|
48
|
+
fileRoutesByTo: FileRoutesByTo
|
|
49
|
+
to: '/login' | '/'
|
|
50
|
+
id: '__root__' | '/_app' | '/login' | '/_app/'
|
|
51
|
+
fileRoutesById: FileRoutesById
|
|
52
|
+
}
|
|
53
|
+
export interface RootRouteChildren {
|
|
54
|
+
AppRoute: typeof AppRouteWithChildren
|
|
55
|
+
LoginRoute: typeof LoginRoute
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare module '@tanstack/react-router' {
|
|
59
|
+
interface FileRoutesByPath {
|
|
60
|
+
'/_app': {
|
|
61
|
+
id: '/_app'
|
|
62
|
+
path: ''
|
|
63
|
+
fullPath: '/'
|
|
64
|
+
preLoaderRoute: typeof AppRouteImport
|
|
65
|
+
parentRoute: typeof rootRouteImport
|
|
66
|
+
}
|
|
67
|
+
'/login': {
|
|
68
|
+
id: '/login'
|
|
69
|
+
path: '/login'
|
|
70
|
+
fullPath: '/login'
|
|
71
|
+
preLoaderRoute: typeof LoginRouteImport
|
|
72
|
+
parentRoute: typeof rootRouteImport
|
|
73
|
+
}
|
|
74
|
+
'/_app/': {
|
|
75
|
+
id: '/_app/'
|
|
76
|
+
path: '/'
|
|
77
|
+
fullPath: '/'
|
|
78
|
+
preLoaderRoute: typeof AppIndexRouteImport
|
|
79
|
+
parentRoute: typeof AppRoute
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface AppRouteChildren {
|
|
85
|
+
AppIndexRoute: typeof AppIndexRoute
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const AppRouteChildren: AppRouteChildren = {
|
|
89
|
+
AppIndexRoute: AppIndexRoute,
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const AppRouteWithChildren = AppRoute._addFileChildren(AppRouteChildren)
|
|
93
|
+
|
|
94
|
+
const rootRouteChildren: RootRouteChildren = {
|
|
95
|
+
AppRoute: AppRouteWithChildren,
|
|
96
|
+
LoginRoute: LoginRoute,
|
|
97
|
+
}
|
|
98
|
+
export const routeTree = rootRouteImport
|
|
99
|
+
._addFileChildren(rootRouteChildren)
|
|
100
|
+
._addFileTypes<FileRouteTypes>()
|
|
101
|
+
|
|
102
|
+
import type { getRouter } from './router.tsx'
|
|
103
|
+
import type { createStart } from '@tanstack/react-start'
|
|
104
|
+
declare module '@tanstack/react-start' {
|
|
105
|
+
interface Register {
|
|
106
|
+
ssr: true
|
|
107
|
+
router: Awaited<ReturnType<typeof getRouter>>
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { initErrorReporting } from "@tpl/shared/observability/error-reporting"
|
|
2
|
+
import { QueryClient } from "@tanstack/react-query"
|
|
3
|
+
import { createRouter } from "@tanstack/react-router"
|
|
4
|
+
import { routeTree } from "./routeTree.gen"
|
|
5
|
+
|
|
6
|
+
export function getRouter() {
|
|
7
|
+
if (typeof document !== "undefined") {
|
|
8
|
+
initErrorReporting({ dsn: import.meta.env.VITE_SENTRY_DSN, front: "admin" })
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const queryClient = new QueryClient({
|
|
12
|
+
defaultOptions: {
|
|
13
|
+
queries: { staleTime: 30_000, refetchOnWindowFocus: false },
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
return createRouter({
|
|
18
|
+
routeTree,
|
|
19
|
+
context: { queryClient },
|
|
20
|
+
defaultPreload: "intent",
|
|
21
|
+
scrollRestoration: true,
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare module "@tanstack/react-router" {
|
|
26
|
+
interface Register {
|
|
27
|
+
router: ReturnType<typeof getRouter>
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { PROJECT_TITLE } from "@tpl/shared/project"
|
|
2
|
+
import { type QueryClient, QueryClientProvider } from "@tanstack/react-query"
|
|
3
|
+
import {
|
|
4
|
+
createRootRouteWithContext,
|
|
5
|
+
HeadContent,
|
|
6
|
+
Outlet,
|
|
7
|
+
Scripts,
|
|
8
|
+
} from "@tanstack/react-router"
|
|
9
|
+
import { DevSignInLinks } from "@/components/dev-sign-in-links"
|
|
10
|
+
import { DevelopmentDevtools } from "@/components/dev-toolbar/development-devtools"
|
|
11
|
+
import { Toaster } from "@/components/ui/toaster"
|
|
12
|
+
import { TooltipProvider } from "@/components/ui/tooltip"
|
|
13
|
+
import appCss from "@/styles/app.css?url"
|
|
14
|
+
|
|
15
|
+
export const Route = createRootRouteWithContext<{ queryClient: QueryClient }>()(
|
|
16
|
+
{
|
|
17
|
+
head: () => ({
|
|
18
|
+
meta: [
|
|
19
|
+
{ charSet: "utf-8" },
|
|
20
|
+
{
|
|
21
|
+
name: "viewport",
|
|
22
|
+
content: "width=device-width, initial-scale=1, viewport-fit=cover",
|
|
23
|
+
},
|
|
24
|
+
{ name: "robots", content: "noindex, nofollow" },
|
|
25
|
+
{ title: `Back office · ${PROJECT_TITLE}` },
|
|
26
|
+
],
|
|
27
|
+
links: [
|
|
28
|
+
{ rel: "stylesheet", href: appCss },
|
|
29
|
+
{ rel: "icon", href: "/favicon.svg", type: "image/svg+xml" },
|
|
30
|
+
],
|
|
31
|
+
}),
|
|
32
|
+
component: RootComponent,
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
function RootComponent() {
|
|
37
|
+
const { queryClient } = Route.useRouteContext()
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<html lang="fr">
|
|
41
|
+
<head>
|
|
42
|
+
<HeadContent />
|
|
43
|
+
</head>
|
|
44
|
+
<body>
|
|
45
|
+
<QueryClientProvider client={queryClient}>
|
|
46
|
+
<TooltipProvider>
|
|
47
|
+
<Outlet />
|
|
48
|
+
<Toaster />
|
|
49
|
+
<DevelopmentDevtools environmentActions={<DevSignInLinks />} />
|
|
50
|
+
</TooltipProvider>
|
|
51
|
+
</QueryClientProvider>
|
|
52
|
+
<Scripts />
|
|
53
|
+
</body>
|
|
54
|
+
</html>
|
|
55
|
+
)
|
|
56
|
+
}
|