/** * This Source Code is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright (c) Infonomic Company Limited */ import type { AdminResourceConfig, BlockAdminConfig, CollectionDefinition, CollectionGroupDefinition } from '../@types/index.js'; /** * Validate the dashboard collection-group registry and every reference to it. * * Enforced rules: * 1. Each `collectionGroups` entry has a non-blank `name` and `label`. * 2. No two entries share a `name`. * 3. Every admin resource's `group` names a declared entry. This single * rule covers both a typographical error and the case where `group` was set * but the registry was never declared. * * Throws a plain `Error` for the same reason the rest of this module does — * configuration validation runs at startup, before the logger and error * registry are necessarily wired up. */ export declare function validateCollectionGroups(collectionGroups: readonly CollectionGroupDefinition[] | undefined, admins: readonly AdminResourceConfig[] | undefined): void; /** * Validate every admin config in a configuration. * * Enforced rules (per admin config): * 1. Slug pairing — `admin.slug` matches exactly one `collection.path`. * 2. Placement — when `layout` is present, every top-level schema field * name appears exactly once across the union of all `tabSet.tabs[].fields`, * all `row.fields`, all `group.fields`, `layout.main`, and `layout.sidebar`. * 3. Name resolution — every string referenced in any `fields[]` array or * layout region resolves to either a top-level schema field name or a * declared primitive name. The literal `'path'` is explicitly rejected * with a message pointing the user at `useAsPath`. * 4. No collisions — primitive names (across `tabSets` / `rows` / `groups`) * are unique within an admin config and don't shadow schema field names. * 5. Nesting — `tabSets` only appear in `layout.main`; rows contain only * schema field names; groups exclude tabSets and nested groups. * 6. `fields` map sanity — every key in `admin.fields` is a dotted, * index-free schema path resolving to a field declaration (top-level * name or a path through group/array fields; never through blocks). * 7. `defaultSort` sanity — `field` resolves to a top-level schema field * or a document-level column (`createdAt` / `updatedAt` / `path`), the * direction (when given) is `asc` | `desc`, and the option is rejected * on `orderable: true` collections (manual ordering owns their default * sort and the drag-to-reorder canonical-view check assumes it). * 8. Collection groups — the `collectionGroups` registry is well-formed * (non-blank, unique names) and every `admin.group` names a declared * entry. See `validateCollectionGroups`. * * Throws a plain `Error` (not a `BylineError`) because configuration * validation runs at startup, before the logger and error registry are * necessarily wired up. */ export declare function validateAdminConfigs(admins: readonly AdminResourceConfig[] | undefined, collections: readonly CollectionDefinition[], collectionGroups?: readonly CollectionGroupDefinition[]): void; /** * Validate every block admin config in a configuration. * * Enforced rules (per `AdminConfig.blockAdmin` entry): * 1. Block pairing — `blockType` matches a block declared on at least one * `type: 'blocks'` field across the registered collections (blocks have * no global registry; the collections walk is the source of truth). * 2. Uniqueness — no two entries share a `blockType`. * 3. `fields` map sanity — every key is a dotted, index-free schema path * resolving to a field declaration of the block (top-level name or a * path through group/array fields; never through a nested blocks field). * When the same `blockType` appears in several collections, a key is * accepted if it resolves in any declaration site (union semantics). * * Throws a plain `Error` for the same reason `validateAdminConfigs` does — * this runs at startup, before the logger is necessarily wired up. */ export declare function validateBlockAdminConfigs(blockAdmins: readonly BlockAdminConfig[] | undefined, collections: readonly CollectionDefinition[]): void;