/** * ObjectQL * Copyright (c) 2026-present ObjectStack Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import { IObjectRepository } from './repository'; export interface ObjectQLContext { userId?: string; spaceId?: string; roles: string[]; /** * Sudo Mode / System Bypass. */ isSystem?: boolean; /** * Returns a repository proxy bound to this context. * All operations performed via this proxy inherit userId, spaceId, and transaction. */ object(entityName: string): IObjectRepository; /** * Execute a function within a transaction. * The callback receives a new context 'trxCtx' which inherits userId, spaceId from this context. */ transaction(callback: (trxCtx: ObjectQLContext) => Promise): Promise; /** * Returns a new context with system privileges (isSystem: true). * It shares the same transaction scope as the current context. */ sudo(): ObjectQLContext; /** * Internal: Driver-specific transaction handle. */ transactionHandle?: unknown; } export interface ObjectQLContextOptions { userId?: string; spaceId?: string; roles?: string[]; isSystem?: boolean; }