@niscorp/vex 0.2.0 → 0.2.3
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 +161 -0
- package/DESIGN.md +78 -3
- package/DOCS.md +167 -14
- package/README.md +2 -1
- package/dist/adapters/express/index.cjs +241 -19
- package/dist/adapters/express/index.cjs.map +1 -1
- package/dist/adapters/express/index.d.cts +2 -2
- package/dist/adapters/express/index.d.ts +2 -2
- package/dist/adapters/express/index.js +2 -2
- package/dist/adapters/hono/index.cjs +260 -24
- package/dist/adapters/hono/index.cjs.map +1 -1
- package/dist/adapters/hono/index.d.cts +2 -2
- package/dist/adapters/hono/index.d.ts +2 -2
- package/dist/adapters/hono/index.js +21 -7
- package/dist/adapters/hono/index.js.map +1 -1
- package/dist/agent/index.cjs +2 -0
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +1 -1
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-HF25Q53I.js → chunk-H4BHW76Q.js} +6 -3
- package/dist/chunk-H4BHW76Q.js.map +1 -0
- package/dist/{chunk-5CBKESBJ.js → chunk-IQM4SQE2.js} +279 -29
- package/dist/chunk-IQM4SQE2.js.map +1 -0
- package/dist/{handler-Cql8SJ3F.d.cts → handler-BGCL6_Si.d.ts} +3 -2
- package/dist/{handler-mICf9ins.d.ts → handler-CMrjTXNx.d.cts} +3 -2
- package/dist/index.cjs +320 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +45 -37
- package/dist/index.js.map +1 -1
- package/dist/{types-BRvMB6IM.d.cts → types-Bi-Lg86b.d.cts} +48 -2
- package/dist/{types-BRvMB6IM.d.ts → types-Bi-Lg86b.d.ts} +48 -2
- package/package.json +9 -8
- package/dist/chunk-5CBKESBJ.js.map +0 -1
- package/dist/chunk-HF25Q53I.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Q as QueryEngineConfig, a as QueryEngine, b as Query, D as DatabaseSchema, R as ResolvedQuery, A as AnalysisConfig, c as AnalysisResult, C as CompiledQuery, d as ContextMeta, e as DatabaseAdapter, f as Row, F as FieldSchema, P as ParamSlot, g as ResolvedExists, h as FieldOrValue, i as Filter, j as QueryErrorCode, S as ScopePolicy, k as CacheBackend, l as CacheEntry, m as Refresh, M as MutationDefinition, n as ContextContract } from './types-
|
|
2
|
-
export { o as AdapterCapabilities, p as AggregateExpression, q as AggregateExpressionSchema, B as BoundParams, r as ComputeExpression, s as ComputeExpressionSchema, t as ContextRef, u as CoreMutation, E as EntitySchema, v as ExecuteOptions, w as FilterSchema, G as GenerateDsl, x as GenerationCaller, I as IndexSchema, y as IntrospectOptions, z as ItemRef, L as LiveRowsConfig, H as LiveRowsStats, J as LookupValue, K as MapToShape, N as Mutation, O as MutationCacheEntry, T as MutationDefinitionSchema, U as MutationSchema, V as MutationValue, W as NamedScopeBehaviors, X as NormalizedType, Y as OkCacheEntry, Z as QueryErrorResponse, _ as QueryRequest, $ as QueryRequestSchema, a0 as QueryResponse, a1 as QuerySchema, a2 as REFRESH_MODES, a3 as RelationSchema, a4 as ResolvedField, a5 as ResolvedFilter, a6 as ResolvedJoin, a7 as ResolvedMutation, a8 as ResolvedOnConflict, a9 as ResolvedSemantic, aa as ResolvedSource, ab as
|
|
1
|
+
import { Q as QueryEngineConfig, a as QueryEngine, b as Query, D as DatabaseSchema, R as ResolvedQuery, A as AnalysisConfig, c as AnalysisResult, C as CompiledQuery, d as ContextMeta, e as DatabaseAdapter, f as Row, F as FieldSchema, P as ParamSlot, g as ResolvedExists, h as FieldOrValue, i as Filter, j as QueryErrorCode, S as ScopePolicy, k as CacheBackend, l as CacheEntry, m as Refresh, M as MutationDefinition, n as ContextContract } from './types-Bi-Lg86b.cjs';
|
|
2
|
+
export { o as AdapterCapabilities, p as AggregateExpression, q as AggregateExpressionSchema, B as BoundParams, r as ComputeExpression, s as ComputeExpressionSchema, t as ContextRef, u as CoreMutation, E as EntitySchema, v as ExecuteOptions, w as FilterSchema, G as GenerateDsl, x as GenerationCaller, I as IndexSchema, y as IntrospectOptions, z as ItemRef, L as LiveRowsConfig, H as LiveRowsStats, J as LookupValue, K as MapToShape, N as Mutation, O as MutationCacheEntry, T as MutationDefinitionSchema, U as MutationSchema, V as MutationValue, W as NamedScopeBehaviors, X as NormalizedType, Y as OkCacheEntry, Z as QueryErrorResponse, _ as QueryRequest, $ as QueryRequestSchema, a0 as QueryResponse, a1 as QuerySchema, a2 as REFRESH_MODES, a3 as RelationSchema, a4 as ResolvedField, a5 as ResolvedFilter, a6 as ResolvedJoin, a7 as ResolvedMutation, a8 as ResolvedOnConflict, a9 as ResolvedSemantic, aa as ResolvedSource, ab as ReturnedRef, ac as SCOPE_VERBS, ad as ScopeBehaviors, ae as ScopeBinding, af as ScopeEntityRule, ag as ScopeMatch, ah as ScopeRef, ai as ScopeRule, aj as ScopeRules, ak as ScopeSet, al as ScopeValues, am as SortEntry, an as Source, ao as TestResult, ap as UnsatisfiableCacheEntry, aq as VexEvent, ar as VexEventHandler, as as createScopePolicy, at as isRefresh, au as mergeScopePolicies, av as scopeBindings, aw as scopeGrants, ax as scopeProfiles } from './types-Bi-Lg86b.cjs';
|
|
3
3
|
import { P as PgPool } from './introspect-D3OaXHBc.cjs';
|
|
4
4
|
import { Sequence } from '@niscorp/strata';
|
|
5
|
-
export { C as ContextField, a as ContextSignature, D as DiscoveryFingerprint, b as DiscoveryResponse, E as ExecuteRecord, M as MutationClient, c as MutationContext, d as MutationEffect, e as MutationTx, Q as QueryResult, V as VexHandlerConfig, f as VexLive, W as WriteEvent, g as WriteResult, h as collectMutationContext, i as collectQueryContext, j as executeMutation, k as executeWrites, l as handleDiscovery, m as handleFingerprintDelete, n as handleFingerprintPatch, o as handleQuery, p as lintMutation, q as mutationEffect, r as requiredContextKeys, t as tablesChangedBy } from './handler-
|
|
5
|
+
export { C as ContextField, a as ContextSignature, D as DiscoveryFingerprint, b as DiscoveryResponse, E as ExecuteRecord, M as MutationClient, c as MutationContext, d as MutationEffect, e as MutationTx, Q as QueryResult, V as VexHandlerConfig, f as VexLive, W as WriteEvent, g as WriteResult, h as collectMutationContext, i as collectQueryContext, j as executeMutation, k as executeWrites, l as handleDiscovery, m as handleFingerprintDelete, n as handleFingerprintPatch, o as handleQuery, p as lintMutation, q as mutationEffect, r as mutationMisfits, s as requiredContextKeys, t as tablesChangedBy } from './handler-CMrjTXNx.cjs';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import '@niscorp/prism';
|
|
8
8
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Q as QueryEngineConfig, a as QueryEngine, b as Query, D as DatabaseSchema, R as ResolvedQuery, A as AnalysisConfig, c as AnalysisResult, C as CompiledQuery, d as ContextMeta, e as DatabaseAdapter, f as Row, F as FieldSchema, P as ParamSlot, g as ResolvedExists, h as FieldOrValue, i as Filter, j as QueryErrorCode, S as ScopePolicy, k as CacheBackend, l as CacheEntry, m as Refresh, M as MutationDefinition, n as ContextContract } from './types-
|
|
2
|
-
export { o as AdapterCapabilities, p as AggregateExpression, q as AggregateExpressionSchema, B as BoundParams, r as ComputeExpression, s as ComputeExpressionSchema, t as ContextRef, u as CoreMutation, E as EntitySchema, v as ExecuteOptions, w as FilterSchema, G as GenerateDsl, x as GenerationCaller, I as IndexSchema, y as IntrospectOptions, z as ItemRef, L as LiveRowsConfig, H as LiveRowsStats, J as LookupValue, K as MapToShape, N as Mutation, O as MutationCacheEntry, T as MutationDefinitionSchema, U as MutationSchema, V as MutationValue, W as NamedScopeBehaviors, X as NormalizedType, Y as OkCacheEntry, Z as QueryErrorResponse, _ as QueryRequest, $ as QueryRequestSchema, a0 as QueryResponse, a1 as QuerySchema, a2 as REFRESH_MODES, a3 as RelationSchema, a4 as ResolvedField, a5 as ResolvedFilter, a6 as ResolvedJoin, a7 as ResolvedMutation, a8 as ResolvedOnConflict, a9 as ResolvedSemantic, aa as ResolvedSource, ab as
|
|
1
|
+
import { Q as QueryEngineConfig, a as QueryEngine, b as Query, D as DatabaseSchema, R as ResolvedQuery, A as AnalysisConfig, c as AnalysisResult, C as CompiledQuery, d as ContextMeta, e as DatabaseAdapter, f as Row, F as FieldSchema, P as ParamSlot, g as ResolvedExists, h as FieldOrValue, i as Filter, j as QueryErrorCode, S as ScopePolicy, k as CacheBackend, l as CacheEntry, m as Refresh, M as MutationDefinition, n as ContextContract } from './types-Bi-Lg86b.js';
|
|
2
|
+
export { o as AdapterCapabilities, p as AggregateExpression, q as AggregateExpressionSchema, B as BoundParams, r as ComputeExpression, s as ComputeExpressionSchema, t as ContextRef, u as CoreMutation, E as EntitySchema, v as ExecuteOptions, w as FilterSchema, G as GenerateDsl, x as GenerationCaller, I as IndexSchema, y as IntrospectOptions, z as ItemRef, L as LiveRowsConfig, H as LiveRowsStats, J as LookupValue, K as MapToShape, N as Mutation, O as MutationCacheEntry, T as MutationDefinitionSchema, U as MutationSchema, V as MutationValue, W as NamedScopeBehaviors, X as NormalizedType, Y as OkCacheEntry, Z as QueryErrorResponse, _ as QueryRequest, $ as QueryRequestSchema, a0 as QueryResponse, a1 as QuerySchema, a2 as REFRESH_MODES, a3 as RelationSchema, a4 as ResolvedField, a5 as ResolvedFilter, a6 as ResolvedJoin, a7 as ResolvedMutation, a8 as ResolvedOnConflict, a9 as ResolvedSemantic, aa as ResolvedSource, ab as ReturnedRef, ac as SCOPE_VERBS, ad as ScopeBehaviors, ae as ScopeBinding, af as ScopeEntityRule, ag as ScopeMatch, ah as ScopeRef, ai as ScopeRule, aj as ScopeRules, ak as ScopeSet, al as ScopeValues, am as SortEntry, an as Source, ao as TestResult, ap as UnsatisfiableCacheEntry, aq as VexEvent, ar as VexEventHandler, as as createScopePolicy, at as isRefresh, au as mergeScopePolicies, av as scopeBindings, aw as scopeGrants, ax as scopeProfiles } from './types-Bi-Lg86b.js';
|
|
3
3
|
import { P as PgPool } from './introspect-D3OaXHBc.js';
|
|
4
4
|
import { Sequence } from '@niscorp/strata';
|
|
5
|
-
export { C as ContextField, a as ContextSignature, D as DiscoveryFingerprint, b as DiscoveryResponse, E as ExecuteRecord, M as MutationClient, c as MutationContext, d as MutationEffect, e as MutationTx, Q as QueryResult, V as VexHandlerConfig, f as VexLive, W as WriteEvent, g as WriteResult, h as collectMutationContext, i as collectQueryContext, j as executeMutation, k as executeWrites, l as handleDiscovery, m as handleFingerprintDelete, n as handleFingerprintPatch, o as handleQuery, p as lintMutation, q as mutationEffect, r as requiredContextKeys, t as tablesChangedBy } from './handler-
|
|
5
|
+
export { C as ContextField, a as ContextSignature, D as DiscoveryFingerprint, b as DiscoveryResponse, E as ExecuteRecord, M as MutationClient, c as MutationContext, d as MutationEffect, e as MutationTx, Q as QueryResult, V as VexHandlerConfig, f as VexLive, W as WriteEvent, g as WriteResult, h as collectMutationContext, i as collectQueryContext, j as executeMutation, k as executeWrites, l as handleDiscovery, m as handleFingerprintDelete, n as handleFingerprintPatch, o as handleQuery, p as lintMutation, q as mutationEffect, r as mutationMisfits, s as requiredContextKeys, t as tablesChangedBy } from './handler-BGCL6_Si.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import '@niscorp/prism';
|
|
8
8
|
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { MutationDefinitionSchema, lintMutation, computeSchemaFingerprint, pruneOptional, buildValidationContext, requireScope, executeQuery, QueryRequestSchema, computeRequestHash, computePolicyKey, presenceOf, presenceSignature, findMissingContext, buildContextContract, optionalKeysOf, resolveParams, fireAndForget, isSetMatch, refuseOptional, quoteIdent, compileCompute, compileAggregate, compileJoinPairs, compileFilter, checkScope, scopeResolved, mintFingerprint, isEntryFresh, canReadTable, isTouchDue } from './chunk-
|
|
2
|
-
export { MutationDefinitionSchema, MutationSchema, QueryRequestSchema, VexScopeError, applyScope, buildContextContract, buildValidationContext, checkScope, collectMutationContext, collectQueryContext, compileFieldOrValue, compileFilter, computeRequestHash, computeSchemaFingerprint, executeMutation, executeQuery, executeWrites, findMissingContext, handleDiscovery, handleFingerprintDelete, handleFingerprintPatch, handleQuery, lintMutation, mintFingerprint, mutationEffect, normalizeShape, optionalKeysOf, presenceOf, pruneOptional, requiredContextKeys, resolveParams, scopeResolved, sweepCache, tablesChangedBy } from './chunk-
|
|
3
|
-
import { VexError, QuerySchema, isIdentifier, isFieldPathShape } from './chunk-
|
|
4
|
-
export { AggregateExpressionSchema, ComputeExpressionSchema, FilterSchema, QuerySchema, VexError } from './chunk-
|
|
1
|
+
import { MutationDefinitionSchema, lintMutation, computeSchemaFingerprint, pruneOptional, buildValidationContext, requireScope, executeQuery, QueryRequestSchema, computeRequestHash, computePolicyKey, presenceOf, presenceSignature, findMissingContext, buildContextContract, optionalKeysOf, resolveParams, canonicalHash, fireAndForget, isSetMatch, refuseOptional, canonicalText, quoteIdent, compileCompute, compileAggregate, compileJoinPairs, compileFilter, checkScope, scopeResolved, mintFingerprint, isEntryFresh, canReadTable, hashText, isTouchDue } from './chunk-IQM4SQE2.js';
|
|
2
|
+
export { MutationDefinitionSchema, MutationSchema, QueryRequestSchema, VexScopeError, applyScope, buildContextContract, buildValidationContext, checkScope, collectMutationContext, collectQueryContext, compileFieldOrValue, compileFilter, computeRequestHash, computeSchemaFingerprint, executeMutation, executeQuery, executeWrites, findMissingContext, handleDiscovery, handleFingerprintDelete, handleFingerprintPatch, handleQuery, lintMutation, mintFingerprint, mutationEffect, mutationMisfits, normalizeShape, optionalKeysOf, presenceOf, pruneOptional, requiredContextKeys, resolveParams, scopeResolved, sweepCache, tablesChangedBy } from './chunk-IQM4SQE2.js';
|
|
3
|
+
import { VexError, QuerySchema, isIdentifier, isFieldPathShape, isVexError } from './chunk-H4BHW76Q.js';
|
|
4
|
+
export { AggregateExpressionSchema, ComputeExpressionSchema, FilterSchema, QuerySchema, VexError } from './chunk-H4BHW76Q.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import { createHash } from 'crypto';
|
|
7
6
|
import { exceedsDepth, depthRefusal } from '@niscorp/strata';
|
|
8
7
|
import { compile, execute } from '@niscorp/prism';
|
|
9
8
|
import { migrate } from '@niscorp/strata/postgres';
|
|
@@ -865,18 +864,6 @@ var createMemoryCache = () => {
|
|
|
865
864
|
};
|
|
866
865
|
return { get, set, delete: del, clear, keys, entries };
|
|
867
866
|
};
|
|
868
|
-
var canonical = (value) => {
|
|
869
|
-
if (Array.isArray(value)) return value.map(canonical);
|
|
870
|
-
if (value !== null && typeof value === "object" && !(value instanceof Date)) {
|
|
871
|
-
const sorted = {};
|
|
872
|
-
for (const [key, inner] of Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) sorted[key] = canonical(inner);
|
|
873
|
-
return sorted;
|
|
874
|
-
}
|
|
875
|
-
return value;
|
|
876
|
-
};
|
|
877
|
-
var canonicalText = (value) => JSON.stringify(canonical(value)) ?? "undefined";
|
|
878
|
-
var hashText = (text) => createHash("sha256").update(text).digest("hex");
|
|
879
|
-
var canonicalHash = (value) => hashText(canonicalText(value));
|
|
880
867
|
|
|
881
868
|
// src/engine/live.ts
|
|
882
869
|
var DEFAULT_TTL_MS = 6e4;
|
|
@@ -1094,6 +1081,7 @@ var createQueryEngine = (engineConfig) => {
|
|
|
1094
1081
|
const maxNestingDepth = engineConfig.config?.maxNestingDepth ?? DEFAULT_MAX_NESTING_DEPTH;
|
|
1095
1082
|
const defaultLimit = engineConfig.config?.defaultLimit ?? DEFAULT_LIMIT;
|
|
1096
1083
|
const maxLimit = engineConfig.config?.maxLimit ?? DEFAULT_MAX_LIMIT;
|
|
1084
|
+
const capAuthored = engineConfig.config?.capAuthored ?? false;
|
|
1097
1085
|
const rejectCartesianProducts = engineConfig.config?.rejectCartesianProducts ?? true;
|
|
1098
1086
|
const warnUnindexedFilters = engineConfig.config?.warnUnindexedFilters ?? true;
|
|
1099
1087
|
const rejectUnindexedFilters = engineConfig.config?.rejectUnindexedFilters ?? false;
|
|
@@ -1152,13 +1140,16 @@ var createQueryEngine = (engineConfig) => {
|
|
|
1152
1140
|
}
|
|
1153
1141
|
return cachedSchema;
|
|
1154
1142
|
};
|
|
1155
|
-
const runPipeline = (dsl, policyOverride) => {
|
|
1143
|
+
const runPipeline = (dsl, policyOverride, seeded = false) => {
|
|
1156
1144
|
const schema = ensureSchema();
|
|
1157
1145
|
let processedDsl = dsl;
|
|
1146
|
+
let engineLimit;
|
|
1158
1147
|
if (processedDsl.limit === void 0) {
|
|
1159
1148
|
processedDsl = { ...processedDsl, limit: defaultLimit };
|
|
1160
|
-
|
|
1149
|
+
engineLimit = defaultLimit;
|
|
1150
|
+
} else if (processedDsl.limit > maxLimit && (capAuthored || !seeded)) {
|
|
1161
1151
|
processedDsl = { ...processedDsl, limit: maxLimit };
|
|
1152
|
+
engineLimit = maxLimit;
|
|
1162
1153
|
}
|
|
1163
1154
|
const entities = discoverEntities(processedDsl);
|
|
1164
1155
|
const activePolicy = policyOverride ?? scopePolicy;
|
|
@@ -1174,7 +1165,18 @@ var createQueryEngine = (engineConfig) => {
|
|
|
1174
1165
|
);
|
|
1175
1166
|
}
|
|
1176
1167
|
const compiled = adapter.compile(resolved);
|
|
1177
|
-
return { compiled, warnings: analysis.warnings };
|
|
1168
|
+
return { compiled, warnings: analysis.warnings, ...engineLimit !== void 0 ? { engineLimit } : {} };
|
|
1169
|
+
};
|
|
1170
|
+
const cutSaid = /* @__PURE__ */ new Set();
|
|
1171
|
+
const cutNote = (engineLimit, stated, rowCount, shape, fingerprint) => {
|
|
1172
|
+
if (engineLimit === void 0 || rowCount !== engineLimit) return void 0;
|
|
1173
|
+
if (shape !== void 0 && !Array.isArray(shape)) return void 0;
|
|
1174
|
+
const note = stated === void 0 ? `This list states no limit, so it ran with the engine's defaultLimit of ${engineLimit}, and exactly ${engineLimit} rows came back \u2014 it may have been cut. State a \`limit\`.` : `This query asks for ${stated} rows, the engine's maxLimit is ${engineLimit}, and exactly ${engineLimit} came back \u2014 the list may have been cut. Raise \`maxLimit\` to read more.`;
|
|
1175
|
+
if (fingerprint !== void 0 && !cutSaid.has(fingerprint)) {
|
|
1176
|
+
cutSaid.add(fingerprint);
|
|
1177
|
+
console.warn(`[vex] "${fingerprint}": ${note}`);
|
|
1178
|
+
}
|
|
1179
|
+
return note;
|
|
1178
1180
|
};
|
|
1179
1181
|
const compile2 = (dsl) => runPipeline(pruneOptional(dsl, "all")).compiled;
|
|
1180
1182
|
const test = async (dsl, scopeValues) => {
|
|
@@ -1222,6 +1224,7 @@ var createQueryEngine = (engineConfig) => {
|
|
|
1222
1224
|
...entry.intent !== void 0 ? { intent: entry.intent } : {},
|
|
1223
1225
|
...entry.shape !== void 0 ? { shape: entry.shape } : {},
|
|
1224
1226
|
...entry.refresh !== void 0 ? { refresh: entry.refresh } : {},
|
|
1227
|
+
seeded: entry.protected === true && entry.requestHash === void 0,
|
|
1225
1228
|
hit: true,
|
|
1226
1229
|
replaced: false
|
|
1227
1230
|
};
|
|
@@ -1266,7 +1269,7 @@ var createQueryEngine = (engineConfig) => {
|
|
|
1266
1269
|
try {
|
|
1267
1270
|
return await generateDsl(validRequest, agentSchema, callerOf(policy, scope, agentSchema.entities.map((e) => e.name)));
|
|
1268
1271
|
} catch (err) {
|
|
1269
|
-
if (err
|
|
1272
|
+
if (isVexError(err) && err.code === "unsatisfiable") {
|
|
1270
1273
|
const now = Date.now();
|
|
1271
1274
|
await cache.set(negKey, {
|
|
1272
1275
|
kind: "unsatisfiable",
|
|
@@ -1322,7 +1325,7 @@ var createQueryEngine = (engineConfig) => {
|
|
|
1322
1325
|
}
|
|
1323
1326
|
if (mappingMs !== void 0) emit({ type: "query.mapped", mappingMs });
|
|
1324
1327
|
}
|
|
1325
|
-
return { result, executionMs, mappingMs, mappedIr };
|
|
1328
|
+
return { result, rowCount: rows.length, executionMs, mappingMs, mappedIr };
|
|
1326
1329
|
};
|
|
1327
1330
|
const execute$1 = async (request, options) => {
|
|
1328
1331
|
if (exceedsDepth(request)) throw new VexError("invalid_request", `Invalid request: ${depthRefusal()}`);
|
|
@@ -1371,7 +1374,7 @@ var createQueryEngine = (engineConfig) => {
|
|
|
1371
1374
|
}
|
|
1372
1375
|
const presence = presenceOf(validRequest.context);
|
|
1373
1376
|
const shaped = pruneOptional(applySortContext(dsl, validRequest.context), presence);
|
|
1374
|
-
const { compiled, warnings } = runPipeline(shaped, activePolicy);
|
|
1377
|
+
const { compiled, warnings, engineLimit } = runPipeline(shaped, activePolicy, cached.seeded === true);
|
|
1375
1378
|
noteVariant(cached.fingerprint, presenceSignature(dsl, presence), warnings);
|
|
1376
1379
|
emit({ type: "query.sql", sql: compiled.sql, warnings });
|
|
1377
1380
|
requireScope(compiled, scope);
|
|
@@ -1406,14 +1409,18 @@ var createQueryEngine = (engineConfig) => {
|
|
|
1406
1409
|
const executionMs2 = Date.now() - execStart;
|
|
1407
1410
|
emit({ type: "query.rows", count: rows.length, executionMs: executionMs2 });
|
|
1408
1411
|
const result2 = shapeRows(rows);
|
|
1409
|
-
const
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1412
|
+
const metaOf = (rowCount2) => {
|
|
1413
|
+
const cut2 = cutNote(engineLimit, shaped.limit, rowCount2, shape, validRequest.fingerprint);
|
|
1414
|
+
const said2 = cut2 === void 0 ? warnings : [...warnings, cut2];
|
|
1415
|
+
return {
|
|
1416
|
+
cache: {
|
|
1417
|
+
hit: cached.hit,
|
|
1418
|
+
fingerprint: cached.fingerprint,
|
|
1419
|
+
intent: cached.intent ?? validRequest.intent
|
|
1420
|
+
},
|
|
1421
|
+
context: buildContextContract(compiled, optionalKeysOf(dsl)),
|
|
1422
|
+
warnings: said2.length > 0 ? said2 : void 0
|
|
1423
|
+
};
|
|
1417
1424
|
};
|
|
1418
1425
|
const { signal, onChange } = options ?? {};
|
|
1419
1426
|
if (signal !== void 0 && onChange !== void 0) {
|
|
@@ -1424,20 +1431,22 @@ var createQueryEngine = (engineConfig) => {
|
|
|
1424
1431
|
const nextHash = canonicalHash(nextResult);
|
|
1425
1432
|
if (nextHash === lastHash) return;
|
|
1426
1433
|
lastHash = nextHash;
|
|
1427
|
-
onChange({ result: nextResult, meta });
|
|
1434
|
+
onChange({ result: nextResult, meta: metaOf(next.length) });
|
|
1428
1435
|
}
|
|
1429
1436
|
}, signal);
|
|
1430
1437
|
}
|
|
1431
1438
|
emit({ type: "query.done", totalMs: Date.now() - t0 });
|
|
1432
|
-
return { result: result2, meta: { ...
|
|
1439
|
+
return { result: result2, meta: { ...metaOf(rows.length), timing: { executionMs: executionMs2 } } };
|
|
1433
1440
|
}
|
|
1434
|
-
const { result, executionMs, mappingMs, mappedIr } = await executeAndMap(
|
|
1441
|
+
const { result, rowCount, executionMs, mappingMs, mappedIr } = await executeAndMap(
|
|
1435
1442
|
compiled,
|
|
1436
1443
|
effectiveRequest,
|
|
1437
1444
|
cached.cachedIr,
|
|
1438
1445
|
context,
|
|
1439
1446
|
scope
|
|
1440
1447
|
);
|
|
1448
|
+
const cut = cutNote(engineLimit, shaped.limit, rowCount, effectiveRequest.shape, validRequest.fingerprint);
|
|
1449
|
+
const said = cut === void 0 ? warnings : [...warnings, cut];
|
|
1441
1450
|
if (!cached.hit) {
|
|
1442
1451
|
const now = Date.now();
|
|
1443
1452
|
const entry = {
|
|
@@ -1469,7 +1478,7 @@ var createQueryEngine = (engineConfig) => {
|
|
|
1469
1478
|
executionMs,
|
|
1470
1479
|
...mappingMs !== void 0 ? { mappingMs } : {}
|
|
1471
1480
|
},
|
|
1472
|
-
warnings:
|
|
1481
|
+
warnings: said.length > 0 ? said : void 0
|
|
1473
1482
|
}
|
|
1474
1483
|
};
|
|
1475
1484
|
};
|
|
@@ -1959,9 +1968,8 @@ var createPostgresAdapter = (config) => {
|
|
|
1959
1968
|
return enforcement;
|
|
1960
1969
|
};
|
|
1961
1970
|
const execute = async (query, params) => {
|
|
1962
|
-
const { transaction } = pool;
|
|
1963
1971
|
const limit = perStatementMs;
|
|
1964
|
-
const result = limit === void 0 || transaction === void 0 ? await pool.query(query.sql, params) : await transaction(async (tx) => {
|
|
1972
|
+
const result = limit === void 0 || pool.transaction === void 0 ? await pool.query(query.sql, params) : await pool.transaction(async (tx) => {
|
|
1965
1973
|
await tx.query(`SET LOCAL statement_timeout = ${limit}`);
|
|
1966
1974
|
return tx.query(query.sql, params);
|
|
1967
1975
|
});
|