@niscorp/vex 0.1.0
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/DESIGN.md +881 -0
- package/DOCS.md +1295 -0
- package/LICENSE +202 -0
- package/README.md +97 -0
- package/dist/adapters/express/index.cjs +1406 -0
- package/dist/adapters/express/index.cjs.map +1 -0
- package/dist/adapters/express/index.d.cts +25 -0
- package/dist/adapters/express/index.d.ts +25 -0
- package/dist/adapters/express/index.js +60 -0
- package/dist/adapters/express/index.js.map +1 -0
- package/dist/adapters/hono/index.cjs +1426 -0
- package/dist/adapters/hono/index.cjs.map +1 -0
- package/dist/adapters/hono/index.d.cts +25 -0
- package/dist/adapters/hono/index.d.ts +25 -0
- package/dist/adapters/hono/index.js +78 -0
- package/dist/adapters/hono/index.js.map +1 -0
- package/dist/adapters/pglite/index.cjs +17 -0
- package/dist/adapters/pglite/index.cjs.map +1 -0
- package/dist/adapters/pglite/index.d.cts +21 -0
- package/dist/adapters/pglite/index.d.ts +21 -0
- package/dist/adapters/pglite/index.js +14 -0
- package/dist/adapters/pglite/index.js.map +1 -0
- package/dist/agent/index.cjs +478 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +29 -0
- package/dist/agent/index.d.ts +29 -0
- package/dist/agent/index.js +313 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/chunk-FPKW4TRX.js +1528 -0
- package/dist/chunk-FPKW4TRX.js.map +1 -0
- package/dist/chunk-HF25Q53I.js +165 -0
- package/dist/chunk-HF25Q53I.js.map +1 -0
- package/dist/handler-Cql8SJ3F.d.cts +133 -0
- package/dist/handler-mICf9ins.d.ts +133 -0
- package/dist/index.cjs +4078 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +199 -0
- package/dist/index.d.ts +199 -0
- package/dist/index.js +2340 -0
- package/dist/index.js.map +1 -0
- package/dist/introspect-D3OaXHBc.d.cts +16 -0
- package/dist/introspect-D3OaXHBc.d.ts +16 -0
- package/dist/types-BRvMB6IM.d.cts +1491 -0
- package/dist/types-BRvMB6IM.d.ts +1491 -0
- package/package.json +125 -0
|
@@ -0,0 +1,1491 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CompiledIr, JsonValue } from '@niscorp/prism';
|
|
3
|
+
import { Sequence } from '@niscorp/strata';
|
|
4
|
+
|
|
5
|
+
type ScopeValues = Record<string, unknown>;
|
|
6
|
+
type ScopeMatchOne = {
|
|
7
|
+
match: string;
|
|
8
|
+
to: string;
|
|
9
|
+
};
|
|
10
|
+
type ScopeMatchAny = {
|
|
11
|
+
match: string;
|
|
12
|
+
in: string;
|
|
13
|
+
};
|
|
14
|
+
type ScopeMatch = ScopeMatchOne | ScopeMatchAny;
|
|
15
|
+
type ScopeSet = {
|
|
16
|
+
set: string;
|
|
17
|
+
to: string;
|
|
18
|
+
};
|
|
19
|
+
type ScopeRule = ScopeMatch | ScopeSet;
|
|
20
|
+
type ScopeEntityRule = {
|
|
21
|
+
public: true;
|
|
22
|
+
} | {
|
|
23
|
+
deny: true;
|
|
24
|
+
} | {
|
|
25
|
+
read?: ScopeMatch[];
|
|
26
|
+
write?: ScopeRule[];
|
|
27
|
+
insert?: ScopeRule[];
|
|
28
|
+
update?: ScopeRule[];
|
|
29
|
+
delete?: ScopeMatch[];
|
|
30
|
+
};
|
|
31
|
+
type ScopePolicy = {
|
|
32
|
+
default: 'allow' | 'deny';
|
|
33
|
+
entities: Record<string, ScopeEntityRule>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
declare const ContextRefSchema: z.ZodObject<{
|
|
37
|
+
$context: z.ZodString;
|
|
38
|
+
}, z.core.$strict>;
|
|
39
|
+
declare const ScopeRefSchema: z.ZodObject<{
|
|
40
|
+
$scope: z.ZodString;
|
|
41
|
+
}, z.core.$strict>;
|
|
42
|
+
declare const FieldOrValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
43
|
+
$context: z.ZodString;
|
|
44
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
45
|
+
$scope: z.ZodString;
|
|
46
|
+
}, z.core.$strict>]>;
|
|
47
|
+
type ContextRef = z.infer<typeof ContextRefSchema>;
|
|
48
|
+
type ScopeRef = z.infer<typeof ScopeRefSchema>;
|
|
49
|
+
type FieldOrValue = z.infer<typeof FieldOrValueSchema>;
|
|
50
|
+
|
|
51
|
+
type ExistsQuery = {
|
|
52
|
+
from: string[];
|
|
53
|
+
filter?: Filter;
|
|
54
|
+
};
|
|
55
|
+
type Filter = {
|
|
56
|
+
exists: ExistsQuery;
|
|
57
|
+
} | {
|
|
58
|
+
eq: [FieldOrValue, FieldOrValue];
|
|
59
|
+
} | {
|
|
60
|
+
neq: [FieldOrValue, FieldOrValue];
|
|
61
|
+
} | {
|
|
62
|
+
gt: [FieldOrValue, FieldOrValue];
|
|
63
|
+
} | {
|
|
64
|
+
gte: [FieldOrValue, FieldOrValue];
|
|
65
|
+
} | {
|
|
66
|
+
lt: [FieldOrValue, FieldOrValue];
|
|
67
|
+
} | {
|
|
68
|
+
lte: [FieldOrValue, FieldOrValue];
|
|
69
|
+
} | {
|
|
70
|
+
in: [string, FieldOrValue[] | ContextRef | ScopeRef];
|
|
71
|
+
} | {
|
|
72
|
+
notIn: [string, FieldOrValue[] | ContextRef | ScopeRef];
|
|
73
|
+
} | {
|
|
74
|
+
like: [string, FieldOrValue];
|
|
75
|
+
} | {
|
|
76
|
+
ilike: [string, FieldOrValue];
|
|
77
|
+
} | {
|
|
78
|
+
isNull: string;
|
|
79
|
+
} | {
|
|
80
|
+
isNotNull: string;
|
|
81
|
+
} | {
|
|
82
|
+
and: Filter[];
|
|
83
|
+
} | {
|
|
84
|
+
or: Filter[];
|
|
85
|
+
} | {
|
|
86
|
+
not: Filter;
|
|
87
|
+
} | {
|
|
88
|
+
semantic: {
|
|
89
|
+
field: string;
|
|
90
|
+
query: ContextRef | ScopeRef;
|
|
91
|
+
minScore?: number;
|
|
92
|
+
};
|
|
93
|
+
} | {
|
|
94
|
+
fuzzy: {
|
|
95
|
+
field: string;
|
|
96
|
+
query: ContextRef | ScopeRef;
|
|
97
|
+
maxDistance?: number;
|
|
98
|
+
};
|
|
99
|
+
} | {
|
|
100
|
+
optional: {
|
|
101
|
+
key: string | string[];
|
|
102
|
+
then: Filter;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
declare const FilterSchema: z.ZodType<Filter>;
|
|
106
|
+
|
|
107
|
+
declare const ComputeExpressionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
108
|
+
add: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
109
|
+
$context: z.ZodString;
|
|
110
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
111
|
+
$scope: z.ZodString;
|
|
112
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
113
|
+
$context: z.ZodString;
|
|
114
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
115
|
+
$scope: z.ZodString;
|
|
116
|
+
}, z.core.$strict>]>], null>;
|
|
117
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
118
|
+
subtract: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
119
|
+
$context: z.ZodString;
|
|
120
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
121
|
+
$scope: z.ZodString;
|
|
122
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
123
|
+
$context: z.ZodString;
|
|
124
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
125
|
+
$scope: z.ZodString;
|
|
126
|
+
}, z.core.$strict>]>], null>;
|
|
127
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
128
|
+
multiply: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
129
|
+
$context: z.ZodString;
|
|
130
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
131
|
+
$scope: z.ZodString;
|
|
132
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
133
|
+
$context: z.ZodString;
|
|
134
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
135
|
+
$scope: z.ZodString;
|
|
136
|
+
}, z.core.$strict>]>], null>;
|
|
137
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
138
|
+
divide: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
139
|
+
$context: z.ZodString;
|
|
140
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
141
|
+
$scope: z.ZodString;
|
|
142
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
143
|
+
$context: z.ZodString;
|
|
144
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
145
|
+
$scope: z.ZodString;
|
|
146
|
+
}, z.core.$strict>]>], null>;
|
|
147
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
148
|
+
concat: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
149
|
+
$context: z.ZodString;
|
|
150
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
151
|
+
$scope: z.ZodString;
|
|
152
|
+
}, z.core.$strict>]>>;
|
|
153
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
154
|
+
coalesce: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
155
|
+
$context: z.ZodString;
|
|
156
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
157
|
+
$scope: z.ZodString;
|
|
158
|
+
}, z.core.$strict>]>>;
|
|
159
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
160
|
+
case: z.ZodObject<{
|
|
161
|
+
when: z.ZodArray<z.ZodObject<{
|
|
162
|
+
condition: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
163
|
+
then: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
164
|
+
$context: z.ZodString;
|
|
165
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
166
|
+
$scope: z.ZodString;
|
|
167
|
+
}, z.core.$strict>]>;
|
|
168
|
+
}, z.core.$strict>>;
|
|
169
|
+
else: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
170
|
+
$context: z.ZodString;
|
|
171
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
172
|
+
$scope: z.ZodString;
|
|
173
|
+
}, z.core.$strict>]>;
|
|
174
|
+
}, z.core.$strict>;
|
|
175
|
+
}, z.core.$strict>]>;
|
|
176
|
+
type ComputeExpression = z.infer<typeof ComputeExpressionSchema>;
|
|
177
|
+
|
|
178
|
+
declare const AggregateExpressionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
179
|
+
count: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"*">]>;
|
|
180
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
181
|
+
countDistinct: z.ZodString;
|
|
182
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
183
|
+
sum: z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
184
|
+
add: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
185
|
+
$context: z.ZodString;
|
|
186
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
187
|
+
$scope: z.ZodString;
|
|
188
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
189
|
+
$context: z.ZodString;
|
|
190
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
191
|
+
$scope: z.ZodString;
|
|
192
|
+
}, z.core.$strict>]>], null>;
|
|
193
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
194
|
+
subtract: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
195
|
+
$context: z.ZodString;
|
|
196
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
197
|
+
$scope: z.ZodString;
|
|
198
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
199
|
+
$context: z.ZodString;
|
|
200
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
201
|
+
$scope: z.ZodString;
|
|
202
|
+
}, z.core.$strict>]>], null>;
|
|
203
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
204
|
+
multiply: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
205
|
+
$context: z.ZodString;
|
|
206
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
207
|
+
$scope: z.ZodString;
|
|
208
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
209
|
+
$context: z.ZodString;
|
|
210
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
211
|
+
$scope: z.ZodString;
|
|
212
|
+
}, z.core.$strict>]>], null>;
|
|
213
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
214
|
+
divide: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
215
|
+
$context: z.ZodString;
|
|
216
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
217
|
+
$scope: z.ZodString;
|
|
218
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
219
|
+
$context: z.ZodString;
|
|
220
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
221
|
+
$scope: z.ZodString;
|
|
222
|
+
}, z.core.$strict>]>], null>;
|
|
223
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
224
|
+
concat: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
225
|
+
$context: z.ZodString;
|
|
226
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
227
|
+
$scope: z.ZodString;
|
|
228
|
+
}, z.core.$strict>]>>;
|
|
229
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
230
|
+
coalesce: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
231
|
+
$context: z.ZodString;
|
|
232
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
233
|
+
$scope: z.ZodString;
|
|
234
|
+
}, z.core.$strict>]>>;
|
|
235
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
236
|
+
case: z.ZodObject<{
|
|
237
|
+
when: z.ZodArray<z.ZodObject<{
|
|
238
|
+
condition: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
239
|
+
then: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
240
|
+
$context: z.ZodString;
|
|
241
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
242
|
+
$scope: z.ZodString;
|
|
243
|
+
}, z.core.$strict>]>;
|
|
244
|
+
}, z.core.$strict>>;
|
|
245
|
+
else: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
246
|
+
$context: z.ZodString;
|
|
247
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
248
|
+
$scope: z.ZodString;
|
|
249
|
+
}, z.core.$strict>]>;
|
|
250
|
+
}, z.core.$strict>;
|
|
251
|
+
}, z.core.$strict>]>]>;
|
|
252
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
253
|
+
avg: z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
254
|
+
add: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
255
|
+
$context: z.ZodString;
|
|
256
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
257
|
+
$scope: z.ZodString;
|
|
258
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
259
|
+
$context: z.ZodString;
|
|
260
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
261
|
+
$scope: z.ZodString;
|
|
262
|
+
}, z.core.$strict>]>], null>;
|
|
263
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
264
|
+
subtract: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
265
|
+
$context: z.ZodString;
|
|
266
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
267
|
+
$scope: z.ZodString;
|
|
268
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
269
|
+
$context: z.ZodString;
|
|
270
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
271
|
+
$scope: z.ZodString;
|
|
272
|
+
}, z.core.$strict>]>], null>;
|
|
273
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
274
|
+
multiply: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
275
|
+
$context: z.ZodString;
|
|
276
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
277
|
+
$scope: z.ZodString;
|
|
278
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
279
|
+
$context: z.ZodString;
|
|
280
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
281
|
+
$scope: z.ZodString;
|
|
282
|
+
}, z.core.$strict>]>], null>;
|
|
283
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
284
|
+
divide: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
285
|
+
$context: z.ZodString;
|
|
286
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
287
|
+
$scope: z.ZodString;
|
|
288
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
289
|
+
$context: z.ZodString;
|
|
290
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
291
|
+
$scope: z.ZodString;
|
|
292
|
+
}, z.core.$strict>]>], null>;
|
|
293
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
294
|
+
concat: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
295
|
+
$context: z.ZodString;
|
|
296
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
297
|
+
$scope: z.ZodString;
|
|
298
|
+
}, z.core.$strict>]>>;
|
|
299
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
300
|
+
coalesce: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
301
|
+
$context: z.ZodString;
|
|
302
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
303
|
+
$scope: z.ZodString;
|
|
304
|
+
}, z.core.$strict>]>>;
|
|
305
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
306
|
+
case: z.ZodObject<{
|
|
307
|
+
when: z.ZodArray<z.ZodObject<{
|
|
308
|
+
condition: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
309
|
+
then: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
310
|
+
$context: z.ZodString;
|
|
311
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
312
|
+
$scope: z.ZodString;
|
|
313
|
+
}, z.core.$strict>]>;
|
|
314
|
+
}, z.core.$strict>>;
|
|
315
|
+
else: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
316
|
+
$context: z.ZodString;
|
|
317
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
318
|
+
$scope: z.ZodString;
|
|
319
|
+
}, z.core.$strict>]>;
|
|
320
|
+
}, z.core.$strict>;
|
|
321
|
+
}, z.core.$strict>]>]>;
|
|
322
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
323
|
+
min: z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
324
|
+
add: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
325
|
+
$context: z.ZodString;
|
|
326
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
327
|
+
$scope: z.ZodString;
|
|
328
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
329
|
+
$context: z.ZodString;
|
|
330
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
331
|
+
$scope: z.ZodString;
|
|
332
|
+
}, z.core.$strict>]>], null>;
|
|
333
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
334
|
+
subtract: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
335
|
+
$context: z.ZodString;
|
|
336
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
337
|
+
$scope: z.ZodString;
|
|
338
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
339
|
+
$context: z.ZodString;
|
|
340
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
341
|
+
$scope: z.ZodString;
|
|
342
|
+
}, z.core.$strict>]>], null>;
|
|
343
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
344
|
+
multiply: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
345
|
+
$context: z.ZodString;
|
|
346
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
347
|
+
$scope: z.ZodString;
|
|
348
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
349
|
+
$context: z.ZodString;
|
|
350
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
351
|
+
$scope: z.ZodString;
|
|
352
|
+
}, z.core.$strict>]>], null>;
|
|
353
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
354
|
+
divide: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
355
|
+
$context: z.ZodString;
|
|
356
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
357
|
+
$scope: z.ZodString;
|
|
358
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
359
|
+
$context: z.ZodString;
|
|
360
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
361
|
+
$scope: z.ZodString;
|
|
362
|
+
}, z.core.$strict>]>], null>;
|
|
363
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
364
|
+
concat: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
365
|
+
$context: z.ZodString;
|
|
366
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
367
|
+
$scope: z.ZodString;
|
|
368
|
+
}, z.core.$strict>]>>;
|
|
369
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
370
|
+
coalesce: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
371
|
+
$context: z.ZodString;
|
|
372
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
373
|
+
$scope: z.ZodString;
|
|
374
|
+
}, z.core.$strict>]>>;
|
|
375
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
376
|
+
case: z.ZodObject<{
|
|
377
|
+
when: z.ZodArray<z.ZodObject<{
|
|
378
|
+
condition: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
379
|
+
then: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
380
|
+
$context: z.ZodString;
|
|
381
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
382
|
+
$scope: z.ZodString;
|
|
383
|
+
}, z.core.$strict>]>;
|
|
384
|
+
}, z.core.$strict>>;
|
|
385
|
+
else: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
386
|
+
$context: z.ZodString;
|
|
387
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
388
|
+
$scope: z.ZodString;
|
|
389
|
+
}, z.core.$strict>]>;
|
|
390
|
+
}, z.core.$strict>;
|
|
391
|
+
}, z.core.$strict>]>]>;
|
|
392
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
393
|
+
max: z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
394
|
+
add: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
395
|
+
$context: z.ZodString;
|
|
396
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
397
|
+
$scope: z.ZodString;
|
|
398
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
399
|
+
$context: z.ZodString;
|
|
400
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
401
|
+
$scope: z.ZodString;
|
|
402
|
+
}, z.core.$strict>]>], null>;
|
|
403
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
404
|
+
subtract: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
405
|
+
$context: z.ZodString;
|
|
406
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
407
|
+
$scope: z.ZodString;
|
|
408
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
409
|
+
$context: z.ZodString;
|
|
410
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
411
|
+
$scope: z.ZodString;
|
|
412
|
+
}, z.core.$strict>]>], null>;
|
|
413
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
414
|
+
multiply: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
415
|
+
$context: z.ZodString;
|
|
416
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
417
|
+
$scope: z.ZodString;
|
|
418
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
419
|
+
$context: z.ZodString;
|
|
420
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
421
|
+
$scope: z.ZodString;
|
|
422
|
+
}, z.core.$strict>]>], null>;
|
|
423
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
424
|
+
divide: z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
425
|
+
$context: z.ZodString;
|
|
426
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
427
|
+
$scope: z.ZodString;
|
|
428
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
429
|
+
$context: z.ZodString;
|
|
430
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
431
|
+
$scope: z.ZodString;
|
|
432
|
+
}, z.core.$strict>]>], null>;
|
|
433
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
434
|
+
concat: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
435
|
+
$context: z.ZodString;
|
|
436
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
437
|
+
$scope: z.ZodString;
|
|
438
|
+
}, z.core.$strict>]>>;
|
|
439
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
440
|
+
coalesce: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
441
|
+
$context: z.ZodString;
|
|
442
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
443
|
+
$scope: z.ZodString;
|
|
444
|
+
}, z.core.$strict>]>>;
|
|
445
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
446
|
+
case: z.ZodObject<{
|
|
447
|
+
when: z.ZodArray<z.ZodObject<{
|
|
448
|
+
condition: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
449
|
+
then: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
450
|
+
$context: z.ZodString;
|
|
451
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
452
|
+
$scope: z.ZodString;
|
|
453
|
+
}, z.core.$strict>]>;
|
|
454
|
+
}, z.core.$strict>>;
|
|
455
|
+
else: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
456
|
+
$context: z.ZodString;
|
|
457
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
458
|
+
$scope: z.ZodString;
|
|
459
|
+
}, z.core.$strict>]>;
|
|
460
|
+
}, z.core.$strict>;
|
|
461
|
+
}, z.core.$strict>]>]>;
|
|
462
|
+
}, z.core.$strict>]>;
|
|
463
|
+
type AggregateExpression = z.infer<typeof AggregateExpressionSchema>;
|
|
464
|
+
|
|
465
|
+
declare const SortEntrySchema: z.ZodObject<{
|
|
466
|
+
field: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
467
|
+
dir: z.ZodDefault<z.ZodEnum<{
|
|
468
|
+
asc: "asc";
|
|
469
|
+
desc: "desc";
|
|
470
|
+
}>>;
|
|
471
|
+
}, z.core.$strict>;
|
|
472
|
+
type SortEntry = z.infer<typeof SortEntrySchema>;
|
|
473
|
+
type Source = string | {
|
|
474
|
+
as: string;
|
|
475
|
+
query: Query;
|
|
476
|
+
};
|
|
477
|
+
type FieldRef = string | {
|
|
478
|
+
field: string;
|
|
479
|
+
as: string;
|
|
480
|
+
};
|
|
481
|
+
type Query = {
|
|
482
|
+
from: Source[];
|
|
483
|
+
fields?: FieldRef[];
|
|
484
|
+
filter?: Filter;
|
|
485
|
+
compute?: Record<string, ComputeExpression>;
|
|
486
|
+
aggregate?: Record<string, AggregateExpression>;
|
|
487
|
+
groupBy?: string[];
|
|
488
|
+
sort?: SortEntry[];
|
|
489
|
+
limit?: number;
|
|
490
|
+
distinct?: boolean;
|
|
491
|
+
};
|
|
492
|
+
declare const QuerySchema: z.ZodType<Query>;
|
|
493
|
+
|
|
494
|
+
declare const MutationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
495
|
+
op: z.ZodLiteral<"insert">;
|
|
496
|
+
table: z.ZodString;
|
|
497
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
498
|
+
$context: z.ZodString;
|
|
499
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
500
|
+
$lookup: z.ZodObject<{
|
|
501
|
+
from: z.ZodString;
|
|
502
|
+
field: z.ZodString;
|
|
503
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
504
|
+
}, z.core.$strict>;
|
|
505
|
+
}, z.core.$strict>]>>;
|
|
506
|
+
onConflict: z.ZodOptional<z.ZodObject<{
|
|
507
|
+
target: z.ZodArray<z.ZodString>;
|
|
508
|
+
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
509
|
+
$context: z.ZodString;
|
|
510
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
511
|
+
$lookup: z.ZodObject<{
|
|
512
|
+
from: z.ZodString;
|
|
513
|
+
field: z.ZodString;
|
|
514
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
515
|
+
}, z.core.$strict>;
|
|
516
|
+
}, z.core.$strict>]>>>;
|
|
517
|
+
}, z.core.$strict>>;
|
|
518
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
519
|
+
op: z.ZodLiteral<"insertEach">;
|
|
520
|
+
table: z.ZodString;
|
|
521
|
+
items: z.ZodObject<{
|
|
522
|
+
$context: z.ZodString;
|
|
523
|
+
}, z.core.$strict>;
|
|
524
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
525
|
+
$context: z.ZodString;
|
|
526
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
527
|
+
$lookup: z.ZodObject<{
|
|
528
|
+
from: z.ZodString;
|
|
529
|
+
field: z.ZodString;
|
|
530
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
531
|
+
}, z.core.$strict>;
|
|
532
|
+
}, z.core.$strict>]>, z.ZodObject<{
|
|
533
|
+
$item: z.ZodString;
|
|
534
|
+
}, z.core.$strict>]>>;
|
|
535
|
+
onConflict: z.ZodOptional<z.ZodObject<{
|
|
536
|
+
target: z.ZodArray<z.ZodString>;
|
|
537
|
+
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
538
|
+
$context: z.ZodString;
|
|
539
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
540
|
+
$lookup: z.ZodObject<{
|
|
541
|
+
from: z.ZodString;
|
|
542
|
+
field: z.ZodString;
|
|
543
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
544
|
+
}, z.core.$strict>;
|
|
545
|
+
}, z.core.$strict>]>>>;
|
|
546
|
+
}, z.core.$strict>>;
|
|
547
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
548
|
+
op: z.ZodLiteral<"update">;
|
|
549
|
+
table: z.ZodString;
|
|
550
|
+
set: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
551
|
+
$context: z.ZodString;
|
|
552
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
553
|
+
$lookup: z.ZodObject<{
|
|
554
|
+
from: z.ZodString;
|
|
555
|
+
field: z.ZodString;
|
|
556
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
557
|
+
}, z.core.$strict>;
|
|
558
|
+
}, z.core.$strict>]>>;
|
|
559
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
560
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
561
|
+
op: z.ZodLiteral<"delete">;
|
|
562
|
+
table: z.ZodString;
|
|
563
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
564
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
565
|
+
op: z.ZodLiteral<"upsert">;
|
|
566
|
+
table: z.ZodString;
|
|
567
|
+
columns: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
568
|
+
$context: z.ZodString;
|
|
569
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
570
|
+
$lookup: z.ZodObject<{
|
|
571
|
+
from: z.ZodString;
|
|
572
|
+
field: z.ZodString;
|
|
573
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
574
|
+
}, z.core.$strict>;
|
|
575
|
+
}, z.core.$strict>]>>;
|
|
576
|
+
insert: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
577
|
+
$context: z.ZodString;
|
|
578
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
579
|
+
$lookup: z.ZodObject<{
|
|
580
|
+
from: z.ZodString;
|
|
581
|
+
field: z.ZodString;
|
|
582
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
583
|
+
}, z.core.$strict>;
|
|
584
|
+
}, z.core.$strict>]>>>;
|
|
585
|
+
key: z.ZodString;
|
|
586
|
+
}, z.core.$strict>], "op">;
|
|
587
|
+
type Mutation = z.infer<typeof MutationSchema>;
|
|
588
|
+
type CoreMutation = Exclude<Mutation, {
|
|
589
|
+
op: 'upsert';
|
|
590
|
+
}>;
|
|
591
|
+
declare const MutationDefinitionSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
592
|
+
op: z.ZodLiteral<"insert">;
|
|
593
|
+
table: z.ZodString;
|
|
594
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
595
|
+
$context: z.ZodString;
|
|
596
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
597
|
+
$lookup: z.ZodObject<{
|
|
598
|
+
from: z.ZodString;
|
|
599
|
+
field: z.ZodString;
|
|
600
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
601
|
+
}, z.core.$strict>;
|
|
602
|
+
}, z.core.$strict>]>>;
|
|
603
|
+
onConflict: z.ZodOptional<z.ZodObject<{
|
|
604
|
+
target: z.ZodArray<z.ZodString>;
|
|
605
|
+
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
606
|
+
$context: z.ZodString;
|
|
607
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
608
|
+
$lookup: z.ZodObject<{
|
|
609
|
+
from: z.ZodString;
|
|
610
|
+
field: z.ZodString;
|
|
611
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
612
|
+
}, z.core.$strict>;
|
|
613
|
+
}, z.core.$strict>]>>>;
|
|
614
|
+
}, z.core.$strict>>;
|
|
615
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
616
|
+
op: z.ZodLiteral<"insertEach">;
|
|
617
|
+
table: z.ZodString;
|
|
618
|
+
items: z.ZodObject<{
|
|
619
|
+
$context: z.ZodString;
|
|
620
|
+
}, z.core.$strict>;
|
|
621
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
622
|
+
$context: z.ZodString;
|
|
623
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
624
|
+
$lookup: z.ZodObject<{
|
|
625
|
+
from: z.ZodString;
|
|
626
|
+
field: z.ZodString;
|
|
627
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
628
|
+
}, z.core.$strict>;
|
|
629
|
+
}, z.core.$strict>]>, z.ZodObject<{
|
|
630
|
+
$item: z.ZodString;
|
|
631
|
+
}, z.core.$strict>]>>;
|
|
632
|
+
onConflict: z.ZodOptional<z.ZodObject<{
|
|
633
|
+
target: z.ZodArray<z.ZodString>;
|
|
634
|
+
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
635
|
+
$context: z.ZodString;
|
|
636
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
637
|
+
$lookup: z.ZodObject<{
|
|
638
|
+
from: z.ZodString;
|
|
639
|
+
field: z.ZodString;
|
|
640
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
641
|
+
}, z.core.$strict>;
|
|
642
|
+
}, z.core.$strict>]>>>;
|
|
643
|
+
}, z.core.$strict>>;
|
|
644
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
645
|
+
op: z.ZodLiteral<"update">;
|
|
646
|
+
table: z.ZodString;
|
|
647
|
+
set: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
648
|
+
$context: z.ZodString;
|
|
649
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
650
|
+
$lookup: z.ZodObject<{
|
|
651
|
+
from: z.ZodString;
|
|
652
|
+
field: z.ZodString;
|
|
653
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
654
|
+
}, z.core.$strict>;
|
|
655
|
+
}, z.core.$strict>]>>;
|
|
656
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
657
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
658
|
+
op: z.ZodLiteral<"delete">;
|
|
659
|
+
table: z.ZodString;
|
|
660
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
661
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
662
|
+
op: z.ZodLiteral<"upsert">;
|
|
663
|
+
table: z.ZodString;
|
|
664
|
+
columns: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
665
|
+
$context: z.ZodString;
|
|
666
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
667
|
+
$lookup: z.ZodObject<{
|
|
668
|
+
from: z.ZodString;
|
|
669
|
+
field: z.ZodString;
|
|
670
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
671
|
+
}, z.core.$strict>;
|
|
672
|
+
}, z.core.$strict>]>>;
|
|
673
|
+
insert: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
674
|
+
$context: z.ZodString;
|
|
675
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
676
|
+
$lookup: z.ZodObject<{
|
|
677
|
+
from: z.ZodString;
|
|
678
|
+
field: z.ZodString;
|
|
679
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
680
|
+
}, z.core.$strict>;
|
|
681
|
+
}, z.core.$strict>]>>>;
|
|
682
|
+
key: z.ZodString;
|
|
683
|
+
}, z.core.$strict>], "op">, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
684
|
+
op: z.ZodLiteral<"insert">;
|
|
685
|
+
table: z.ZodString;
|
|
686
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
687
|
+
$context: z.ZodString;
|
|
688
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
689
|
+
$lookup: z.ZodObject<{
|
|
690
|
+
from: z.ZodString;
|
|
691
|
+
field: z.ZodString;
|
|
692
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
693
|
+
}, z.core.$strict>;
|
|
694
|
+
}, z.core.$strict>]>>;
|
|
695
|
+
onConflict: z.ZodOptional<z.ZodObject<{
|
|
696
|
+
target: z.ZodArray<z.ZodString>;
|
|
697
|
+
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
698
|
+
$context: z.ZodString;
|
|
699
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
700
|
+
$lookup: z.ZodObject<{
|
|
701
|
+
from: z.ZodString;
|
|
702
|
+
field: z.ZodString;
|
|
703
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
704
|
+
}, z.core.$strict>;
|
|
705
|
+
}, z.core.$strict>]>>>;
|
|
706
|
+
}, z.core.$strict>>;
|
|
707
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
708
|
+
op: z.ZodLiteral<"insertEach">;
|
|
709
|
+
table: z.ZodString;
|
|
710
|
+
items: z.ZodObject<{
|
|
711
|
+
$context: z.ZodString;
|
|
712
|
+
}, z.core.$strict>;
|
|
713
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
714
|
+
$context: z.ZodString;
|
|
715
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
716
|
+
$lookup: z.ZodObject<{
|
|
717
|
+
from: z.ZodString;
|
|
718
|
+
field: z.ZodString;
|
|
719
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
720
|
+
}, z.core.$strict>;
|
|
721
|
+
}, z.core.$strict>]>, z.ZodObject<{
|
|
722
|
+
$item: z.ZodString;
|
|
723
|
+
}, z.core.$strict>]>>;
|
|
724
|
+
onConflict: z.ZodOptional<z.ZodObject<{
|
|
725
|
+
target: z.ZodArray<z.ZodString>;
|
|
726
|
+
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
727
|
+
$context: z.ZodString;
|
|
728
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
729
|
+
$lookup: z.ZodObject<{
|
|
730
|
+
from: z.ZodString;
|
|
731
|
+
field: z.ZodString;
|
|
732
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
733
|
+
}, z.core.$strict>;
|
|
734
|
+
}, z.core.$strict>]>>>;
|
|
735
|
+
}, z.core.$strict>>;
|
|
736
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
737
|
+
op: z.ZodLiteral<"update">;
|
|
738
|
+
table: z.ZodString;
|
|
739
|
+
set: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
740
|
+
$context: z.ZodString;
|
|
741
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
742
|
+
$lookup: z.ZodObject<{
|
|
743
|
+
from: z.ZodString;
|
|
744
|
+
field: z.ZodString;
|
|
745
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
746
|
+
}, z.core.$strict>;
|
|
747
|
+
}, z.core.$strict>]>>;
|
|
748
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
749
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
750
|
+
op: z.ZodLiteral<"delete">;
|
|
751
|
+
table: z.ZodString;
|
|
752
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
753
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
754
|
+
op: z.ZodLiteral<"upsert">;
|
|
755
|
+
table: z.ZodString;
|
|
756
|
+
columns: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
757
|
+
$context: z.ZodString;
|
|
758
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
759
|
+
$lookup: z.ZodObject<{
|
|
760
|
+
from: z.ZodString;
|
|
761
|
+
field: z.ZodString;
|
|
762
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
763
|
+
}, z.core.$strict>;
|
|
764
|
+
}, z.core.$strict>]>>;
|
|
765
|
+
insert: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodObject<{
|
|
766
|
+
$context: z.ZodString;
|
|
767
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
768
|
+
$lookup: z.ZodObject<{
|
|
769
|
+
from: z.ZodString;
|
|
770
|
+
field: z.ZodString;
|
|
771
|
+
where: z.ZodType<Filter, unknown, z.core.$ZodTypeInternals<Filter, unknown>>;
|
|
772
|
+
}, z.core.$strict>;
|
|
773
|
+
}, z.core.$strict>]>>>;
|
|
774
|
+
key: z.ZodString;
|
|
775
|
+
}, z.core.$strict>], "op">>]>;
|
|
776
|
+
type MutationDefinition = z.infer<typeof MutationDefinitionSchema>;
|
|
777
|
+
type LookupValue = {
|
|
778
|
+
$lookup: {
|
|
779
|
+
from: string;
|
|
780
|
+
field: string;
|
|
781
|
+
where: Filter;
|
|
782
|
+
};
|
|
783
|
+
};
|
|
784
|
+
type ItemRef = {
|
|
785
|
+
$item: string;
|
|
786
|
+
};
|
|
787
|
+
type MutationValue = FieldOrValue | LookupValue;
|
|
788
|
+
type ResolvedOnConflict = {
|
|
789
|
+
target: string[];
|
|
790
|
+
set?: Record<string, MutationValue>;
|
|
791
|
+
where?: Filter;
|
|
792
|
+
};
|
|
793
|
+
type ResolvedMutation = {
|
|
794
|
+
op: 'insert';
|
|
795
|
+
table: string;
|
|
796
|
+
values: Record<string, MutationValue>;
|
|
797
|
+
onConflict?: ResolvedOnConflict;
|
|
798
|
+
} | {
|
|
799
|
+
op: 'insertEach';
|
|
800
|
+
table: string;
|
|
801
|
+
items: {
|
|
802
|
+
$context: string;
|
|
803
|
+
};
|
|
804
|
+
values: Record<string, MutationValue | ItemRef>;
|
|
805
|
+
onConflict?: ResolvedOnConflict;
|
|
806
|
+
} | {
|
|
807
|
+
op: 'update';
|
|
808
|
+
table: string;
|
|
809
|
+
set: Record<string, MutationValue>;
|
|
810
|
+
where: Filter;
|
|
811
|
+
} | {
|
|
812
|
+
op: 'delete';
|
|
813
|
+
table: string;
|
|
814
|
+
where: Filter;
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
declare const REFRESH_MODES: readonly ["snapshot", "reactive"];
|
|
818
|
+
type Refresh = (typeof REFRESH_MODES)[number];
|
|
819
|
+
declare const isRefresh: (value: unknown) => value is Refresh;
|
|
820
|
+
type CacheEntryMeta = {
|
|
821
|
+
createdAt: number;
|
|
822
|
+
/**
|
|
823
|
+
* Touch-on-read timestamp. Lifetime is usage: a GC sweep evicts
|
|
824
|
+
* entries unused for a configured window; protected entries never
|
|
825
|
+
* sweep. Replaces the provisional/permanent distinction entirely.
|
|
826
|
+
*/
|
|
827
|
+
lastUsedAt?: number;
|
|
828
|
+
expiresAt?: number;
|
|
829
|
+
/**
|
|
830
|
+
* Protected entries refuse replacement: a fingerprint request whose
|
|
831
|
+
* intent/shape differ from the stored ones errors instead of
|
|
832
|
+
* regenerating. Written ONLY by the seed path and an explicit PATCH —
|
|
833
|
+
* never by query execution.
|
|
834
|
+
*/
|
|
835
|
+
protected?: boolean;
|
|
836
|
+
/**
|
|
837
|
+
* Identity of the request that produced this entry (intent + normalized
|
|
838
|
+
* shape + context key names). A fingerprint request with a matching
|
|
839
|
+
* hash is a hit; a differing one regenerates (or 409s when protected).
|
|
840
|
+
*/
|
|
841
|
+
requestHash?: string;
|
|
842
|
+
/**
|
|
843
|
+
* Fingerprint of the database schema at write time. When it no longer
|
|
844
|
+
* matches the current schema, the entry is stale (its DSL may
|
|
845
|
+
* reference columns that have since changed) and is treated as a miss.
|
|
846
|
+
*/
|
|
847
|
+
schemaFingerprint?: string;
|
|
848
|
+
/**
|
|
849
|
+
* The originating request's intent and shape — descriptive metadata
|
|
850
|
+
* for inspection and the GET overview. Never part of identity.
|
|
851
|
+
*/
|
|
852
|
+
intent?: string;
|
|
853
|
+
shape?: unknown;
|
|
854
|
+
};
|
|
855
|
+
type OkCacheEntry = CacheEntryMeta & {
|
|
856
|
+
kind: 'ok';
|
|
857
|
+
dsl: Query;
|
|
858
|
+
prismIr?: CompiledIr;
|
|
859
|
+
/**
|
|
860
|
+
* THE REACH THIS READ REQUIRES, whatever the caller's roles say.
|
|
861
|
+
*
|
|
862
|
+
* Reach is normally the caller's: a scope profile named by their role, applied
|
|
863
|
+
* to every table they touch. That is right for a read whose answer legitimately
|
|
864
|
+
* widens with the reader — a roster, a schedule, a members list.
|
|
865
|
+
*
|
|
866
|
+
* It is wrong for a read that means "mine". A principal may hold several roles
|
|
867
|
+
* and the compiled policies merge to the WIDEST reach any of them grants, so an
|
|
868
|
+
* instructor who also trains at the studio reads `bookings` studio-wide — and
|
|
869
|
+
* "the classes you have booked" then answers with the whole studio's.
|
|
870
|
+
*
|
|
871
|
+
* An entry naming a reach is served at that profile instead, with the caller's
|
|
872
|
+
* own grants unchanged. It can only narrow: a read the caller holds no verb for
|
|
873
|
+
* is still refused. If the profile cannot be compiled, the read is refused
|
|
874
|
+
* rather than served wide.
|
|
875
|
+
*/
|
|
876
|
+
reach?: string;
|
|
877
|
+
/** When this read's answer is refreshed. Absent means 'snapshot'. */
|
|
878
|
+
refresh?: Refresh;
|
|
879
|
+
};
|
|
880
|
+
type UnsatisfiableCacheEntry = CacheEntryMeta & {
|
|
881
|
+
kind: 'unsatisfiable';
|
|
882
|
+
reason: string;
|
|
883
|
+
};
|
|
884
|
+
type MutationCacheEntry = CacheEntryMeta & {
|
|
885
|
+
kind: 'mutation';
|
|
886
|
+
mutation: MutationDefinition;
|
|
887
|
+
/**
|
|
888
|
+
* THE REACH THIS WRITE REQUIRES — the same word reads use, and it belongs
|
|
889
|
+
* here for a sharper reason.
|
|
890
|
+
*
|
|
891
|
+
* A read served too wide shows somebody too much. A write served too wide
|
|
892
|
+
* CHANGES somebody else's row: `me/cancel` is "cancel MY booking", and its
|
|
893
|
+
* whole safety is that the policy's update rules pin the row to the caller.
|
|
894
|
+
* Take a principal who holds two roles and the merge widens those rules to
|
|
895
|
+
* the broadest either grants — so the same fingerprint, replayed by somebody
|
|
896
|
+
* who is a member AND something else, could reach a booking that is not
|
|
897
|
+
* theirs.
|
|
898
|
+
*
|
|
899
|
+
* Declaring it here means the write is compiled at that profile whoever asks.
|
|
900
|
+
*/
|
|
901
|
+
reach?: string;
|
|
902
|
+
};
|
|
903
|
+
type CacheEntry = OkCacheEntry | UnsatisfiableCacheEntry | MutationCacheEntry;
|
|
904
|
+
type CacheBackend = {
|
|
905
|
+
get: (key: string) => Promise<CacheEntry | undefined>;
|
|
906
|
+
set: (key: string, entry: CacheEntry) => Promise<void>;
|
|
907
|
+
delete: (key: string) => Promise<void>;
|
|
908
|
+
clear: () => Promise<void>;
|
|
909
|
+
keys: () => Promise<string[]>;
|
|
910
|
+
init?: () => Promise<void>;
|
|
911
|
+
sequence?: Sequence;
|
|
912
|
+
entries?: () => Promise<Array<{
|
|
913
|
+
key: string;
|
|
914
|
+
entry: CacheEntry;
|
|
915
|
+
}>>;
|
|
916
|
+
};
|
|
917
|
+
|
|
918
|
+
declare const NormalizedTypeSchema: z.ZodEnum<{
|
|
919
|
+
string: "string";
|
|
920
|
+
number: "number";
|
|
921
|
+
boolean: "boolean";
|
|
922
|
+
unknown: "unknown";
|
|
923
|
+
date: "date";
|
|
924
|
+
array: "array";
|
|
925
|
+
timestamp: "timestamp";
|
|
926
|
+
uuid: "uuid";
|
|
927
|
+
json: "json";
|
|
928
|
+
vector: "vector";
|
|
929
|
+
}>;
|
|
930
|
+
declare const FieldSchemaSchema: z.ZodObject<{
|
|
931
|
+
name: z.ZodString;
|
|
932
|
+
type: z.ZodString;
|
|
933
|
+
normalizedType: z.ZodEnum<{
|
|
934
|
+
string: "string";
|
|
935
|
+
number: "number";
|
|
936
|
+
boolean: "boolean";
|
|
937
|
+
unknown: "unknown";
|
|
938
|
+
date: "date";
|
|
939
|
+
array: "array";
|
|
940
|
+
timestamp: "timestamp";
|
|
941
|
+
uuid: "uuid";
|
|
942
|
+
json: "json";
|
|
943
|
+
vector: "vector";
|
|
944
|
+
}>;
|
|
945
|
+
nullable: z.ZodBoolean;
|
|
946
|
+
primaryKey: z.ZodBoolean;
|
|
947
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
948
|
+
description: z.ZodOptional<z.ZodString>;
|
|
949
|
+
vectorDimensions: z.ZodOptional<z.ZodNumber>;
|
|
950
|
+
}, z.core.$strip>;
|
|
951
|
+
declare const RelationSchemaSchema: z.ZodObject<{
|
|
952
|
+
type: z.ZodEnum<{
|
|
953
|
+
hasOne: "hasOne";
|
|
954
|
+
hasMany: "hasMany";
|
|
955
|
+
belongsTo: "belongsTo";
|
|
956
|
+
}>;
|
|
957
|
+
entity: z.ZodString;
|
|
958
|
+
localFields: z.ZodArray<z.ZodString>;
|
|
959
|
+
foreignFields: z.ZodArray<z.ZodString>;
|
|
960
|
+
}, z.core.$strip>;
|
|
961
|
+
declare const IndexSchemaSchema: z.ZodObject<{
|
|
962
|
+
name: z.ZodString;
|
|
963
|
+
fields: z.ZodArray<z.ZodString>;
|
|
964
|
+
unique: z.ZodBoolean;
|
|
965
|
+
type: z.ZodEnum<{
|
|
966
|
+
btree: "btree";
|
|
967
|
+
hash: "hash";
|
|
968
|
+
gin: "gin";
|
|
969
|
+
gist: "gist";
|
|
970
|
+
ivfflat: "ivfflat";
|
|
971
|
+
hnsw: "hnsw";
|
|
972
|
+
other: "other";
|
|
973
|
+
}>;
|
|
974
|
+
}, z.core.$strip>;
|
|
975
|
+
declare const EntitySchemaSchema: z.ZodObject<{
|
|
976
|
+
name: z.ZodString;
|
|
977
|
+
table: z.ZodString;
|
|
978
|
+
description: z.ZodOptional<z.ZodString>;
|
|
979
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
980
|
+
name: z.ZodString;
|
|
981
|
+
type: z.ZodString;
|
|
982
|
+
normalizedType: z.ZodEnum<{
|
|
983
|
+
string: "string";
|
|
984
|
+
number: "number";
|
|
985
|
+
boolean: "boolean";
|
|
986
|
+
unknown: "unknown";
|
|
987
|
+
date: "date";
|
|
988
|
+
array: "array";
|
|
989
|
+
timestamp: "timestamp";
|
|
990
|
+
uuid: "uuid";
|
|
991
|
+
json: "json";
|
|
992
|
+
vector: "vector";
|
|
993
|
+
}>;
|
|
994
|
+
nullable: z.ZodBoolean;
|
|
995
|
+
primaryKey: z.ZodBoolean;
|
|
996
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
997
|
+
description: z.ZodOptional<z.ZodString>;
|
|
998
|
+
vectorDimensions: z.ZodOptional<z.ZodNumber>;
|
|
999
|
+
}, z.core.$strip>>;
|
|
1000
|
+
relations: z.ZodArray<z.ZodObject<{
|
|
1001
|
+
type: z.ZodEnum<{
|
|
1002
|
+
hasOne: "hasOne";
|
|
1003
|
+
hasMany: "hasMany";
|
|
1004
|
+
belongsTo: "belongsTo";
|
|
1005
|
+
}>;
|
|
1006
|
+
entity: z.ZodString;
|
|
1007
|
+
localFields: z.ZodArray<z.ZodString>;
|
|
1008
|
+
foreignFields: z.ZodArray<z.ZodString>;
|
|
1009
|
+
}, z.core.$strip>>;
|
|
1010
|
+
indexes: z.ZodArray<z.ZodObject<{
|
|
1011
|
+
name: z.ZodString;
|
|
1012
|
+
fields: z.ZodArray<z.ZodString>;
|
|
1013
|
+
unique: z.ZodBoolean;
|
|
1014
|
+
type: z.ZodEnum<{
|
|
1015
|
+
btree: "btree";
|
|
1016
|
+
hash: "hash";
|
|
1017
|
+
gin: "gin";
|
|
1018
|
+
gist: "gist";
|
|
1019
|
+
ivfflat: "ivfflat";
|
|
1020
|
+
hnsw: "hnsw";
|
|
1021
|
+
other: "other";
|
|
1022
|
+
}>;
|
|
1023
|
+
}, z.core.$strip>>;
|
|
1024
|
+
rowCount: z.ZodOptional<z.ZodNumber>;
|
|
1025
|
+
}, z.core.$strip>;
|
|
1026
|
+
declare const DatabaseSchemaSchema: z.ZodObject<{
|
|
1027
|
+
entities: z.ZodArray<z.ZodObject<{
|
|
1028
|
+
name: z.ZodString;
|
|
1029
|
+
table: z.ZodString;
|
|
1030
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1031
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
1032
|
+
name: z.ZodString;
|
|
1033
|
+
type: z.ZodString;
|
|
1034
|
+
normalizedType: z.ZodEnum<{
|
|
1035
|
+
string: "string";
|
|
1036
|
+
number: "number";
|
|
1037
|
+
boolean: "boolean";
|
|
1038
|
+
unknown: "unknown";
|
|
1039
|
+
date: "date";
|
|
1040
|
+
array: "array";
|
|
1041
|
+
timestamp: "timestamp";
|
|
1042
|
+
uuid: "uuid";
|
|
1043
|
+
json: "json";
|
|
1044
|
+
vector: "vector";
|
|
1045
|
+
}>;
|
|
1046
|
+
nullable: z.ZodBoolean;
|
|
1047
|
+
primaryKey: z.ZodBoolean;
|
|
1048
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
1049
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1050
|
+
vectorDimensions: z.ZodOptional<z.ZodNumber>;
|
|
1051
|
+
}, z.core.$strip>>;
|
|
1052
|
+
relations: z.ZodArray<z.ZodObject<{
|
|
1053
|
+
type: z.ZodEnum<{
|
|
1054
|
+
hasOne: "hasOne";
|
|
1055
|
+
hasMany: "hasMany";
|
|
1056
|
+
belongsTo: "belongsTo";
|
|
1057
|
+
}>;
|
|
1058
|
+
entity: z.ZodString;
|
|
1059
|
+
localFields: z.ZodArray<z.ZodString>;
|
|
1060
|
+
foreignFields: z.ZodArray<z.ZodString>;
|
|
1061
|
+
}, z.core.$strip>>;
|
|
1062
|
+
indexes: z.ZodArray<z.ZodObject<{
|
|
1063
|
+
name: z.ZodString;
|
|
1064
|
+
fields: z.ZodArray<z.ZodString>;
|
|
1065
|
+
unique: z.ZodBoolean;
|
|
1066
|
+
type: z.ZodEnum<{
|
|
1067
|
+
btree: "btree";
|
|
1068
|
+
hash: "hash";
|
|
1069
|
+
gin: "gin";
|
|
1070
|
+
gist: "gist";
|
|
1071
|
+
ivfflat: "ivfflat";
|
|
1072
|
+
hnsw: "hnsw";
|
|
1073
|
+
other: "other";
|
|
1074
|
+
}>;
|
|
1075
|
+
}, z.core.$strip>>;
|
|
1076
|
+
rowCount: z.ZodOptional<z.ZodNumber>;
|
|
1077
|
+
}, z.core.$strip>>;
|
|
1078
|
+
}, z.core.$strip>;
|
|
1079
|
+
type NormalizedType = z.infer<typeof NormalizedTypeSchema>;
|
|
1080
|
+
type FieldSchema = z.infer<typeof FieldSchemaSchema>;
|
|
1081
|
+
type RelationSchema = z.infer<typeof RelationSchemaSchema>;
|
|
1082
|
+
type IndexSchema = z.infer<typeof IndexSchemaSchema>;
|
|
1083
|
+
type EntitySchema = z.infer<typeof EntitySchemaSchema>;
|
|
1084
|
+
type DatabaseSchema = z.infer<typeof DatabaseSchemaSchema>;
|
|
1085
|
+
|
|
1086
|
+
type ResolvedSource = {
|
|
1087
|
+
alias: string;
|
|
1088
|
+
entity?: EntitySchema;
|
|
1089
|
+
subquery?: ResolvedQuery;
|
|
1090
|
+
table?: string;
|
|
1091
|
+
};
|
|
1092
|
+
type ResolvedField = {
|
|
1093
|
+
path: string;
|
|
1094
|
+
alias: string;
|
|
1095
|
+
column: string;
|
|
1096
|
+
outputName: string;
|
|
1097
|
+
schema: FieldSchema;
|
|
1098
|
+
};
|
|
1099
|
+
type ResolvedJoin = {
|
|
1100
|
+
fromAlias: string;
|
|
1101
|
+
fromColumns: string[];
|
|
1102
|
+
toAlias: string;
|
|
1103
|
+
toColumns: string[];
|
|
1104
|
+
toTable: string;
|
|
1105
|
+
kind: 'inner' | 'left';
|
|
1106
|
+
on?: ResolvedFilter[];
|
|
1107
|
+
};
|
|
1108
|
+
type ResolvedFilter = {
|
|
1109
|
+
original: Filter;
|
|
1110
|
+
resolvedPaths: Map<string, {
|
|
1111
|
+
alias: string;
|
|
1112
|
+
column: string;
|
|
1113
|
+
schema: FieldSchema;
|
|
1114
|
+
}>;
|
|
1115
|
+
};
|
|
1116
|
+
type ResolvedSemantic = {
|
|
1117
|
+
field: ResolvedField;
|
|
1118
|
+
contextPath: string;
|
|
1119
|
+
minScore?: number;
|
|
1120
|
+
};
|
|
1121
|
+
type ResolvedExists = {
|
|
1122
|
+
sources: ResolvedSource[];
|
|
1123
|
+
joins: ResolvedJoin[];
|
|
1124
|
+
filter?: ResolvedFilter;
|
|
1125
|
+
aliasMap: Map<string, string>;
|
|
1126
|
+
};
|
|
1127
|
+
type ResolvedQuery = {
|
|
1128
|
+
sources: ResolvedSource[];
|
|
1129
|
+
joins: ResolvedJoin[];
|
|
1130
|
+
existsMap?: Map<object, ResolvedExists>;
|
|
1131
|
+
fields: ResolvedField[];
|
|
1132
|
+
filter?: ResolvedFilter;
|
|
1133
|
+
semantic?: ResolvedSemantic;
|
|
1134
|
+
computes: Array<{
|
|
1135
|
+
name: string;
|
|
1136
|
+
expression: ComputeExpression;
|
|
1137
|
+
}>;
|
|
1138
|
+
aggregates: Array<{
|
|
1139
|
+
name: string;
|
|
1140
|
+
expression: AggregateExpression;
|
|
1141
|
+
}>;
|
|
1142
|
+
groupBy: ResolvedField[];
|
|
1143
|
+
sort: Array<{
|
|
1144
|
+
field: ResolvedField | string;
|
|
1145
|
+
dir: 'asc' | 'desc';
|
|
1146
|
+
}>;
|
|
1147
|
+
limit?: number;
|
|
1148
|
+
distinct: boolean;
|
|
1149
|
+
aliasMap: Map<string, string>;
|
|
1150
|
+
};
|
|
1151
|
+
type AnalysisResult = {
|
|
1152
|
+
warnings: string[];
|
|
1153
|
+
errors: string[];
|
|
1154
|
+
};
|
|
1155
|
+
type AnalysisConfig = {
|
|
1156
|
+
maxNestingDepth: number;
|
|
1157
|
+
rejectCartesianProducts: boolean;
|
|
1158
|
+
warnUnindexedFilters: boolean;
|
|
1159
|
+
rejectUnindexedFilters: boolean;
|
|
1160
|
+
};
|
|
1161
|
+
type TestResult = {
|
|
1162
|
+
rows: Record<string, unknown>[];
|
|
1163
|
+
warnings: string[];
|
|
1164
|
+
errors: string[];
|
|
1165
|
+
};
|
|
1166
|
+
|
|
1167
|
+
type CompiledQuery = {
|
|
1168
|
+
sql: string;
|
|
1169
|
+
paramSlots: ParamSlot[];
|
|
1170
|
+
contextContract: ContextContract;
|
|
1171
|
+
};
|
|
1172
|
+
type ParamSlot = {
|
|
1173
|
+
key: string;
|
|
1174
|
+
kind: 'context' | 'scope' | 'semantic';
|
|
1175
|
+
type: 'string' | 'number' | 'boolean' | 'string[]' | 'number[]' | 'json';
|
|
1176
|
+
dimensions?: number;
|
|
1177
|
+
encode?: 'json';
|
|
1178
|
+
};
|
|
1179
|
+
type ContextContract = Record<string, {
|
|
1180
|
+
type: ParamSlot['type'];
|
|
1181
|
+
kind: ParamSlot['kind'];
|
|
1182
|
+
}>;
|
|
1183
|
+
type BoundParams = unknown[];
|
|
1184
|
+
type Row = Record<string, unknown>;
|
|
1185
|
+
type IntrospectOptions = {
|
|
1186
|
+
entities?: string[];
|
|
1187
|
+
exclude?: string[];
|
|
1188
|
+
schema?: string;
|
|
1189
|
+
};
|
|
1190
|
+
type DatabaseAdapter = {
|
|
1191
|
+
id: string;
|
|
1192
|
+
introspect: (options?: IntrospectOptions) => Promise<DatabaseSchema>;
|
|
1193
|
+
compile: (resolved: ResolvedQuery) => CompiledQuery;
|
|
1194
|
+
execute: (query: CompiledQuery, params: BoundParams) => Promise<Row[]>;
|
|
1195
|
+
capabilities: AdapterCapabilities;
|
|
1196
|
+
limitReads?: (ms: number) => Promise<'connection' | 'statement' | 'unenforced'>;
|
|
1197
|
+
};
|
|
1198
|
+
type AdapterCapabilities = {
|
|
1199
|
+
vectorSearch: boolean;
|
|
1200
|
+
fuzzyMatch: boolean;
|
|
1201
|
+
jsonFields: boolean;
|
|
1202
|
+
fullTextSearch: boolean;
|
|
1203
|
+
returningClause: boolean;
|
|
1204
|
+
cte: boolean;
|
|
1205
|
+
windowFunctions: boolean;
|
|
1206
|
+
statementTimeout: boolean;
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1209
|
+
declare const QueryRequestSchema: z.ZodObject<{
|
|
1210
|
+
fingerprint: z.ZodOptional<z.ZodString>;
|
|
1211
|
+
intent: z.ZodOptional<z.ZodString>;
|
|
1212
|
+
shape: z.ZodOptional<z.ZodUnknown>;
|
|
1213
|
+
context: z.ZodDefault<z.ZodObject<{
|
|
1214
|
+
sortBy: z.ZodOptional<z.ZodString>;
|
|
1215
|
+
sortDir: z.ZodOptional<z.ZodEnum<{
|
|
1216
|
+
asc: "asc";
|
|
1217
|
+
desc: "desc";
|
|
1218
|
+
}>>;
|
|
1219
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
1220
|
+
}, z.core.$strip>;
|
|
1221
|
+
type QueryRequest = z.infer<typeof QueryRequestSchema>;
|
|
1222
|
+
type CacheMeta = {
|
|
1223
|
+
hit: boolean;
|
|
1224
|
+
fingerprint?: string;
|
|
1225
|
+
replaced?: boolean;
|
|
1226
|
+
intent?: string;
|
|
1227
|
+
};
|
|
1228
|
+
type TimingMeta = {
|
|
1229
|
+
agentMs?: number;
|
|
1230
|
+
executionMs: number;
|
|
1231
|
+
mappingMs?: number;
|
|
1232
|
+
transformMs?: number;
|
|
1233
|
+
};
|
|
1234
|
+
type ContextMeta = {
|
|
1235
|
+
type?: 'string' | 'number' | 'boolean' | 'string[]' | 'number[]' | 'json';
|
|
1236
|
+
kind: 'context' | 'scope' | 'semantic';
|
|
1237
|
+
optional?: true;
|
|
1238
|
+
absent?: true;
|
|
1239
|
+
};
|
|
1240
|
+
type QueryResponse = {
|
|
1241
|
+
result: JsonValue;
|
|
1242
|
+
meta: {
|
|
1243
|
+
cache: CacheMeta;
|
|
1244
|
+
context: Record<string, ContextMeta>;
|
|
1245
|
+
timing?: TimingMeta;
|
|
1246
|
+
warnings?: string[];
|
|
1247
|
+
missingContext?: string[];
|
|
1248
|
+
};
|
|
1249
|
+
};
|
|
1250
|
+
type QueryErrorResponse = {
|
|
1251
|
+
error: string;
|
|
1252
|
+
message: string;
|
|
1253
|
+
details?: {
|
|
1254
|
+
suggestion?: string;
|
|
1255
|
+
options?: string[];
|
|
1256
|
+
};
|
|
1257
|
+
};
|
|
1258
|
+
type QueryErrorCode = 'invalid_request' | 'invalid_dsl' | 'missing_scope' | 'scope_denied' | 'missing_context' | 'execution_error' | 'agent_failed' | 'cache_miss' | 'fingerprint_protected' | 'locked' | 'unsatisfiable';
|
|
1259
|
+
|
|
1260
|
+
type VexEvent = {
|
|
1261
|
+
type: 'query.start';
|
|
1262
|
+
intent?: string;
|
|
1263
|
+
shape?: unknown;
|
|
1264
|
+
fingerprint?: string;
|
|
1265
|
+
entities?: string[];
|
|
1266
|
+
} | {
|
|
1267
|
+
type: 'query.cache';
|
|
1268
|
+
hit: boolean;
|
|
1269
|
+
fingerprint?: string;
|
|
1270
|
+
replaced?: boolean;
|
|
1271
|
+
} | {
|
|
1272
|
+
type: 'query.dsl';
|
|
1273
|
+
dsl: unknown;
|
|
1274
|
+
agentMs: number;
|
|
1275
|
+
} | {
|
|
1276
|
+
type: 'query.sql';
|
|
1277
|
+
sql: string;
|
|
1278
|
+
warnings: string[];
|
|
1279
|
+
} | {
|
|
1280
|
+
type: 'query.rows';
|
|
1281
|
+
count: number;
|
|
1282
|
+
executionMs: number;
|
|
1283
|
+
} | {
|
|
1284
|
+
type: 'query.mapped';
|
|
1285
|
+
mappingMs: number;
|
|
1286
|
+
} | {
|
|
1287
|
+
type: 'query.done';
|
|
1288
|
+
totalMs: number;
|
|
1289
|
+
} | {
|
|
1290
|
+
type: 'query.error';
|
|
1291
|
+
code: string;
|
|
1292
|
+
message: string;
|
|
1293
|
+
} | {
|
|
1294
|
+
type: 'rows.evict';
|
|
1295
|
+
reason: 'capacity' | 'oversized';
|
|
1296
|
+
bytes: number;
|
|
1297
|
+
} | {
|
|
1298
|
+
type: 'rows.error';
|
|
1299
|
+
message: string;
|
|
1300
|
+
} | {
|
|
1301
|
+
type: 'llm.request';
|
|
1302
|
+
agent: string;
|
|
1303
|
+
iteration: number;
|
|
1304
|
+
messages: number;
|
|
1305
|
+
tools: string[];
|
|
1306
|
+
} | {
|
|
1307
|
+
type: 'llm.response';
|
|
1308
|
+
agent: string;
|
|
1309
|
+
iteration: number;
|
|
1310
|
+
content: string;
|
|
1311
|
+
toolCalls: Array<{
|
|
1312
|
+
name: string;
|
|
1313
|
+
args: unknown;
|
|
1314
|
+
}>;
|
|
1315
|
+
finishReason: string;
|
|
1316
|
+
tokens: number;
|
|
1317
|
+
ms: number;
|
|
1318
|
+
};
|
|
1319
|
+
type VexEventHandler = (event: VexEvent) => void;
|
|
1320
|
+
|
|
1321
|
+
type LiveRowsConfig = {
|
|
1322
|
+
/** How long stored rows are trusted, and how often a followed read is re-checked when nothing wrote. Default 60 000. */
|
|
1323
|
+
ttlMs?: number;
|
|
1324
|
+
/** Most stored results. Default 5 000. */
|
|
1325
|
+
maxEntries?: number;
|
|
1326
|
+
/** Most stored text, measured as the length of each result's JSON. Default 64 MiB. */
|
|
1327
|
+
maxBytes?: number;
|
|
1328
|
+
/** Largest single result worth storing; bigger ones are refetched every time. Default a tenth of `maxBytes`. */
|
|
1329
|
+
maxEntryBytes?: number;
|
|
1330
|
+
/** How long a burst of writes is gathered before followed reads refetch. Default 10. */
|
|
1331
|
+
debounceMs?: number;
|
|
1332
|
+
};
|
|
1333
|
+
type LiveRowsStats = {
|
|
1334
|
+
entries: number;
|
|
1335
|
+
bytes: number;
|
|
1336
|
+
follows: number;
|
|
1337
|
+
followers: number;
|
|
1338
|
+
hits: number;
|
|
1339
|
+
misses: number;
|
|
1340
|
+
evictions: number;
|
|
1341
|
+
oversized: number;
|
|
1342
|
+
refreshes: number;
|
|
1343
|
+
};
|
|
1344
|
+
|
|
1345
|
+
declare const SCOPE_VERBS: readonly ["read", "write.insert", "write.update", "write.delete"];
|
|
1346
|
+
declare const scopeGrants: (tables: readonly string[]) => string[];
|
|
1347
|
+
type ScopeRules = {
|
|
1348
|
+
read?: ScopeMatch[];
|
|
1349
|
+
write?: ScopeRule[];
|
|
1350
|
+
insert?: ScopeRule[];
|
|
1351
|
+
update?: ScopeRule[];
|
|
1352
|
+
delete?: ScopeMatch[];
|
|
1353
|
+
};
|
|
1354
|
+
type NamedScopeBehaviors = Record<string, ScopeRules>;
|
|
1355
|
+
type ScopeBehaviors = Record<string, ScopeRules | NamedScopeBehaviors>;
|
|
1356
|
+
/**
|
|
1357
|
+
* The columns the behaviors bind to scope keys, on the given tables, for the
|
|
1358
|
+
* keys present in `scope` — sorted, one per (table, column, key).
|
|
1359
|
+
*/
|
|
1360
|
+
declare const scopeBindings: (behaviors: ScopeBehaviors, tables: readonly string[], scope: ScopeValues) => ScopeBinding[];
|
|
1361
|
+
/** Every profile name any table declares. A profile nobody declares is a typo. */
|
|
1362
|
+
declare const scopeProfiles: (behaviors: ScopeBehaviors) => ReadonlySet<string>;
|
|
1363
|
+
declare const createScopePolicy: (grants: ReadonlySet<string>, behaviors?: ScopeBehaviors, scoping?: string) => ScopePolicy;
|
|
1364
|
+
/** The union of several compiled policies: anything any of them permits. */
|
|
1365
|
+
declare const mergeScopePolicies: (policies: readonly ScopePolicy[]) => ScopePolicy;
|
|
1366
|
+
|
|
1367
|
+
/**
|
|
1368
|
+
* Who a generation is for, as a capability rather than an identity. `read` runs
|
|
1369
|
+
* a DSL through the engine's own pipeline under the caller's policy and scope
|
|
1370
|
+
* values — `$context` slots bind NULL, because a probe asks whether a query
|
|
1371
|
+
* runs, not what it answers. It is the only door a generator has to the
|
|
1372
|
+
* database: it sees what the person asking would see, and nothing else.
|
|
1373
|
+
*/
|
|
1374
|
+
type GenerationCaller = {
|
|
1375
|
+
read: (dsl: Query) => Promise<{
|
|
1376
|
+
rows: Row[];
|
|
1377
|
+
sql: string;
|
|
1378
|
+
warnings: string[];
|
|
1379
|
+
}>;
|
|
1380
|
+
/**
|
|
1381
|
+
* WHO "ME" IS, as columns: every column the host's behaviors bind to a scope
|
|
1382
|
+
* key this caller actually carries, on a table they may read — the keys and
|
|
1383
|
+
* the columns, never the values. A generator uses them to say "the caller"
|
|
1384
|
+
* or "theirs": filter the column with `{ $scope: key }`, and the engine binds
|
|
1385
|
+
* the caller's own value. Empty when nothing identifies the caller (no
|
|
1386
|
+
* behaviors given, or a caller carrying none of the keys they bind).
|
|
1387
|
+
*/
|
|
1388
|
+
bindings: ScopeBinding[];
|
|
1389
|
+
};
|
|
1390
|
+
/** One column a scope key is bound to by the host's behaviors. */
|
|
1391
|
+
type ScopeBinding = {
|
|
1392
|
+
entity: string;
|
|
1393
|
+
field: string;
|
|
1394
|
+
key: string;
|
|
1395
|
+
};
|
|
1396
|
+
/**
|
|
1397
|
+
* DSL generation from intent + shape. Wire to a Cortex agent (see agent/).
|
|
1398
|
+
* `schema` holds only the tables the caller's policy lets them read.
|
|
1399
|
+
*/
|
|
1400
|
+
type GenerateDsl = (request: QueryRequest, schema: DatabaseSchema, caller: GenerationCaller) => Promise<Query>;
|
|
1401
|
+
/**
|
|
1402
|
+
* Result mapping from the raw row set to the requested shape. The mapping runs
|
|
1403
|
+
* ONCE over `{ result }` — the rows for an array shape, the single (first) row
|
|
1404
|
+
* for an object shape — so `transformed` is whatever it produced: an array, a
|
|
1405
|
+
* single object, or a scalar. Wire to Prism's mapping agent.
|
|
1406
|
+
*/
|
|
1407
|
+
type MapToShape = (rows: Row[], shape: unknown) => Promise<{
|
|
1408
|
+
ir: CompiledIr;
|
|
1409
|
+
transformed: JsonValue;
|
|
1410
|
+
}>;
|
|
1411
|
+
type QueryEngineConfig = {
|
|
1412
|
+
adapter: DatabaseAdapter;
|
|
1413
|
+
/**
|
|
1414
|
+
* Turns text into a vector at parameter-binding time, for `semantic`
|
|
1415
|
+
* filters. An injected provider (wire it to Signal), not a database
|
|
1416
|
+
* concern — the adapter only generates the vector-distance SQL.
|
|
1417
|
+
* Required only if the schema has vector columns you search over.
|
|
1418
|
+
*/
|
|
1419
|
+
embed?: (text: string, dimensions?: number) => Promise<number[]>;
|
|
1420
|
+
scope?: ScopePolicy;
|
|
1421
|
+
cache?: CacheBackend;
|
|
1422
|
+
onEvent?: VexEventHandler;
|
|
1423
|
+
/** Optional LLM-backed query generation (cache misses fail without it). */
|
|
1424
|
+
generateDsl?: GenerateDsl;
|
|
1425
|
+
/**
|
|
1426
|
+
* The host's behaviors — the same document its policies are compiled from
|
|
1427
|
+
* (`createScopePolicy`). Read here for one thing: which columns a scope key
|
|
1428
|
+
* is bound to, so a generation can be told who its caller is in the
|
|
1429
|
+
* schema's own terms (GenerationCaller.bindings). A compiled policy cannot
|
|
1430
|
+
* say it — it keeps only the phases a caller is granted, and the rule that
|
|
1431
|
+
* stamps a member's id lives on a write a reader does not hold. Checked at
|
|
1432
|
+
* `introspect`: every rule names a table and a column that exist.
|
|
1433
|
+
*/
|
|
1434
|
+
behaviors?: ScopeBehaviors;
|
|
1435
|
+
/** Optional LLM-backed result mapping (raw rows used as-is without it). */
|
|
1436
|
+
mapToShape?: MapToShape;
|
|
1437
|
+
/**
|
|
1438
|
+
* The rows cache behind `refresh: 'reactive'` entries — its age, size and
|
|
1439
|
+
* burst window. Held in this process's memory; nothing else is cached.
|
|
1440
|
+
*/
|
|
1441
|
+
rows?: LiveRowsConfig;
|
|
1442
|
+
config?: {
|
|
1443
|
+
maxNestingDepth?: number;
|
|
1444
|
+
defaultLimit?: number;
|
|
1445
|
+
maxLimit?: number;
|
|
1446
|
+
rejectCartesianProducts?: boolean;
|
|
1447
|
+
warnUnindexedFilters?: boolean;
|
|
1448
|
+
rejectUnindexedFilters?: boolean;
|
|
1449
|
+
entities?: string[];
|
|
1450
|
+
unsatisfiableTtlMs?: number;
|
|
1451
|
+
statementTimeoutMs?: number;
|
|
1452
|
+
maxPresenceVariants?: number;
|
|
1453
|
+
};
|
|
1454
|
+
};
|
|
1455
|
+
type QueryEngine = {
|
|
1456
|
+
introspect: () => Promise<DatabaseSchema>;
|
|
1457
|
+
execute: (request: QueryRequest, options?: ExecuteOptions) => Promise<QueryResponse>;
|
|
1458
|
+
compile: (dsl: Query) => CompiledQuery;
|
|
1459
|
+
test: (dsl: Query, scope?: ScopeValues) => Promise<TestResult>;
|
|
1460
|
+
getDslSchema: () => object;
|
|
1461
|
+
getSchema: () => DatabaseSchema | undefined;
|
|
1462
|
+
cache: CacheBackend;
|
|
1463
|
+
/**
|
|
1464
|
+
* These tables were written. Every reactive read over any of them is
|
|
1465
|
+
* refetched (once per burst) and its followers told if their answer changed.
|
|
1466
|
+
* The vex handler calls this after every committed mutation; a host calls
|
|
1467
|
+
* it for writes vex did not make.
|
|
1468
|
+
*/
|
|
1469
|
+
invalidate: (tables: readonly string[]) => void;
|
|
1470
|
+
/** The reactive rows cache: what it holds and how it is doing. */
|
|
1471
|
+
rows: {
|
|
1472
|
+
stats: () => LiveRowsStats;
|
|
1473
|
+
stop: () => void;
|
|
1474
|
+
};
|
|
1475
|
+
};
|
|
1476
|
+
type ExecuteOptions = {
|
|
1477
|
+
scope?: ScopeValues;
|
|
1478
|
+
entities?: string[];
|
|
1479
|
+
locked?: boolean;
|
|
1480
|
+
scopePolicy?: ScopePolicy;
|
|
1481
|
+
/**
|
|
1482
|
+
* FOLLOW THE ANSWER. For an entry with `refresh: 'reactive'`, every later
|
|
1483
|
+
* answer that differs from the last one is handed to `onChange` — after
|
|
1484
|
+
* writes to the tables the query reads — until `signal` aborts. Both or
|
|
1485
|
+
* neither; ignored for a snapshot read.
|
|
1486
|
+
*/
|
|
1487
|
+
signal?: AbortSignal;
|
|
1488
|
+
onChange?: (response: QueryResponse) => void;
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1491
|
+
export { QueryRequestSchema as $, type AnalysisConfig as A, type BoundParams as B, type CompiledQuery as C, type DatabaseSchema as D, type EntitySchema as E, type FieldSchema as F, type GenerateDsl as G, type LiveRowsStats as H, type IndexSchema as I, type LookupValue as J, type MapToShape as K, type LiveRowsConfig as L, type MutationDefinition as M, type Mutation as N, type MutationCacheEntry as O, type ParamSlot as P, type QueryEngineConfig as Q, type ResolvedQuery as R, type ScopePolicy as S, MutationDefinitionSchema as T, MutationSchema as U, type MutationValue as V, type NamedScopeBehaviors as W, type NormalizedType as X, type OkCacheEntry as Y, type QueryErrorResponse as Z, type QueryRequest as _, type QueryEngine as a, type QueryResponse as a0, QuerySchema as a1, REFRESH_MODES as a2, type RelationSchema as a3, type ResolvedField as a4, type ResolvedFilter as a5, type ResolvedJoin as a6, type ResolvedMutation as a7, type ResolvedOnConflict as a8, type ResolvedSemantic as a9, type ResolvedSource as aa, SCOPE_VERBS as ab, type ScopeBehaviors as ac, type ScopeBinding as ad, type ScopeEntityRule as ae, type ScopeMatch as af, type ScopeRef as ag, type ScopeRule as ah, type ScopeRules as ai, type ScopeSet as aj, type ScopeValues as ak, type SortEntry as al, type Source as am, type TestResult as an, type UnsatisfiableCacheEntry as ao, type VexEvent as ap, type VexEventHandler as aq, createScopePolicy as ar, isRefresh as as, mergeScopePolicies as at, scopeBindings as au, scopeGrants as av, scopeProfiles as aw, type Query as b, type AnalysisResult as c, type ContextMeta as d, type DatabaseAdapter as e, type Row as f, type ResolvedExists as g, type FieldOrValue as h, type Filter as i, type QueryErrorCode as j, type CacheBackend as k, type CacheEntry as l, type Refresh as m, type ContextContract as n, type AdapterCapabilities as o, type AggregateExpression as p, AggregateExpressionSchema as q, type ComputeExpression as r, ComputeExpressionSchema as s, type ContextRef as t, type CoreMutation as u, type ExecuteOptions as v, FilterSchema as w, type GenerationCaller as x, type IntrospectOptions as y, type ItemRef as z };
|