fix(schema): track client-side schema deviations, restore schema.ts fidelity
src/types/schema.ts had drifted from the official schema contract: a `clientOnly` field had been added to `FilterEnum` to support client-side log filtering. Restored it to match upstream exactly and moved the deviation-only type into a new intersection type in src/lib/schemaDeviationTypes.ts instead. Audited the codebase for every place the UI does something the official schema doesn't support and tagged each with `// SCHEMA-DEVIATION: <id>`, documented in the new SCHEMA_DEVIATIONS.md registry (what, why, and the ideal server-side fix): - log-client-filters: Level/Event filters on Log Entries, applied client-side because x:Log/query rejects them as JMAP filters. - account-quota-usage-column: synthetic quotaUsage column on the Accounts list. - mailbox-client-hierarchy-sort: full-fetch + client-side sort to reconstruct mailbox parent/child hierarchy. - webapp-enabled-column-fallback: synthetic "Enabled" column label for x:Application when the schema list doesn't define one. Other viewName/objectName special cases (x:OtpAuth, x:Expression, x:Rate, x:Action, x:Trace, CustomComponent/*) were checked against upstream and are pre-existing architecture, not fork deviations.
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
import type { Schema } from '@/types/schema';
|
||||
|
||||
/**
|
||||
* SCHEMA-DEVIATION: account-quota-usage-column (see SCHEMA_DEVIATIONS.md)
|
||||
*
|
||||
* The Accounts list only shows Email/Full Name/Created At, hiding role and
|
||||
* storage usage that otherwise require opening each account individually.
|
||||
* `createdAt` is dropped to make room; `roles` is a real property so it
|
||||
|
||||
+19
-5
@@ -5,8 +5,11 @@
|
||||
*/
|
||||
|
||||
import type { Schema } from '@/types/schema';
|
||||
import type { ClientOnlyFilterEnum } from './schemaDeviationTypes';
|
||||
|
||||
/**
|
||||
* SCHEMA-DEVIATION: log-client-filters (see SCHEMA_DEVIATIONS.md)
|
||||
*
|
||||
* The Stalwart JMAP backend rejects `level`/`event` as filter conditions on
|
||||
* `x:Log/query` (`unsupportedFilter`), even though both properties are
|
||||
* already returned per row. Until the backend adds real support, these two
|
||||
@@ -18,17 +21,28 @@ export function withClientLogFilters(schema: Schema): Schema {
|
||||
const logList = schema.lists['x:Log'];
|
||||
if (!logList || !schema.enums['TracingLevel'] || !schema.enums['EventType']) return schema;
|
||||
|
||||
const levelFilter: ClientOnlyFilterEnum = {
|
||||
type: 'enum',
|
||||
field: 'level',
|
||||
enumName: 'TracingLevel',
|
||||
label: 'Level',
|
||||
clientOnly: true,
|
||||
};
|
||||
const eventFilter: ClientOnlyFilterEnum = {
|
||||
type: 'enum',
|
||||
field: 'event',
|
||||
enumName: 'EventType',
|
||||
label: 'Event',
|
||||
clientOnly: true,
|
||||
};
|
||||
|
||||
return {
|
||||
...schema,
|
||||
lists: {
|
||||
...schema.lists,
|
||||
'x:Log': {
|
||||
...logList,
|
||||
filters: [
|
||||
...(logList.filters ?? []),
|
||||
{ type: 'enum', field: 'level', enumName: 'TracingLevel', label: 'Level', clientOnly: true },
|
||||
{ type: 'enum', field: 'event', enumName: 'EventType', label: 'Event', clientOnly: true },
|
||||
],
|
||||
filters: [...(logList.filters ?? []), levelFilter, eventFilter],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <hello@stalw.art>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
import type { FilterEnum } from '@/types/schema';
|
||||
|
||||
/**
|
||||
* Type augmentations for tracked schema deviations (see SCHEMA_DEVIATIONS.md).
|
||||
*
|
||||
* `src/types/schema.ts` mirrors the server's schema contract and must stay
|
||||
* aligned with the official webui/server types — it is never edited to
|
||||
* accommodate a deviation. When a deviation needs to carry extra data on an
|
||||
* otherwise-official schema shape, the augmented type lives here instead,
|
||||
* as an intersection with the official type, and is imported only by the
|
||||
* deviation's own code.
|
||||
*/
|
||||
|
||||
// SCHEMA-DEVIATION: log-client-filters (see SCHEMA_DEVIATIONS.md)
|
||||
export type ClientOnlyFilterEnum = FilterEnum & { clientOnly?: boolean };
|
||||
|
||||
export function isClientOnlyFilterEnum(f: FilterEnum): f is ClientOnlyFilterEnum {
|
||||
return (f as ClientOnlyFilterEnum).clientOnly === true;
|
||||
}
|
||||
Reference in New Issue
Block a user