/**
 * Structural reader for the tenancy contract `@adonis-agora/context` publishes on its global slots.
 * Never imports that package: with the slot missing, too old, or throwing, tenancy reads as OFF, so
 * media behaves exactly as it does without tenancy.
 *
 * The tenant here is the customer a piece of data belongs to (an organization, a clinic…), not a
 * process topology.
 */
/** One level of a tenant chain. */
export interface TenantLevel {
    id: string;
    kind: string;
    slug?: string;
    role?: string;
}
/** The active tenant, as context publishes it. */
export interface TenantRef extends TenantLevel {
    source?: string;
    chain?: TenantLevel[];
    family?: string;
}
/** How a read or write must be scoped right now. */
export type TenantFilter = {
    mode: 'system';
} | {
    mode: 'all';
} | {
    mode: 'tenantless';
} | {
    mode: 'tenant';
    tenant: TenantRef;
    chain?: TenantLevel[];
};
/** The `tenancy` option of `config/media.ts`. */
export type MediaTenancyOption = 'inherit' | false | {
    /** `'inherit'` (default) follows `tenancy.enabled` in `config/context.ts`. */
    enabled?: 'inherit' | boolean;
    /** Tenant kinds media honours; another kind reads as no tenant. Default: context's. */
    kinds?: string[];
    /**
     * Files with no tenant: `'tenantless'` (default) shows them only to requests without a
     * tenant; `'shared'` also shows them inside every tenant.
     */
    nullRows?: 'tenantless' | 'shared';
    /**
     * Store new files under `t/<tenantId>/…` (default `true` once tenancy is on). Existing files
     * never move: each record keeps the path it was written to.
     */
    pathPrefix?: boolean;
};
/** {@link MediaTenancyOption} resolved against context. */
export interface ResolvedMediaTenancy {
    enabled: boolean;
    kinds?: string[];
    nullRows: 'tenantless' | 'shared';
    pathPrefix: boolean;
}
/** Tenancy off: nothing is stamped, filtered or prefixed. */
export declare const TENANCY_OFF: ResolvedMediaTenancy;
/** Resolve media's `tenancy` option. With no (or an old) context, tenancy is off. */
export declare function resolveMediaTenancy(option: MediaTenancyOption | undefined): ResolvedMediaTenancy;
/**
 * How the current request (or job) must be scoped. Tenancy off → `system` (nothing filtered). A
 * tenant of a kind media does not honour reads as `tenantless`. A context configured with
 * `required: true` throws here when there is no tenant.
 */
export declare function currentTenantFilter(tenancy: ResolvedMediaTenancy): TenantFilter;
/** The tenant id to stamp on a write right now: the tenant's id in `tenant` mode, else `null`. */
export declare function currentTenantId(tenancy: ResolvedMediaTenancy): string | null;
/** A tenant set reads are confined to: these ids, plus rows with no tenant when `includeNull`. */
export interface TenantScope {
    tenants: readonly string[];
    includeNull: boolean;
}
/** The {@link TenantScope} of a filter, or `undefined` for "no filtering" (`system` / `all`). */
export declare function scopeOfFilter(filter: TenantFilter, nullRows?: 'tenantless' | 'shared'): TenantScope | undefined;
/** The scope reads must apply right now (`undefined` = unfiltered). */
export declare function currentTenantScope(tenancy: ResolvedMediaTenancy): TenantScope | undefined;
/** Whether a row stamped `tenantId` is inside `scope` (`undefined` scope = everything). */
export declare function inScope(scope: TenantScope | undefined, tenantId: string | null | undefined): boolean;
/** The scope as a list of tenant ids with `null` standing for "no tenant" (`undefined` = all). */
export declare function scopeIds(scope: TenantScope | undefined): Array<string | null> | undefined;
/** Run `fn` inside `tenant` (or no tenant), through context; plain `fn()` without context. */
export declare function withTenant<T>(tenant: {
    id: string;
    kind: string;
} | null, fn: () => T): T;
/** Run `fn` across every tenant (context's `allTenants`); plain `fn()` without context. */
export declare function allTenants<T>(fn: () => T): T;
/** Display labels for tenant ids, from context's label resolver; ids map to themselves otherwise. */
export declare function tenantLabels(ids: string[], kind?: string): Promise<Record<string, string>>;
/** The storage prefix of a tenant's new files: `t/<tenantId>/`. */
export declare function tenantPathPrefix(tenantId: string): string;
//# sourceMappingURL=tenancy.d.ts.map