alinea
Version:
[](https://npmjs.org/package/alinea) [](https://packagephobia.com/result?p=alinea)
84 lines (82 loc) • 1.82 kB
JavaScript
import "../../chunks/chunk-U5RRZUYZ.js";
// src/backend/resolver/ResolveContext.ts
import { EntryRow } from "alinea/core/EntryRow";
import { Realm } from "alinea/core/pages/Realm";
var ResolveContext = class _ResolveContext {
constructor(data) {
this.data = data;
this.table = EntryRow().as(`E${this.depth}`);
}
table;
linkContext() {
return new _ResolveContext({
realm: this.realm
});
}
get depth() {
return this.data.depth ?? 0;
}
get location() {
return this.data.location ?? [];
}
get realm() {
return this.data.realm ?? Realm.Published;
}
get locale() {
return this.data.locale;
}
get expr() {
return this.data.expr ?? 0 /* InNone */;
}
get Table() {
return this.table;
}
increaseDepth() {
return new _ResolveContext({ ...this.data, depth: this.depth + 1 });
}
decreaseDepth() {
return new _ResolveContext({ ...this.data, depth: this.depth - 1 });
}
get isInSelect() {
return this.expr & 1 /* InSelect */;
}
get isInCondition() {
return this.expr & 2 /* InCondition */;
}
get isInAccess() {
return this.expr & 4 /* InAccess */;
}
get select() {
if (this.isInSelect)
return this;
return new _ResolveContext({
...this.data,
expr: this.expr | 1 /* InSelect */
});
}
get condition() {
if (this.isInCondition)
return this;
return new _ResolveContext({
...this.data,
expr: this.expr | 2 /* InCondition */
});
}
get access() {
if (this.isInAccess)
return this;
return new _ResolveContext({
...this.data,
expr: this.expr | 4 /* InAccess */
});
}
get none() {
return new _ResolveContext({
...this.data,
expr: this.expr | 0 /* InNone */
});
}
};
export {
ResolveContext
};