akanjs 3.0.0-alpha.71 → 3.0.0-alpha.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/cookie.ts +21 -34
- package/client/csrTypes.ts +0 -12
- package/client/frameConfig.ts +13 -0
- package/common/Logger.ts +13 -6
- package/common/TrustedProxy.ts +134 -0
- package/common/clamp.ts +2 -0
- package/common/dynamicRecord.ts +12 -0
- package/common/index.ts +5 -1
- package/common/isValidDate.ts +1 -1
- package/common/requestOrigin.ts +32 -0
- package/common/{httpClient.ts → restClient.ts} +16 -9
- package/constant/types.ts +22 -0
- package/dictionary/base.dictionary.ts +4 -0
- package/dictionary/trans.ts +24 -5
- package/document/dataLoader.ts +0 -4
- package/document/filterMeta.ts +2 -2
- package/document/loaderInfo.ts +4 -1
- package/fetch/client/fetchClient.ts +65 -88
- package/fetch/client/fetchHandle.ts +57 -0
- package/fetch/client/httpClient.ts +42 -14
- package/fetch/client/sliceInitHandle.ts +101 -0
- package/fetch/fetchType/appliedReturn.type.ts +64 -1
- package/fetch/fetchType/sliceFetch.type.ts +5 -5
- package/fetch/requestStorage.ts +19 -5
- package/index.ts +16 -2
- package/local/apps/serverLifecycle/serverLifecycle-local.db-shm +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local_solid.db-shm +0 -0
- package/package.json +1 -1
- package/server/akanApp.ts +3 -19
- package/server/akanAppHeaders.ts +10 -4
- package/server/akanOption.ts +14 -1
- package/server/akanServer.ts +3 -0
- package/server/cachePolicy.ts +2 -11
- package/server/decorators.ts +12 -3
- package/server/devtools/constantSerializer.ts +8 -1
- package/server/di/diLifecycle.ts +21 -1
- package/server/di/resolveHierarchy.ts +3 -3
- package/server/imageOptimizer.ts +2 -17
- package/server/mcp/McpDispatcher.ts +8 -2
- package/server/resolver/database.resolver.ts +13 -8
- package/server/resolver/signal.resolver.ts +3 -3
- package/server/routeTreeBuilder.ts +1 -15
- package/server/routing/apiRouter.ts +4 -5
- package/server/routing/appWsData.ts +9 -6
- package/server/staticPath.ts +34 -0
- package/server/webRouter.ts +35 -41
- package/service/adapt.ts +1 -5
- package/service/predefinedAdaptor/cache.adaptor.ts +8 -4
- package/service/predefinedAdaptor/database.adaptor.ts +37 -1766
- package/service/predefinedAdaptor/sql/PendingStoreEnsures.ts +22 -0
- package/service/predefinedAdaptor/sql/QueryCompiler.ts +225 -0
- package/service/predefinedAdaptor/sql/SqlDocumentStore.ts +812 -0
- package/service/predefinedAdaptor/sql/UpdateCompiler.ts +67 -0
- package/service/predefinedAdaptor/sql/dialect/postgres.ts +151 -0
- package/service/predefinedAdaptor/sql/dialect/sqlite.ts +134 -0
- package/service/predefinedAdaptor/sql/driver/bunSqlite.ts +29 -0
- package/service/predefinedAdaptor/sql/driver/libsql.ts +37 -0
- package/service/predefinedAdaptor/sql/driver/postgres.ts +42 -0
- package/service/predefinedAdaptor/sql/types.ts +251 -0
- package/service/predefinedAdaptor/sql/values.ts +91 -0
- package/signal/CrossSiteGuard.ts +71 -0
- package/signal/SignalFailure.ts +51 -0
- package/signal/endpoint.ts +2 -2
- package/signal/exception.ts +43 -6
- package/signal/index.ts +2 -0
- package/signal/intercept.ts +5 -2
- package/signal/internal.ts +10 -2
- package/signal/serializer/fetch.serializer.ts +11 -1
- package/signal/signalContext.ts +25 -28
- package/signal/slice.ts +1 -1
- package/store/SliceRequest.ts +23 -0
- package/store/action.ts +177 -114
- package/store/agent/AgentBridge.ts +3 -1
- package/store/agentic/StExposeBuilder.ts +7 -4
- package/store/agentic/StStateBuilder.ts +9 -4
- package/store/agentic/StToolBuilder.ts +21 -7
- package/store/store.ts +1 -1
- package/store/storeInstance.ts +3 -3
- package/store/storeRegistry.ts +1 -1
- package/types/client/cookie.d.ts +13 -2
- package/types/client/csrTypes.d.ts +0 -1
- package/types/client/frameConfig.d.ts +1 -0
- package/types/common/TrustedProxy.d.ts +24 -0
- package/types/common/clamp.d.ts +2 -0
- package/types/common/dynamicRecord.d.ts +14 -0
- package/types/common/index.d.ts +5 -1
- package/types/common/requestOrigin.d.ts +14 -0
- package/types/common/restClient.d.ts +27 -0
- package/types/constant/types.d.ts +13 -0
- package/types/dictionary/base.dictionary.d.ts +1 -1
- package/types/dictionary/dictionary.d.ts +8 -8
- package/types/document/dataLoader.d.ts +0 -3
- package/types/document/filterMeta.d.ts +2 -2
- package/types/document/loaderInfo.d.ts +2 -2
- package/types/fetch/client/fetchHandle.d.ts +24 -0
- package/types/fetch/client/httpClient.d.ts +2 -0
- package/types/fetch/client/sliceInitHandle.d.ts +29 -0
- package/types/fetch/fetchType/appliedReturn.type.d.ts +38 -1
- package/types/fetch/fetchType/sliceFetch.type.d.ts +5 -5
- package/types/fetch/requestStorage.d.ts +14 -0
- package/types/index.d.ts +17 -2
- package/types/server/akanOption.d.ts +8 -1
- package/types/server/decorators.d.ts +12 -2
- package/types/server/di/diLifecycle.d.ts +9 -1
- package/types/server/routeTreeBuilder.d.ts +1 -2
- package/types/server/routing/appWsData.d.ts +7 -3
- package/types/server/staticPath.d.ts +17 -0
- package/types/service/adapt.d.ts +1 -1
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +15 -407
- package/types/service/predefinedAdaptor/sql/PendingStoreEnsures.d.ts +6 -0
- package/types/service/predefinedAdaptor/sql/QueryCompiler.d.ts +28 -0
- package/types/service/predefinedAdaptor/sql/SqlDocumentStore.d.ts +127 -0
- package/types/service/predefinedAdaptor/sql/UpdateCompiler.d.ts +17 -0
- package/types/service/predefinedAdaptor/sql/dialect/postgres.d.ts +27 -0
- package/types/service/predefinedAdaptor/sql/dialect/sqlite.d.ts +27 -0
- package/types/service/predefinedAdaptor/sql/driver/bunSqlite.d.ts +16 -0
- package/types/service/predefinedAdaptor/sql/driver/libsql.d.ts +17 -0
- package/types/service/predefinedAdaptor/sql/driver/postgres.d.ts +17 -0
- package/types/service/predefinedAdaptor/sql/types.d.ts +226 -0
- package/types/service/predefinedAdaptor/sql/values.d.ts +13 -0
- package/types/signal/CrossSiteGuard.d.ts +44 -0
- package/types/signal/SignalFailure.d.ts +28 -0
- package/types/signal/exception.d.ts +38 -54774
- package/types/signal/index.d.ts +2 -0
- package/types/signal/intercept.d.ts +3 -3
- package/types/signal/internal.d.ts +5 -1
- package/types/signal/serializer/fetch.serializer.d.ts +7 -1
- package/types/store/SliceRequest.d.ts +16 -0
- package/types/store/agentic/StToolBuilder.d.ts +10 -1
- package/types/ui/Agent/Menu.d.ts +1 -1
- package/types/ui/Field/Choice.d.ts +52 -0
- package/types/ui/Field/Collection.d.ts +51 -0
- package/types/ui/Field/DateField.d.ts +32 -0
- package/types/ui/Field/Label.d.ts +9 -0
- package/types/ui/Field/NumberField.d.ts +43 -0
- package/types/ui/Field/Relation.d.ts +80 -0
- package/types/ui/Field/Text.d.ts +101 -0
- package/types/ui/Field/index.d.ts +50 -0
- package/types/ui/Field.d.ts +1 -412
- package/types/ui/Load/Edit_Client.d.ts +3 -1
- package/types/ui/Load/Stream.d.ts +22 -0
- package/types/ui/Load/index.d.ts +2 -0
- package/types/ui/System/Root.d.ts +4 -0
- package/types/ui/index.d.ts +1 -1
- package/types/ui/recipe/badgeRecipe.d.ts +2 -2
- package/types/ui/recipe/buttonRecipe.d.ts +2 -2
- package/types/webkit/useCamera.d.ts +10 -1
- package/types/webkit/usePurchase.d.ts +4 -0
- package/ui/Agent/Menu.tsx +2 -2
- package/ui/Data/TableList.tsx +1 -1
- package/ui/DraggableList.tsx +1 -2
- package/ui/Field/Choice.tsx +172 -0
- package/ui/Field/Collection.tsx +293 -0
- package/ui/Field/DateField.tsx +138 -0
- package/ui/Field/Label.tsx +31 -0
- package/ui/Field/NumberField.tsx +169 -0
- package/ui/Field/Relation.tsx +387 -0
- package/ui/Field/Text.tsx +360 -0
- package/ui/Field/index.tsx +70 -0
- package/ui/Input.tsx +3 -3
- package/ui/Load/Edit.tsx +2 -2
- package/ui/Load/Edit_Client.tsx +11 -3
- package/ui/Load/Pagination.tsx +25 -25
- package/ui/Load/Stream.tsx +38 -0
- package/ui/Load/Units.tsx +50 -37
- package/ui/Load/View.tsx +25 -17
- package/ui/Load/index.ts +2 -0
- package/ui/Model/EditModal.tsx +7 -7
- package/ui/Signal/Message.tsx +7 -7
- package/ui/Signal/PubSub.tsx +4 -1
- package/ui/System/Client.tsx +0 -2
- package/ui/System/Gtag.tsx +1 -1
- package/ui/System/Root.tsx +4 -0
- package/ui/index.ts +1 -1
- package/ui/overlayPosition.ts +1 -2
- package/webkit/useCamera.tsx +22 -6
- package/webkit/useCodepush.tsx +2 -2
- package/webkit/useCsrValues.ts +1 -3
- package/webkit/useFetch.ts +4 -3
- package/webkit/useFrameRuntime.ts +14 -7
- package/webkit/usePurchase.tsx +4 -1
- package/fetch/serializer/fetch.serializer.ts +0 -142
- package/fetch/serializer/index.ts +0 -1
- package/types/common/httpClient.d.ts +0 -20
- package/types/fetch/serializer/fetch.serializer.d.ts +0 -14
- package/types/fetch/serializer/index.d.ts +0 -1
- package/types/fetch/serializer.d.ts +0 -1
- package/ui/Field.tsx +0 -1639
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class PendingStoreEnsures {
|
|
2
|
+
readonly #pending = new Set<Promise<void>>();
|
|
3
|
+
#closed = false;
|
|
4
|
+
|
|
5
|
+
track(ensure: Promise<void>): void {
|
|
6
|
+
const tracked = ensure
|
|
7
|
+
.catch((error: unknown) => {
|
|
8
|
+
if (this.#closed) return;
|
|
9
|
+
throw error;
|
|
10
|
+
})
|
|
11
|
+
.finally(() => {
|
|
12
|
+
this.#pending.delete(tracked);
|
|
13
|
+
});
|
|
14
|
+
this.#pending.add(tracked);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Let them finish against a live connection. Call before closing it. */
|
|
18
|
+
async settle(): Promise<void> {
|
|
19
|
+
this.#closed = true;
|
|
20
|
+
await Promise.allSettled([...this.#pending]);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { type DocumentQuery, type DocumentQueryNode, searchColumns } from "akanjs/document";
|
|
2
|
+
import { DEFAULT_SEARCH_WEIGHTS, toMatchExpression } from "../searchIndex";
|
|
3
|
+
import { quoteIdent } from "../sqlDescriptor";
|
|
4
|
+
import {
|
|
5
|
+
BASE_COLUMNS,
|
|
6
|
+
type CompileContext,
|
|
7
|
+
type CompiledQuery,
|
|
8
|
+
type FieldMap,
|
|
9
|
+
QUERY_OPERATOR_KEYS,
|
|
10
|
+
type QueryLeafOps,
|
|
11
|
+
type QueryOperatorName,
|
|
12
|
+
type SearchJoin,
|
|
13
|
+
type SqlDialect,
|
|
14
|
+
} from "./types";
|
|
15
|
+
import { BASE_COLUMN_LEAF } from "./values";
|
|
16
|
+
|
|
17
|
+
export class QueryCompiler {
|
|
18
|
+
constructor(
|
|
19
|
+
private readonly fields: FieldMap,
|
|
20
|
+
private readonly dialect: SqlDialect,
|
|
21
|
+
private readonly ref: string,
|
|
22
|
+
private readonly searchEnabled: () => boolean,
|
|
23
|
+
) {}
|
|
24
|
+
|
|
25
|
+
#leaf(path: string): QueryLeafOps {
|
|
26
|
+
return BASE_COLUMNS.has(path) ? BASE_COLUMN_LEAF : this.dialect;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
compile(query?: DocumentQuery): CompiledQuery {
|
|
30
|
+
const joins: SearchJoin[] = [];
|
|
31
|
+
if (!query || (typeof query === "object" && !Array.isArray(query) && Object.keys(query).length === 0)) {
|
|
32
|
+
return { where: "1 = 1", params: [], joins };
|
|
33
|
+
}
|
|
34
|
+
const compiled = this.compileNode(query, { joins, conjunctive: true });
|
|
35
|
+
return { where: compiled.sql || "1 = 1", params: compiled.params, joins };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
orderBy(sort: Record<string, 1 | -1> = { createdAt: -1 }) {
|
|
39
|
+
return Object.entries(sort)
|
|
40
|
+
.map(([path, direction]) => `${this.fieldExpr(path)} ${direction === 1 ? "ASC" : "DESC"}`)
|
|
41
|
+
.join(", ");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
fieldExpr(path: string) {
|
|
45
|
+
this.assertPath(path);
|
|
46
|
+
return BASE_COLUMNS.has(path) ? quoteIdent(path) : this.dialect.extract(path);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
projectExpr(path: string) {
|
|
50
|
+
this.assertPath(path);
|
|
51
|
+
return BASE_COLUMNS.has(path) ? quoteIdent(path) : this.dialect.projectExpr(path);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private compileNode(query: DocumentQuery, ctx: CompileContext): { sql: string; params: unknown[] } {
|
|
55
|
+
if (this.isQueryNode(query)) {
|
|
56
|
+
if (query.kind === "search") {
|
|
57
|
+
if (!ctx.conjunctive)
|
|
58
|
+
throw new Error(
|
|
59
|
+
`Text search on "${this.ref}" must sit at an AND position; q.search() cannot be nested under q.any() or q.not().`,
|
|
60
|
+
);
|
|
61
|
+
const join = this.#searchJoin(query, ctx.joins.length);
|
|
62
|
+
if (join) ctx.joins.push(join);
|
|
63
|
+
return { sql: join ? "" : "0 = 1", params: [] };
|
|
64
|
+
}
|
|
65
|
+
if (query.kind === "all" || query.kind === "any") {
|
|
66
|
+
const subCtx = query.kind === "all" ? ctx : { ...ctx, conjunctive: false };
|
|
67
|
+
const parts = query.queries.map((sub) => this.compileNode(sub, subCtx)).filter((part) => part.sql);
|
|
68
|
+
if (!parts.length) return { sql: "1 = 1", params: [] };
|
|
69
|
+
const joiner = query.kind === "all" ? " AND " : " OR ";
|
|
70
|
+
return {
|
|
71
|
+
sql: `(${parts.map((part) => part.sql).join(joiner)})`,
|
|
72
|
+
params: parts.flatMap((part) => part.params),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (query.kind === "not") {
|
|
76
|
+
const part = this.compileNode(query.query, { ...ctx, conjunctive: false });
|
|
77
|
+
return { sql: `NOT (${part.sql})`, params: part.params };
|
|
78
|
+
}
|
|
79
|
+
if (query.kind === "raw") {
|
|
80
|
+
if (/[;]/.test(query.sql)) throw new Error("Raw SQL query fragments must be a single statement fragment");
|
|
81
|
+
return { sql: `(${query.sql})`, params: query.params };
|
|
82
|
+
}
|
|
83
|
+
throw new Error("Operator nodes must be attached to a document path");
|
|
84
|
+
}
|
|
85
|
+
const parts = Object.entries(query).flatMap(([path, value]) => {
|
|
86
|
+
if (value === undefined) throw new Error(`Undefined query value is not allowed: ${path}`);
|
|
87
|
+
return [this.compileField(path, value, ctx)];
|
|
88
|
+
});
|
|
89
|
+
if (!parts.length) return { sql: "1 = 1", params: [] };
|
|
90
|
+
return {
|
|
91
|
+
sql: `(${parts.map((part) => part.sql).join(" AND ")})`,
|
|
92
|
+
params: parts.flatMap((part) => part.params),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
#searchJoin(node: Extract<DocumentQueryNode, { kind: "search" }>, index: number): SearchJoin | null {
|
|
97
|
+
if (!this.searchEnabled())
|
|
98
|
+
throw new Error(
|
|
99
|
+
`Text search on "${this.ref}" is unavailable because the search index is switched off (AKAN_SEARCH_ENABLED).`,
|
|
100
|
+
);
|
|
101
|
+
const columns = node.columns?.filter((column) => searchColumns.includes(column));
|
|
102
|
+
if (node.columns?.length && !columns?.length)
|
|
103
|
+
throw new Error(`Unknown search column on "${this.ref}": ${node.columns.join(", ")}`);
|
|
104
|
+
const match = toMatchExpression(node.text, { prefix: node.prefix, columns });
|
|
105
|
+
|
|
106
|
+
if (!match) return null;
|
|
107
|
+
const weights = node.weights ?? DEFAULT_SEARCH_WEIGHTS;
|
|
108
|
+
|
|
109
|
+
if (weights.length !== searchColumns.length || weights.some((weight) => !Number.isFinite(weight)))
|
|
110
|
+
throw new Error(
|
|
111
|
+
`Search weights on "${this.ref}" must be ${searchColumns.length} finite numbers: ${JSON.stringify(node.weights)}`,
|
|
112
|
+
);
|
|
113
|
+
const alias = `__s${index}`;
|
|
114
|
+
return { alias, ...this.dialect.searchJoin({ alias, ref: this.ref, match, weights }) };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private compileField(path: string, value: unknown, ctx: CompileContext): { sql: string; params: unknown[] } {
|
|
118
|
+
this.assertPath(path);
|
|
119
|
+
const field = this.fields[path]?.getProps?.() ?? this.fields[path];
|
|
120
|
+
const leaf = this.#leaf(path);
|
|
121
|
+
if (this.isQueryNode(value)) {
|
|
122
|
+
if (value.kind !== "op") return this.compileNode({ [path]: value } as DocumentQuery, ctx);
|
|
123
|
+
switch (value.op) {
|
|
124
|
+
case "eq":
|
|
125
|
+
return leaf.eq(path, value.value);
|
|
126
|
+
case "ne":
|
|
127
|
+
return leaf.ne(path, value.value);
|
|
128
|
+
case "oneOf": {
|
|
129
|
+
const values = (value.value as unknown[]) ?? [];
|
|
130
|
+
if (!values.length) return { sql: "0 = 1", params: [] };
|
|
131
|
+
if (field?.isArray) {
|
|
132
|
+
const parts = values.map((item) => leaf.arrayHas(path, item));
|
|
133
|
+
return {
|
|
134
|
+
sql: `(${parts.map((part) => part.sql).join(" OR ")})`,
|
|
135
|
+
params: parts.flatMap((part) => part.params),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
return leaf.inList(path, values);
|
|
139
|
+
}
|
|
140
|
+
case "notOneOf": {
|
|
141
|
+
const values = (value.value as unknown[]) ?? [];
|
|
142
|
+
if (!values.length) return { sql: "1 = 1", params: [] };
|
|
143
|
+
if (field?.isArray) {
|
|
144
|
+
const parts = values.map((item) => leaf.arrayHas(path, item));
|
|
145
|
+
return {
|
|
146
|
+
sql: `NOT (${parts.map((part) => part.sql).join(" OR ")})`,
|
|
147
|
+
params: parts.flatMap((part) => part.params),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return leaf.notInList(path, values);
|
|
151
|
+
}
|
|
152
|
+
case "gt":
|
|
153
|
+
case "gte":
|
|
154
|
+
case "lt":
|
|
155
|
+
case "lte":
|
|
156
|
+
return leaf.compare(path, value.op, value.value);
|
|
157
|
+
case "between": {
|
|
158
|
+
const [from, to] = value.value as [unknown, unknown];
|
|
159
|
+
return leaf.between(path, from, to);
|
|
160
|
+
}
|
|
161
|
+
case "exists":
|
|
162
|
+
return leaf.exists(path);
|
|
163
|
+
case "missing":
|
|
164
|
+
return leaf.missing(path);
|
|
165
|
+
case "empty":
|
|
166
|
+
return leaf.empty(path);
|
|
167
|
+
case "has":
|
|
168
|
+
return leaf.arrayHas(path, value.value);
|
|
169
|
+
case "contains":
|
|
170
|
+
return leaf.contains(path, value.value);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
174
|
+
const operators = value as Record<string, unknown>;
|
|
175
|
+
const keys = Object.keys(operators);
|
|
176
|
+
if (keys.some((key) => QUERY_OPERATOR_KEYS.has(key))) {
|
|
177
|
+
const parts = keys.flatMap((key) => {
|
|
178
|
+
if (!QUERY_OPERATOR_KEYS.has(key)) return [];
|
|
179
|
+
if (key === "exists")
|
|
180
|
+
return [this.compileField(path, { kind: "op", op: operators.exists ? "exists" : "missing" }, ctx)];
|
|
181
|
+
if (key === "missing")
|
|
182
|
+
return [this.compileField(path, { kind: "op", op: operators.missing ? "missing" : "exists" }, ctx)];
|
|
183
|
+
if (key === "empty")
|
|
184
|
+
return [this.compileField(path, { kind: "op", op: operators.empty ? "empty" : "exists" }, ctx)];
|
|
185
|
+
return [this.compileField(path, { kind: "op", op: key as QueryOperatorName, value: operators[key] }, ctx)];
|
|
186
|
+
});
|
|
187
|
+
return {
|
|
188
|
+
sql: `(${parts.map((part) => part.sql).join(" AND ")})`,
|
|
189
|
+
params: parts.flatMap((part) => part.params),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (field?.isArray && !Array.isArray(value)) return leaf.arrayHas(path, value);
|
|
194
|
+
return leaf.eq(path, value);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The root segment only, deliberately.
|
|
199
|
+
*
|
|
200
|
+
* Everything past it reaches the escaped JSON-path literal and nothing else, so a deep typo is a query that
|
|
201
|
+
* matches nothing rather than a query that does something else. Validating it would mean walking the field
|
|
202
|
+
* graph through array indices (`payments.3.name`), array-of-object leaves (`works.tags`) and `Map` keys, which
|
|
203
|
+
* have no fixed path to check against — a validator that guessed there would refuse working queries, which is
|
|
204
|
+
* worse than the silence. Deep paths are written by the model's own filter code, where the first test catches
|
|
205
|
+
* a typo; the root is the one segment a caller can reach.
|
|
206
|
+
*/
|
|
207
|
+
private assertPath(path: string) {
|
|
208
|
+
const root = path.split(".")[0];
|
|
209
|
+
if (BASE_COLUMNS.has(root)) return;
|
|
210
|
+
if (!this.fields[root]) {
|
|
211
|
+
|
|
212
|
+
if (/^\d+$/.test(root))
|
|
213
|
+
throw new Error(
|
|
214
|
+
`Query received an array instead of a query object (field path "${path}"). ` +
|
|
215
|
+
`A query must be a descriptor object; a slice exec must return queryBy...(...), not an executed list.`,
|
|
216
|
+
);
|
|
217
|
+
throw new Error(`Unknown document field path: ${path}`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private isQueryNode(value: unknown): value is DocumentQueryNode {
|
|
222
|
+
return !!value && typeof value === "object" && "kind" in value;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|