/** * 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 AbilityDescriptor, AbilityRegistry, type SessionProvider } from '@byline/auth'; import type { Logger as PinoLogger } from 'pino'; import { type BylineLogger } from './lib/logger.js'; import { type CollectionRecord } from './services/collection-bootstrap.js'; import type { CollectionDefinition, IDbAdapter, IStorageProvider, ResolvedServerConfig, ServerConfig } from './@types/index.js'; import type { RecurringTaskDefinition } from './scheduler/types.js'; export interface BylineCore { config: ResolvedServerConfig; collections: readonly CollectionDefinition[]; db: IDbAdapter; storage: IStorageProvider | undefined; logger: BylineLogger; /** * Registered collections, keyed by `path`, with their current DB row id, * schema version, and fingerprint. Populated by `ensureCollections()` at * startup. Prefer `getCollectionRecord(path)` for lookups. */ collectionRecords: Map; /** * Throwing lookup for a collection's registration record. Use this * wherever you need `(collectionId, collectionVersion)` — callers that * hit this accessor do not need a DB round-trip. */ getCollectionRecord: (path: string) => CollectionRecord; /** * Ability registry. Populated at init time with the kind-aware ability * family contributed by every declared document resource. * * Plugins and future subsystems contribute their own abilities via * `registerAbility()` — or directly against `core.abilities` — typically * during server bootstrap and before any admin UI renders. * * Consumed at runtime by `AdminAuth.assertAbility()` and at design * time by the admin role-editor UI. See docs/07-auth-and-security/01-authn-authz.md. */ abilities: AbilityRegistry; /** Convenience wrapper around `abilities.register()`. */ registerAbility: (descriptor: AbilityDescriptor) => void; /** Convenience wrapper around `abilities.list()`. */ listAbilities: () => AbilityDescriptor[]; /** Convenience wrapper around `abilities.byGroup()`. */ getAbilitiesByGroup: () => Map; /** * Configured session provider. Phase 3 leaves this optional — the admin * server-fn middleware wired in Phase 5 will tighten the contract where * authentication is required. */ sessionProvider: SessionProvider | undefined; /** * Adapter-built admin store bundle (users / roles / permissions / * refresh tokens). Passed through from `ServerConfig.adminStore` so * consumers (server fns, seeds, admin commands) have a single * adapter-agnostic handle instead of reconstructing the store or * casting `db` to the concrete adapter type. * * Undefined when the installation does not configure admin. */ adminStore: TAdminStore | undefined; /** * Validated recurring-task definitions (`ServerConfig.recurringTasks`), * empty when none are configured. `runDueTasks(core)` and * `startBylineScheduler(core)` read this vetted set so no caller can * substitute another; `initBylineCore()` does not start a timer. */ recurringTasks: readonly RecurringTaskDefinition[]; } /** * Initialize Byline CMS core services via the typed registry. * * This is the recommended server-side entry point. It composes the * dependency graph and populates the global config singleton for * backward compatibility with `getServerConfig()`. * * @param config - Server configuration (collections, db, storage, i18n). * @param pinoLogger - Optional raw Pino instance. When omitted a default * `pino({ level: 'info' })` is constructed via dynamic import so the * pino runtime stays out of the client bundle (see import comment above). */ export declare const initBylineCore: (config: ServerConfig, pinoLogger?: PinoLogger) => Promise>; /** * Typed accessor for the composed `BylineCore` registered by * `initBylineCore`. Throws if init has not run yet. * * The generic `TAdminStore` parameter mirrors `BylineCore` — * callers that consume `core.adminStore` should pass the concrete admin * store type (e.g. `getBylineCore()`); callers that don't * touch `adminStore` can omit it. */ export declare function getBylineCore(): BylineCore;