@niscorp/vex 0.3.0 → 0.4.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/CHANGELOG.md +40 -0
- package/DESIGN.md +30 -14
- package/DOCS.md +65 -13
- package/dist/adapters/express/index.cjs +7 -25
- package/dist/adapters/express/index.cjs.map +1 -1
- package/dist/adapters/express/index.d.cts +3 -2
- package/dist/adapters/express/index.d.ts +3 -2
- package/dist/adapters/express/index.js +3 -2
- package/dist/adapters/express/index.js.map +1 -1
- package/dist/adapters/hono/index.cjs +7 -25
- package/dist/adapters/hono/index.cjs.map +1 -1
- package/dist/adapters/hono/index.d.cts +3 -2
- package/dist/adapters/hono/index.d.ts +3 -2
- package/dist/adapters/hono/index.js +3 -2
- package/dist/adapters/hono/index.js.map +1 -1
- package/dist/adapters/pglite/index.cjs.map +1 -1
- package/dist/adapters/pglite/index.js.map +1 -1
- package/dist/agent/index.cjs +9 -14
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +3 -2
- package/dist/agent/index.d.ts +3 -2
- package/dist/agent/index.js +8 -9
- package/dist/agent/index.js.map +1 -1
- package/dist/{chunk-IQM4SQE2.js → chunk-7F2OH4IP.js} +8 -22
- package/dist/chunk-7F2OH4IP.js.map +1 -0
- package/dist/chunk-F7RDSWYF.js +7 -0
- package/dist/chunk-F7RDSWYF.js.map +1 -0
- package/dist/{chunk-H4BHW76Q.js → chunk-UPQMKAAX.js} +6 -24
- package/dist/chunk-UPQMKAAX.js.map +1 -0
- package/dist/chunk-XTOK7YOR.js +18 -0
- package/dist/chunk-XTOK7YOR.js.map +1 -0
- package/dist/{handler-BGCL6_Si.d.ts → handler-Bw7xVmBM.d.ts} +2 -1
- package/dist/{handler-CMrjTXNx.d.cts → handler-Cy0gNM6K.d.cts} +2 -1
- package/dist/index.cjs +44 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -63
- package/dist/index.d.ts +17 -63
- package/dist/index.js +46 -74
- package/dist/index.js.map +1 -1
- package/dist/migrations/index.cjs +173 -0
- package/dist/migrations/index.cjs.map +1 -0
- package/dist/migrations/index.d.cts +20 -0
- package/dist/migrations/index.d.ts +20 -0
- package/dist/migrations/index.js +23 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/query.schema-B-LVNfyX.d.cts +461 -0
- package/dist/query.schema-B-LVNfyX.d.ts +461 -0
- package/dist/{types-Bi-Lg86b.d.cts → types-Bs_9VM9p.d.ts} +16 -583
- package/dist/{types-Bi-Lg86b.d.ts → types-DO-rYZci.d.cts} +16 -583
- package/package.json +17 -7
- package/dist/chunk-H4BHW76Q.js.map +0 -1
- package/dist/chunk-IQM4SQE2.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as Filter, F as FieldOrValue, Q as Query, C as ComputeExpression, A as AggregateExpression } from './query.schema-B-LVNfyX.cjs';
|
|
2
2
|
import { CompiledIr, JsonValue } from '@niscorp/prism';
|
|
3
|
+
import { z } from 'zod';
|
|
3
4
|
import { Sequence } from '@niscorp/strata';
|
|
4
5
|
|
|
5
6
|
type ScopeValues = Record<string, unknown>;
|
|
@@ -33,464 +34,6 @@ type ScopePolicy = {
|
|
|
33
34
|
entities: Record<string, ScopeEntityRule>;
|
|
34
35
|
};
|
|
35
36
|
|
|
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
37
|
declare const MutationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
495
38
|
op: z.ZodLiteral<"insert">;
|
|
496
39
|
table: z.ZodString;
|
|
@@ -864,36 +407,11 @@ type Refresh = (typeof REFRESH_MODES)[number];
|
|
|
864
407
|
declare const isRefresh: (value: unknown) => value is Refresh;
|
|
865
408
|
type CacheEntryMeta = {
|
|
866
409
|
createdAt: number;
|
|
867
|
-
/**
|
|
868
|
-
* Touch-on-read timestamp. Lifetime is usage: a GC sweep evicts
|
|
869
|
-
* entries unused for a configured window; protected entries never
|
|
870
|
-
* sweep. Replaces the provisional/permanent distinction entirely.
|
|
871
|
-
*/
|
|
872
410
|
lastUsedAt?: number;
|
|
873
411
|
expiresAt?: number;
|
|
874
|
-
/**
|
|
875
|
-
* Protected entries refuse replacement: a fingerprint request whose
|
|
876
|
-
* intent/shape differ from the stored ones errors instead of
|
|
877
|
-
* regenerating. Written ONLY by the seed path and an explicit PATCH —
|
|
878
|
-
* never by query execution.
|
|
879
|
-
*/
|
|
880
412
|
protected?: boolean;
|
|
881
|
-
/**
|
|
882
|
-
* Identity of the request that produced this entry (intent + normalized
|
|
883
|
-
* shape + context key names). A fingerprint request with a matching
|
|
884
|
-
* hash is a hit; a differing one regenerates (or 409s when protected).
|
|
885
|
-
*/
|
|
886
413
|
requestHash?: string;
|
|
887
|
-
/**
|
|
888
|
-
* Fingerprint of the database schema at write time. When it no longer
|
|
889
|
-
* matches the current schema, the entry is stale (its DSL may
|
|
890
|
-
* reference columns that have since changed) and is treated as a miss.
|
|
891
|
-
*/
|
|
892
414
|
schemaFingerprint?: string;
|
|
893
|
-
/**
|
|
894
|
-
* The originating request's intent and shape — descriptive metadata
|
|
895
|
-
* for inspection and the GET overview. Never part of identity.
|
|
896
|
-
*/
|
|
897
415
|
intent?: string;
|
|
898
416
|
shape?: unknown;
|
|
899
417
|
};
|
|
@@ -901,25 +419,13 @@ type OkCacheEntry = CacheEntryMeta & {
|
|
|
901
419
|
kind: 'ok';
|
|
902
420
|
dsl: Query;
|
|
903
421
|
prismIr?: CompiledIr;
|
|
422
|
+
mapping?: unknown;
|
|
904
423
|
/**
|
|
905
|
-
*
|
|
906
|
-
*
|
|
907
|
-
*
|
|
908
|
-
* to every table they touch. That is right for a read whose answer legitimately
|
|
909
|
-
* widens with the reader — a roster, a schedule, a members list.
|
|
910
|
-
*
|
|
911
|
-
* It is wrong for a read that means "mine". A principal may hold several roles
|
|
912
|
-
* and the compiled policies merge to the WIDEST reach any of them grants, so an
|
|
913
|
-
* instructor who also trains at the studio reads `bookings` studio-wide — and
|
|
914
|
-
* "the classes you have booked" then answers with the whole studio's.
|
|
915
|
-
*
|
|
916
|
-
* An entry naming a reach is served at that profile instead, with the caller's
|
|
917
|
-
* own grants unchanged. It can only narrow: a read the caller holds no verb for
|
|
918
|
-
* is still refused. If the profile cannot be compiled, the read is refused
|
|
919
|
-
* rather than served wide.
|
|
424
|
+
* The scope profile this read is served at, whatever the caller's roles say:
|
|
425
|
+
* roles merge to the widest reach any of them grants, which is wrong for a
|
|
426
|
+
* read that means "mine". A reach the host cannot compile refuses the read.
|
|
920
427
|
*/
|
|
921
428
|
reach?: string;
|
|
922
|
-
/** When this read's answer is refreshed. Absent means 'snapshot'. */
|
|
923
429
|
refresh?: Refresh;
|
|
924
430
|
};
|
|
925
431
|
type UnsatisfiableCacheEntry = CacheEntryMeta & {
|
|
@@ -929,25 +435,11 @@ type UnsatisfiableCacheEntry = CacheEntryMeta & {
|
|
|
929
435
|
type MutationCacheEntry = CacheEntryMeta & {
|
|
930
436
|
kind: 'mutation';
|
|
931
437
|
mutation: MutationDefinition;
|
|
932
|
-
/**
|
|
933
|
-
* THE REACH THIS WRITE REQUIRES — the same word reads use, and it belongs
|
|
934
|
-
* here for a sharper reason.
|
|
935
|
-
*
|
|
936
|
-
* A read served too wide shows somebody too much. A write served too wide
|
|
937
|
-
* CHANGES somebody else's row: `me/cancel` is "cancel MY booking", and its
|
|
938
|
-
* whole safety is that the policy's update rules pin the row to the caller.
|
|
939
|
-
* Take a principal who holds two roles and the merge widens those rules to
|
|
940
|
-
* the broadest either grants — so the same fingerprint, replayed by somebody
|
|
941
|
-
* who is a member AND something else, could reach a booking that is not
|
|
942
|
-
* theirs.
|
|
943
|
-
*
|
|
944
|
-
* Declaring it here means the write is compiled at that profile whoever asks.
|
|
945
|
-
*/
|
|
946
438
|
reach?: string;
|
|
947
439
|
};
|
|
948
440
|
type CacheEntry = OkCacheEntry | UnsatisfiableCacheEntry | MutationCacheEntry;
|
|
949
441
|
type CacheBackend = {
|
|
950
|
-
get: (key: string) => Promise<CacheEntry | undefined>;
|
|
442
|
+
get: (key: string, scope?: ScopeValues) => Promise<CacheEntry | undefined>;
|
|
951
443
|
set: (key: string, entry: CacheEntry) => Promise<void>;
|
|
952
444
|
delete: (key: string) => Promise<void>;
|
|
953
445
|
clear: () => Promise<void>;
|
|
@@ -1364,15 +856,11 @@ type VexEvent = {
|
|
|
1364
856
|
type VexEventHandler = (event: VexEvent) => void;
|
|
1365
857
|
|
|
1366
858
|
type LiveRowsConfig = {
|
|
1367
|
-
/** How long stored rows are trusted, and how often a followed read is re-checked when nothing wrote. Default 60 000. */
|
|
1368
859
|
ttlMs?: number;
|
|
1369
|
-
/** Most stored results. Default 5 000. */
|
|
1370
860
|
maxEntries?: number;
|
|
1371
|
-
/**
|
|
861
|
+
/** Measured as the length of each result's JSON. */
|
|
1372
862
|
maxBytes?: number;
|
|
1373
|
-
/** Largest single result worth storing; bigger ones are refetched every time. Default a tenth of `maxBytes`. */
|
|
1374
863
|
maxEntryBytes?: number;
|
|
1375
|
-
/** How long a burst of writes is gathered before followed reads refetch. Default 10. */
|
|
1376
864
|
debounceMs?: number;
|
|
1377
865
|
};
|
|
1378
866
|
type LiveRowsStats = {
|
|
@@ -1398,91 +886,48 @@ type ScopeRules = {
|
|
|
1398
886
|
};
|
|
1399
887
|
type NamedScopeBehaviors = Record<string, ScopeRules>;
|
|
1400
888
|
type ScopeBehaviors = Record<string, ScopeRules | NamedScopeBehaviors>;
|
|
1401
|
-
/**
|
|
1402
|
-
* The columns the behaviors bind to scope keys, on the given tables, for the
|
|
1403
|
-
* keys present in `scope` — sorted, one per (table, column, key).
|
|
1404
|
-
*/
|
|
1405
889
|
declare const scopeBindings: (behaviors: ScopeBehaviors, tables: readonly string[], scope: ScopeValues) => ScopeBinding[];
|
|
1406
|
-
/** Every profile name any table declares. A profile nobody declares is a typo. */
|
|
1407
890
|
declare const scopeProfiles: (behaviors: ScopeBehaviors) => ReadonlySet<string>;
|
|
1408
891
|
declare const createScopePolicy: (grants: ReadonlySet<string>, behaviors?: ScopeBehaviors, scoping?: string) => ScopePolicy;
|
|
1409
|
-
/** The union of several compiled policies: anything any of them permits. */
|
|
1410
892
|
declare const mergeScopePolicies: (policies: readonly ScopePolicy[]) => ScopePolicy;
|
|
1411
893
|
|
|
1412
|
-
/**
|
|
1413
|
-
* Who a generation is for, as a capability rather than an identity. `read` runs
|
|
1414
|
-
* a DSL through the engine's own pipeline under the caller's policy and scope
|
|
1415
|
-
* values — `$context` slots bind NULL, because a probe asks whether a query
|
|
1416
|
-
* runs, not what it answers. It is the only door a generator has to the
|
|
1417
|
-
* database: it sees what the person asking would see, and nothing else.
|
|
1418
|
-
*/
|
|
1419
894
|
type GenerationCaller = {
|
|
1420
895
|
read: (dsl: Query) => Promise<{
|
|
1421
896
|
rows: Row[];
|
|
1422
897
|
sql: string;
|
|
1423
898
|
warnings: string[];
|
|
1424
899
|
}>;
|
|
1425
|
-
/**
|
|
1426
|
-
* WHO "ME" IS, as columns: every column the host's behaviors bind to a scope
|
|
1427
|
-
* key this caller actually carries, on a table they may read — the keys and
|
|
1428
|
-
* the columns, never the values. A generator uses them to say "the caller"
|
|
1429
|
-
* or "theirs": filter the column with `{ $scope: key }`, and the engine binds
|
|
1430
|
-
* the caller's own value. Empty when nothing identifies the caller (no
|
|
1431
|
-
* behaviors given, or a caller carrying none of the keys they bind).
|
|
1432
|
-
*/
|
|
1433
900
|
bindings: ScopeBinding[];
|
|
1434
901
|
};
|
|
1435
|
-
/** One column a scope key is bound to by the host's behaviors. */
|
|
1436
902
|
type ScopeBinding = {
|
|
1437
903
|
entity: string;
|
|
1438
904
|
field: string;
|
|
1439
905
|
key: string;
|
|
1440
906
|
};
|
|
1441
|
-
/**
|
|
1442
|
-
* DSL generation from intent + shape. Wire to a Cortex agent (see agent/).
|
|
1443
|
-
* `schema` holds only the tables the caller's policy lets them read.
|
|
1444
|
-
*/
|
|
1445
907
|
type GenerateDsl = (request: QueryRequest, schema: DatabaseSchema, caller: GenerationCaller) => Promise<Query>;
|
|
1446
908
|
/**
|
|
1447
|
-
*
|
|
1448
|
-
*
|
|
1449
|
-
* for an object shape — so `transformed` is whatever it produced: an array, a
|
|
1450
|
-
* single object, or a scalar. Wire to Prism's mapping agent.
|
|
909
|
+
* The IR is replayed against an envelope whose `result` is the rows for an array shape, the first row for any other.
|
|
910
|
+
* `config` is the prism config the IR was compiled from: a compiled form cannot be read back, or upgraded when prism changes.
|
|
1451
911
|
*/
|
|
1452
912
|
type MapToShape = (rows: Row[], shape: unknown) => Promise<{
|
|
1453
913
|
ir: CompiledIr;
|
|
914
|
+
config: unknown;
|
|
1454
915
|
transformed: JsonValue;
|
|
1455
916
|
}>;
|
|
1456
917
|
type QueryEngineConfig = {
|
|
1457
918
|
adapter: DatabaseAdapter;
|
|
1458
|
-
/**
|
|
1459
|
-
* Turns text into a vector at parameter-binding time, for `semantic`
|
|
1460
|
-
* filters. An injected provider (wire it to Signal), not a database
|
|
1461
|
-
* concern — the adapter only generates the vector-distance SQL.
|
|
1462
|
-
* Required only if the schema has vector columns you search over.
|
|
1463
|
-
*/
|
|
1464
919
|
embed?: (text: string, dimensions?: number) => Promise<number[]>;
|
|
1465
920
|
scope?: ScopePolicy;
|
|
1466
921
|
cache?: CacheBackend;
|
|
1467
922
|
onEvent?: VexEventHandler;
|
|
1468
|
-
/** Optional LLM-backed query generation (cache misses fail without it). */
|
|
1469
923
|
generateDsl?: GenerateDsl;
|
|
1470
924
|
/**
|
|
1471
|
-
*
|
|
1472
|
-
*
|
|
1473
|
-
*
|
|
1474
|
-
* schema's own terms (GenerationCaller.bindings). A compiled policy cannot
|
|
1475
|
-
* say it — it keeps only the phases a caller is granted, and the rule that
|
|
1476
|
-
* stamps a member's id lives on a write a reader does not hold. Checked at
|
|
1477
|
-
* `introspect`: every rule names a table and a column that exist.
|
|
925
|
+
* Read for one thing: which columns a scope key is bound to, so a generation
|
|
926
|
+
* can be told who its caller is (GenerationCaller.bindings). A compiled
|
|
927
|
+
* policy cannot say it: it keeps only the phases a caller is granted.
|
|
1478
928
|
*/
|
|
1479
929
|
behaviors?: ScopeBehaviors;
|
|
1480
|
-
/** Optional LLM-backed result mapping (raw rows used as-is without it). */
|
|
1481
930
|
mapToShape?: MapToShape;
|
|
1482
|
-
/**
|
|
1483
|
-
* The rows cache behind `refresh: 'reactive'` entries — its age, size and
|
|
1484
|
-
* burst window. Held in this process's memory; nothing else is cached.
|
|
1485
|
-
*/
|
|
1486
931
|
rows?: LiveRowsConfig;
|
|
1487
932
|
config?: {
|
|
1488
933
|
maxNestingDepth?: number;
|
|
@@ -1506,14 +951,7 @@ type QueryEngine = {
|
|
|
1506
951
|
getDslSchema: () => object;
|
|
1507
952
|
getSchema: () => DatabaseSchema | undefined;
|
|
1508
953
|
cache: CacheBackend;
|
|
1509
|
-
/**
|
|
1510
|
-
* These tables were written. Every reactive read over any of them is
|
|
1511
|
-
* refetched (once per burst) and its followers told if their answer changed.
|
|
1512
|
-
* The vex handler calls this after every committed mutation; a host calls
|
|
1513
|
-
* it for writes vex did not make.
|
|
1514
|
-
*/
|
|
1515
954
|
invalidate: (tables: readonly string[]) => void;
|
|
1516
|
-
/** The reactive rows cache: what it holds and how it is doing. */
|
|
1517
955
|
rows: {
|
|
1518
956
|
stats: () => LiveRowsStats;
|
|
1519
957
|
stop: () => void;
|
|
@@ -1524,14 +962,9 @@ type ExecuteOptions = {
|
|
|
1524
962
|
entities?: string[];
|
|
1525
963
|
locked?: boolean;
|
|
1526
964
|
scopePolicy?: ScopePolicy;
|
|
1527
|
-
/**
|
|
1528
|
-
* FOLLOW THE ANSWER. For an entry with `refresh: 'reactive'`, every later
|
|
1529
|
-
* answer that differs from the last one is handed to `onChange` — after
|
|
1530
|
-
* writes to the tables the query reads — until `signal` aborts. Both or
|
|
1531
|
-
* neither; ignored for a snapshot read.
|
|
1532
|
-
*/
|
|
965
|
+
/** `signal` and `onChange` go together; both are ignored for a snapshot read. */
|
|
1533
966
|
signal?: AbortSignal;
|
|
1534
967
|
onChange?: (response: QueryResponse) => void;
|
|
1535
968
|
};
|
|
1536
969
|
|
|
1537
|
-
export {
|
|
970
|
+
export { type ResolvedSemantic 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 QueryErrorResponse as H, type IndexSchema as I, type QueryRequest as J, QueryRequestSchema as K, type LiveRowsConfig as L, type MutationDefinition as M, type NamedScopeBehaviors as N, type OkCacheEntry as O, type ParamSlot as P, type QueryEngineConfig as Q, type ResolvedQuery as R, type ScopePolicy as S, type QueryResponse as T, REFRESH_MODES as U, type RelationSchema as V, type ResolvedField as W, type ResolvedFilter as X, type ResolvedJoin as Y, type ResolvedMutation as Z, type ResolvedOnConflict as _, type QueryEngine as a, type ResolvedSource as a0, type ReturnedRef as a1, SCOPE_VERBS as a2, type ScopeBehaviors as a3, type ScopeBinding as a4, type ScopeEntityRule as a5, type ScopeMatch as a6, type ScopeRule as a7, type ScopeRules as a8, type ScopeSet as a9, type ScopeValues as aa, type TestResult as ab, type UnsatisfiableCacheEntry as ac, type VexEvent as ad, type VexEventHandler as ae, createScopePolicy as af, isRefresh as ag, mergeScopePolicies as ah, scopeBindings as ai, scopeGrants as aj, scopeProfiles as ak, type AnalysisResult as b, type ContextMeta as c, type DatabaseAdapter as d, type Row as e, type ResolvedExists as f, type QueryErrorCode as g, type CacheBackend as h, type CacheEntry as i, type Refresh as j, type ContextContract as k, type AdapterCapabilities as l, type CoreMutation as m, type ExecuteOptions as n, type GenerationCaller as o, type IntrospectOptions as p, type ItemRef as q, type LiveRowsStats as r, type LookupValue as s, type MapToShape as t, type Mutation as u, type MutationCacheEntry as v, MutationDefinitionSchema as w, MutationSchema as x, type MutationValue as y, type NormalizedType as z };
|