mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-25 06:13:04 +00:00
style: format server and shared with prettier
A mechanical prettier --write over server/src, server/tests, server/scripts and shared/src with the workspaces' .prettierrc; nothing but layout and import order changes, and every file keeps the same set of imports. shared is formatted throughout and its format baseline is empty. The server baseline keeps the 35 files that Prettier would grow past their lint:size limit (they need a split first, which is not a formatting change), and the generated entity files stay as their generator writes them.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { Controller, Get, UseGuards } from '@nestjs/common';
|
||||
import { InjectRepository } from '@mikro-orm/nestjs';
|
||||
import type { PluginPoiCategory } from '@trek/shared';
|
||||
import { Plugins } from '../../db/entities/Plugins.entity';
|
||||
import type { PluginsRepository } from '../../db/repositories/Plugins.repository';
|
||||
import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';
|
||||
import { pluginsEnabled } from './kill-switch';
|
||||
import { POI_CATEGORY_PERMISSION, poiCategoriesOf } from './poi-categories';
|
||||
import { InjectRepository } from '@mikro-orm/nestjs';
|
||||
import { Controller, Get, UseGuards } from '@nestjs/common';
|
||||
import type { PluginPoiCategory } from '@trek/shared';
|
||||
|
||||
/**
|
||||
* GET /api/plugins — the authenticated feed of ACTIVE plugins the client renders
|
||||
@@ -74,7 +74,9 @@ function slotOf(capabilities: string): ActivePlugin['slot'] {
|
||||
try {
|
||||
const c = JSON.parse(capabilities || '{}') as { widget?: { slot?: string } };
|
||||
const slot = c.widget?.slot;
|
||||
return slot === 'hero' || slot === 'place-detail' || slot === 'day-detail' || slot === 'reservation-detail' ? slot : 'sidebar';
|
||||
return slot === 'hero' || slot === 'place-detail' || slot === 'day-detail' || slot === 'reservation-detail'
|
||||
? slot
|
||||
: 'sidebar';
|
||||
} catch {
|
||||
return 'sidebar';
|
||||
}
|
||||
@@ -83,7 +85,14 @@ function slotOf(capabilities: string): ActivePlugin['slot'] {
|
||||
// Re-validated here even though the manifest parser already gated the values —
|
||||
// the capabilities column is a JSON blob, and the tab list the client hides
|
||||
// must never be steerable by a hand-edited row ('plan' stays unhideable).
|
||||
const REPLACEABLE_TABS: ReadonlySet<string> = new Set(['transports', 'buchungen', 'listen', 'finanzplan', 'dateien', 'collab']);
|
||||
const REPLACEABLE_TABS: ReadonlySet<string> = new Set([
|
||||
'transports',
|
||||
'buchungen',
|
||||
'listen',
|
||||
'finanzplan',
|
||||
'dateien',
|
||||
'collab',
|
||||
]);
|
||||
|
||||
function settingsUiOf(capabilities: string): boolean {
|
||||
try {
|
||||
@@ -116,7 +125,8 @@ function routeProfilesOf(capabilities: string, granted: string): ActivePlugin['r
|
||||
for (const v of c.routeProfiles.slice(0, 3)) {
|
||||
if (!v || typeof v !== 'object') continue;
|
||||
const p = v as { id?: unknown; label?: unknown; icon?: unknown };
|
||||
if (typeof p.id !== 'string' || !PROFILE_RE.test(p.id) || typeof p.label !== 'string' || !p.label.trim()) continue;
|
||||
if (typeof p.id !== 'string' || !PROFILE_RE.test(p.id) || typeof p.label !== 'string' || !p.label.trim())
|
||||
continue;
|
||||
out.push({
|
||||
id: p.id,
|
||||
label: p.label.trim().slice(0, 40),
|
||||
@@ -134,8 +144,13 @@ function tripPageOf(capabilities: string): ActivePlugin['tripPage'] {
|
||||
const c = JSON.parse(capabilities || '{}') as { tripPage?: { replaces?: unknown; position?: unknown } };
|
||||
const tp = c.tripPage;
|
||||
if (!tp || typeof tp !== 'object') return undefined;
|
||||
const replaces = Array.isArray(tp.replaces) ? tp.replaces.filter((t): t is string => typeof t === 'string' && REPLACEABLE_TABS.has(t)) : [];
|
||||
const position = typeof tp.position === 'number' && Number.isInteger(tp.position) && tp.position >= 0 && tp.position <= 50 ? tp.position : undefined;
|
||||
const replaces = Array.isArray(tp.replaces)
|
||||
? tp.replaces.filter((t): t is string => typeof t === 'string' && REPLACEABLE_TABS.has(t))
|
||||
: [];
|
||||
const position =
|
||||
typeof tp.position === 'number' && Number.isInteger(tp.position) && tp.position >= 0 && tp.position <= 50
|
||||
? tp.position
|
||||
: undefined;
|
||||
if (!replaces.length && position === undefined) return undefined;
|
||||
return { ...(replaces.length ? { replaces } : {}), ...(position !== undefined ? { position } : {}) };
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user