@niscorp/vex 0.2.2 → 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.
Files changed (36) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/DESIGN.md +66 -3
  3. package/DOCS.md +156 -12
  4. package/dist/adapters/express/index.cjs +102 -17
  5. package/dist/adapters/express/index.cjs.map +1 -1
  6. package/dist/adapters/express/index.d.cts +2 -2
  7. package/dist/adapters/express/index.d.ts +2 -2
  8. package/dist/adapters/express/index.js +2 -2
  9. package/dist/adapters/hono/index.cjs +121 -22
  10. package/dist/adapters/hono/index.cjs.map +1 -1
  11. package/dist/adapters/hono/index.d.cts +2 -2
  12. package/dist/adapters/hono/index.d.ts +2 -2
  13. package/dist/adapters/hono/index.js +21 -7
  14. package/dist/adapters/hono/index.js.map +1 -1
  15. package/dist/agent/index.cjs +2 -0
  16. package/dist/agent/index.cjs.map +1 -1
  17. package/dist/agent/index.d.cts +1 -1
  18. package/dist/agent/index.d.ts +1 -1
  19. package/dist/agent/index.js +1 -1
  20. package/dist/{chunk-HF25Q53I.js → chunk-H4BHW76Q.js} +6 -3
  21. package/dist/chunk-H4BHW76Q.js.map +1 -0
  22. package/dist/{chunk-HCEH55PP.js → chunk-IQM4SQE2.js} +123 -21
  23. package/dist/chunk-IQM4SQE2.js.map +1 -0
  24. package/dist/{handler-Cql8SJ3F.d.cts → handler-BGCL6_Si.d.ts} +3 -2
  25. package/dist/{handler-mICf9ins.d.ts → handler-CMrjTXNx.d.cts} +3 -2
  26. package/dist/index.cjs +163 -35
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +3 -3
  29. package/dist/index.d.ts +3 -3
  30. package/dist/index.js +44 -22
  31. package/dist/index.js.map +1 -1
  32. package/dist/{types-BRvMB6IM.d.cts → types-Bi-Lg86b.d.cts} +48 -2
  33. package/dist/{types-BRvMB6IM.d.ts → types-Bi-Lg86b.d.ts} +48 -2
  34. package/package.json +5 -5
  35. package/dist/chunk-HCEH55PP.js.map +0 -1
  36. 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-BRvMB6IM.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 SCOPE_VERBS, ac as ScopeBehaviors, ad as ScopeBinding, ae as ScopeEntityRule, af as ScopeMatch, ag as ScopeRef, ah as ScopeRule, ai as ScopeRules, aj as ScopeSet, ak as ScopeValues, al as SortEntry, am as Source, an as TestResult, ao as UnsatisfiableCacheEntry, ap as VexEvent, aq as VexEventHandler, ar as createScopePolicy, as as isRefresh, at as mergeScopePolicies, au as scopeBindings, av as scopeGrants, aw as scopeProfiles } from './types-BRvMB6IM.cjs';
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-Cql8SJ3F.cjs';
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-BRvMB6IM.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 SCOPE_VERBS, ac as ScopeBehaviors, ad as ScopeBinding, ae as ScopeEntityRule, af as ScopeMatch, ag as ScopeRef, ah as ScopeRule, ai as ScopeRules, aj as ScopeSet, ak as ScopeValues, al as SortEntry, am as Source, an as TestResult, ao as UnsatisfiableCacheEntry, ap as VexEvent, aq as VexEventHandler, ar as createScopePolicy, as as isRefresh, at as mergeScopePolicies, au as scopeBindings, av as scopeGrants, aw as scopeProfiles } from './types-BRvMB6IM.js';
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-mICf9ins.js';
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,7 +1,7 @@
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-HCEH55PP.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, normalizeShape, optionalKeysOf, presenceOf, pruneOptional, requiredContextKeys, resolveParams, scopeResolved, sweepCache, tablesChangedBy } from './chunk-HCEH55PP.js';
3
- import { VexError, QuerySchema, isIdentifier, isFieldPathShape } from './chunk-HF25Q53I.js';
4
- export { AggregateExpressionSchema, ComputeExpressionSchema, FilterSchema, QuerySchema, VexError } from './chunk-HF25Q53I.js';
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
6
  import { exceedsDepth, depthRefusal } from '@niscorp/strata';
7
7
  import { compile, execute } from '@niscorp/prism';
@@ -1081,6 +1081,7 @@ var createQueryEngine = (engineConfig) => {
1081
1081
  const maxNestingDepth = engineConfig.config?.maxNestingDepth ?? DEFAULT_MAX_NESTING_DEPTH;
1082
1082
  const defaultLimit = engineConfig.config?.defaultLimit ?? DEFAULT_LIMIT;
1083
1083
  const maxLimit = engineConfig.config?.maxLimit ?? DEFAULT_MAX_LIMIT;
1084
+ const capAuthored = engineConfig.config?.capAuthored ?? false;
1084
1085
  const rejectCartesianProducts = engineConfig.config?.rejectCartesianProducts ?? true;
1085
1086
  const warnUnindexedFilters = engineConfig.config?.warnUnindexedFilters ?? true;
1086
1087
  const rejectUnindexedFilters = engineConfig.config?.rejectUnindexedFilters ?? false;
@@ -1139,13 +1140,16 @@ var createQueryEngine = (engineConfig) => {
1139
1140
  }
1140
1141
  return cachedSchema;
1141
1142
  };
1142
- const runPipeline = (dsl, policyOverride) => {
1143
+ const runPipeline = (dsl, policyOverride, seeded = false) => {
1143
1144
  const schema = ensureSchema();
1144
1145
  let processedDsl = dsl;
1146
+ let engineLimit;
1145
1147
  if (processedDsl.limit === void 0) {
1146
1148
  processedDsl = { ...processedDsl, limit: defaultLimit };
1147
- } else if (processedDsl.limit > maxLimit) {
1149
+ engineLimit = defaultLimit;
1150
+ } else if (processedDsl.limit > maxLimit && (capAuthored || !seeded)) {
1148
1151
  processedDsl = { ...processedDsl, limit: maxLimit };
1152
+ engineLimit = maxLimit;
1149
1153
  }
1150
1154
  const entities = discoverEntities(processedDsl);
1151
1155
  const activePolicy = policyOverride ?? scopePolicy;
@@ -1161,7 +1165,18 @@ var createQueryEngine = (engineConfig) => {
1161
1165
  );
1162
1166
  }
1163
1167
  const compiled = adapter.compile(resolved);
1164
- 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;
1165
1180
  };
1166
1181
  const compile2 = (dsl) => runPipeline(pruneOptional(dsl, "all")).compiled;
1167
1182
  const test = async (dsl, scopeValues) => {
@@ -1209,6 +1224,7 @@ var createQueryEngine = (engineConfig) => {
1209
1224
  ...entry.intent !== void 0 ? { intent: entry.intent } : {},
1210
1225
  ...entry.shape !== void 0 ? { shape: entry.shape } : {},
1211
1226
  ...entry.refresh !== void 0 ? { refresh: entry.refresh } : {},
1227
+ seeded: entry.protected === true && entry.requestHash === void 0,
1212
1228
  hit: true,
1213
1229
  replaced: false
1214
1230
  };
@@ -1253,7 +1269,7 @@ var createQueryEngine = (engineConfig) => {
1253
1269
  try {
1254
1270
  return await generateDsl(validRequest, agentSchema, callerOf(policy, scope, agentSchema.entities.map((e) => e.name)));
1255
1271
  } catch (err) {
1256
- if (err instanceof VexError && err.code === "unsatisfiable") {
1272
+ if (isVexError(err) && err.code === "unsatisfiable") {
1257
1273
  const now = Date.now();
1258
1274
  await cache.set(negKey, {
1259
1275
  kind: "unsatisfiable",
@@ -1309,7 +1325,7 @@ var createQueryEngine = (engineConfig) => {
1309
1325
  }
1310
1326
  if (mappingMs !== void 0) emit({ type: "query.mapped", mappingMs });
1311
1327
  }
1312
- return { result, executionMs, mappingMs, mappedIr };
1328
+ return { result, rowCount: rows.length, executionMs, mappingMs, mappedIr };
1313
1329
  };
1314
1330
  const execute$1 = async (request, options) => {
1315
1331
  if (exceedsDepth(request)) throw new VexError("invalid_request", `Invalid request: ${depthRefusal()}`);
@@ -1358,7 +1374,7 @@ var createQueryEngine = (engineConfig) => {
1358
1374
  }
1359
1375
  const presence = presenceOf(validRequest.context);
1360
1376
  const shaped = pruneOptional(applySortContext(dsl, validRequest.context), presence);
1361
- const { compiled, warnings } = runPipeline(shaped, activePolicy);
1377
+ const { compiled, warnings, engineLimit } = runPipeline(shaped, activePolicy, cached.seeded === true);
1362
1378
  noteVariant(cached.fingerprint, presenceSignature(dsl, presence), warnings);
1363
1379
  emit({ type: "query.sql", sql: compiled.sql, warnings });
1364
1380
  requireScope(compiled, scope);
@@ -1393,14 +1409,18 @@ var createQueryEngine = (engineConfig) => {
1393
1409
  const executionMs2 = Date.now() - execStart;
1394
1410
  emit({ type: "query.rows", count: rows.length, executionMs: executionMs2 });
1395
1411
  const result2 = shapeRows(rows);
1396
- const meta = {
1397
- cache: {
1398
- hit: cached.hit,
1399
- fingerprint: cached.fingerprint,
1400
- intent: cached.intent ?? validRequest.intent
1401
- },
1402
- context: buildContextContract(compiled, optionalKeysOf(dsl)),
1403
- warnings: warnings.length > 0 ? warnings : void 0
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
+ };
1404
1424
  };
1405
1425
  const { signal, onChange } = options ?? {};
1406
1426
  if (signal !== void 0 && onChange !== void 0) {
@@ -1411,20 +1431,22 @@ var createQueryEngine = (engineConfig) => {
1411
1431
  const nextHash = canonicalHash(nextResult);
1412
1432
  if (nextHash === lastHash) return;
1413
1433
  lastHash = nextHash;
1414
- onChange({ result: nextResult, meta });
1434
+ onChange({ result: nextResult, meta: metaOf(next.length) });
1415
1435
  }
1416
1436
  }, signal);
1417
1437
  }
1418
1438
  emit({ type: "query.done", totalMs: Date.now() - t0 });
1419
- return { result: result2, meta: { ...meta, timing: { executionMs: executionMs2 } } };
1439
+ return { result: result2, meta: { ...metaOf(rows.length), timing: { executionMs: executionMs2 } } };
1420
1440
  }
1421
- const { result, executionMs, mappingMs, mappedIr } = await executeAndMap(
1441
+ const { result, rowCount, executionMs, mappingMs, mappedIr } = await executeAndMap(
1422
1442
  compiled,
1423
1443
  effectiveRequest,
1424
1444
  cached.cachedIr,
1425
1445
  context,
1426
1446
  scope
1427
1447
  );
1448
+ const cut = cutNote(engineLimit, shaped.limit, rowCount, effectiveRequest.shape, validRequest.fingerprint);
1449
+ const said = cut === void 0 ? warnings : [...warnings, cut];
1428
1450
  if (!cached.hit) {
1429
1451
  const now = Date.now();
1430
1452
  const entry = {
@@ -1456,7 +1478,7 @@ var createQueryEngine = (engineConfig) => {
1456
1478
  executionMs,
1457
1479
  ...mappingMs !== void 0 ? { mappingMs } : {}
1458
1480
  },
1459
- warnings: warnings.length > 0 ? warnings : void 0
1481
+ warnings: said.length > 0 ? said : void 0
1460
1482
  }
1461
1483
  };
1462
1484
  };