@@ -29,6 +29,10 @@ import {
2929} from '@objectstack/spec/system' ;
3030import { ExecutionContext , ExecutionContextInput , ExecutionContextSchema } from '@objectstack/spec/kernel' ;
3131import type { FlowFunctionEffect } from '@objectstack/spec/automation' ;
32+ // Imported from spec directly rather than through `@objectstack/core`'s
33+ // re-export block: that block is labelled backward-compatibility, and this
34+ // contract is new (#5945).
35+ import type { IScopedContext , IScopedObjectRepository } from '@objectstack/spec/contracts' ;
3236import {
3337 IDataDriver ,
3438 IDataEngine ,
@@ -7305,7 +7309,21 @@ export class ObjectQL implements IObjectQLEngine {
73057309 * and convenience aliases (create, updateById, deleteById) matching
73067310 * the @objectql/core ObjectRepository API.
73077311 */
7308- export class ObjectRepository {
7312+ /**
7313+ * A repository bound to one object and one execution context — what
7314+ * `ScopedContext.object(name)` returns, and what a hook reaches as
7315+ * `ctx.api.object(name)`.
7316+ *
7317+ * `implements IScopedObjectRepository` (#5945): the six members that contract
7318+ * declares are the ones the documentation corpus is measured to CALL, and the
7319+ * `implements` clause is what keeps the two from drifting — before it, the
7320+ * only descriptions of this face were the private slices each consumer
7321+ * hand-rolled (`type CrossObjectApi = …`), which nothing checked. The class
7322+ * stays WIDER than the contract on purpose (`create`, `delete`, `deleteById`,
7323+ * `aggregate`, `execute`); `implements` allows that, and those members join the
7324+ * contract when a call site turns up to justify them.
7325+ */
7326+ export class ObjectRepository implements IScopedObjectRepository {
73097327 constructor (
73107328 private objectName : string ,
73117329 private context : ExecutionContextInput ,
@@ -7398,12 +7416,18 @@ export class ObjectRepository {
73987416
73997417/**
74007418 * Scoped execution context with object() accessor.
7401- *
7419+ *
74027420 * Provides identity (userId, tenantId/spaceId, roles),
74037421 * repository access via object(), privilege escalation via sudo(),
74047422 * and transactional execution via transaction().
7423+ *
7424+ * `implements IScopedContext` (#5945) — this class IS `HookContext.api`, built
7425+ * per dispatch by {@link ObjectQL.buildHookApi}. The contract declares the two
7426+ * members hooks reach (`object`, `transaction`); `sudo()`, the discrete
7427+ * begin/commit/rollback trio and the identity getters stay off it, so this
7428+ * class is deliberately wider than what it implements.
74057429 */
7406- export class ScopedContext {
7430+ export class ScopedContext implements IScopedContext {
74077431 constructor (
74087432 private executionContext : ExecutionContextInput ,
74097433 private engine : IDataEngine
0 commit comments