@niscorp/vex 0.4.4 → 0.5.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/DESIGN.md +72 -45
  3. package/DOCS.md +219 -21
  4. package/README.md +18 -0
  5. package/dist/adapters/express/index.cjs +606 -173
  6. package/dist/adapters/express/index.cjs.map +1 -1
  7. package/dist/adapters/express/index.d.cts +6 -2
  8. package/dist/adapters/express/index.d.ts +6 -2
  9. package/dist/adapters/express/index.js +16 -3
  10. package/dist/adapters/express/index.js.map +1 -1
  11. package/dist/adapters/hono/index.cjs +597 -173
  12. package/dist/adapters/hono/index.cjs.map +1 -1
  13. package/dist/adapters/hono/index.d.cts +5 -2
  14. package/dist/adapters/hono/index.d.ts +5 -2
  15. package/dist/adapters/hono/index.js +7 -3
  16. package/dist/adapters/hono/index.js.map +1 -1
  17. package/dist/agent/index.cjs +12 -12
  18. package/dist/agent/index.cjs.map +1 -1
  19. package/dist/agent/index.d.cts +1 -1
  20. package/dist/agent/index.d.ts +1 -1
  21. package/dist/agent/index.js +12 -12
  22. package/dist/agent/index.js.map +1 -1
  23. package/dist/{chunk-W5MYFJKT.js → chunk-F7OXXJIH.js} +562 -192
  24. package/dist/chunk-F7OXXJIH.js.map +1 -0
  25. package/dist/{chunk-F7RDSWYF.js → chunk-VHNCSQPO.js} +2 -2
  26. package/dist/{chunk-F7RDSWYF.js.map → chunk-VHNCSQPO.js.map} +1 -1
  27. package/dist/{handler-CoJxInw-.d.ts → handler-DdfaWN_J.d.ts} +7 -1
  28. package/dist/{handler-CsFbanZA.d.cts → handler-kvZkxwaN.d.cts} +7 -1
  29. package/dist/index.cjs +667 -259
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +5 -3
  32. package/dist/index.d.ts +5 -3
  33. package/dist/index.js +290 -248
  34. package/dist/index.js.map +1 -1
  35. package/dist/migrations/index.cjs.map +1 -1
  36. package/dist/migrations/index.js +1 -1
  37. package/dist/{types-B2HEmyNq.d.cts → types-BxkRxTTx.d.cts} +38 -2
  38. package/dist/{types-DC68ZUuq.d.ts → types-DgUZNKii.d.ts} +38 -2
  39. package/package.json +8 -8
  40. package/dist/chunk-W5MYFJKT.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cache/cache.types.ts","../../src/schemas/value.schema.ts","../../src/schemas/identifier.schema.ts","../../src/schemas/filter.schema.ts","../../src/schemas/compute.schema.ts","../../src/schemas/aggregate.schema.ts","../../src/schemas/query.schema.ts","../../src/migrations/index.ts"],"names":["z"],"mappings":";;;;;;;AAMO,IAAM,aAAA,GAAgB,CAAC,UAAA,EAAY,UAAU,CAAA;ACJ7C,IAAM,gBAAA,GAAmBA,MAC7B,MAAA,CAAO;AAAA,EACN,QAAA,EAAUA,KAAA,CAAE,MAAA,EAAO,CAAE,SAAS,8CAA8C;AAC9E,CAAC,CAAA,CACA,MAAA,EAAO,CACP,QAAA,CAAS,8CAA8C,CAAA;AAEnD,IAAM,cAAA,GAAiBA,MAC3B,MAAA,CAAO;AAAA,EACN,MAAA,EAAQA,KAAA,CAAE,MAAA,EAAO,CAAE,SAAS,gDAAgD;AAC9E,CAAC,CAAA,CACA,MAAA,EAAO,CACP,QAAA,CAAS,6DAA6D,CAAA;AAElE,IAAM,kBAAA,GAAqBA,MAC/B,KAAA,CAAM;AAAA,EACLA,KAAA,CAAE,MAAA,EAAO,CAAE,QAAA,CAAS,wDAAwD,CAAA;AAAA,EAC5EA,KAAA,CAAE,MAAA,EAAO,CAAE,QAAA,CAAS,kBAAkB,CAAA;AAAA,EACtCA,KAAA,CAAE,OAAA,EAAQ,CAAE,QAAA,CAAS,mBAAmB,CAAA;AAAA,EACxCA,KAAA,CAAE,IAAA,EAAK,CAAE,QAAA,CAAS,gBAAgB,CAAA;AAAA,EAClC,gBAAA;AAAA,EACA;AACF,CAAC,CAAA,CACA,SAAS,mDAAmD,CAAA;ACnB/D,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,SAAA,EAAW,EAAE,KAAA,EAAO,EAAE,QAAQ,EAAE,OAAA,EAAS,mBAAA,EAAoB,EAAE,EAAE;AAAA,EACjE,YAAY;AACd;AAIO,IAAM,WAAA,GAAc;AAAA,EACzB,gBAAA,EAAkBA,MACf,MAAA,CAAO;AAAA,IACN,GAAA,EAAK,WAAA;AAAA,IACL,OAAA,EAASA,KAAAA,CAAE,OAAA,EAAQ,CAAE,QAAA,EAAS;AAAA,IAC9B,KAAA,EAAOA,KAAAA,CAAE,OAAA,EAAQ,CAAE,QAAA,EAAS;AAAA,IAC5B,MAAA,EAAQA,KAAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,IAC5B,KAAA,EAAOA,KAAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,IAC3B,OAAA,EAASA,KAAAA,CAAE,IAAA,CAAK,aAAa,EAAE,QAAA;AAAS,GACzC,EACA,MAAA;AACL","file":"index.cjs","sourcesContent":["import type { Query } from '../schemas/query.schema.js';\nimport type { CompiledIr } from '@niscorp/prism';\nimport type { MutationDefinition } from '../mutations/schema.js';\nimport type { Sequence } from '@niscorp/strata';\nimport type { ScopeValues } from '../scope/scope.types.js';\n\nexport const REFRESH_MODES = ['snapshot', 'reactive'] as const;\nexport type Refresh = (typeof REFRESH_MODES)[number];\n\nexport const isRefresh = (value: unknown): value is Refresh => REFRESH_MODES.some((mode) => mode === value);\n\ntype CacheEntryMeta = {\n createdAt: number;\n lastUsedAt?: number;\n expiresAt?: number;\n protected?: boolean;\n requestHash?: string;\n schemaFingerprint?: string;\n intent?: string;\n shape?: unknown;\n};\n\nexport type OkCacheEntry = CacheEntryMeta & {\n kind: 'ok';\n dsl: Query;\n prismIr?: CompiledIr;\n // The prism config `prismIr` was compiled from, where vex wrote the mapping.\n mapping?: unknown;\n /**\n * The scope profile this read is served at, whatever the caller's roles say:\n * roles merge to the widest reach any of them grants, which is wrong for a\n * read that means \"mine\". A reach the host cannot compile refuses the read.\n */\n reach?: string;\n refresh?: Refresh;\n};\n\nexport type UnsatisfiableCacheEntry = CacheEntryMeta & {\n kind: 'unsatisfiable';\n reason: string;\n};\n\nexport type MutationCacheEntry = CacheEntryMeta & {\n kind: 'mutation';\n mutation: MutationDefinition;\n reach?: string;\n};\n\nexport type CacheEntry = OkCacheEntry | UnsatisfiableCacheEntry | MutationCacheEntry;\n\nexport type CacheBackend = {\n // `scope`: whose request asks, for a cache that answers an entry to some callers and not to others.\n get: (key: string, scope?: ScopeValues) => Promise<CacheEntry | undefined>;\n set: (key: string, entry: CacheEntry) => Promise<void>;\n delete: (key: string) => Promise<void>;\n clear: () => Promise<void>;\n keys: () => Promise<string[]>;\n init?: () => Promise<void>;\n sequence?: Sequence;\n entries?: () => Promise<Array<{ key: string; entry: CacheEntry }>>;\n};\n","import { z } from 'zod';\n\nexport const ContextRefSchema = z\n .object({\n $context: z.string().describe('Key to look up in the request context object'),\n })\n .strict()\n .describe('Reference to a caller-provided context value');\n\nexport const ScopeRefSchema = z\n .object({\n $scope: z.string().describe('Key to look up in the server-side scope values'),\n })\n .strict()\n .describe('Reference to a server-injected scope value (access control)');\n\nexport const FieldOrValueSchema = z\n .union([\n z.string().describe('A field path (entity.field format) or a literal string'),\n z.number().describe('A literal number'),\n z.boolean().describe('A literal boolean'),\n z.null().describe('A literal null'),\n ContextRefSchema,\n ScopeRefSchema,\n ])\n .describe('A field path, literal value, or dynamic reference');\n\nexport type ContextRef = z.infer<typeof ContextRefSchema>;\nexport type ScopeRef = z.infer<typeof ScopeRefSchema>;\nexport type FieldOrValue = z.infer<typeof FieldOrValueSchema>;\n","import { z } from 'zod';\n\n// A name is the only authored text that reaches SQL as text (values bind as\n// parameters or are quoted as literals), so it is held to this grammar. In a\n// value position, `isFieldPathShape` decides whether a string is a column or\n// a literal.\nconst IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;\nconst FIELD_PATH = /^[A-Za-z_][A-Za-z0-9_]*\\.[A-Za-z_][A-Za-z0-9_]*$/;\n\nexport const isIdentifier = (value: string): boolean => IDENTIFIER.test(value);\n\nexport const isFieldPathShape = (value: unknown): value is string => typeof value === 'string' && FIELD_PATH.test(value);\n\nexport const IdentifierSchema = z\n .string()\n .regex(IDENTIFIER, 'A name is letters, digits and underscores, not starting with a digit');\n\nexport const FieldPathSchema = z\n .string()\n .regex(FIELD_PATH, 'A field path is entity.field — each part letters, digits and underscores, not starting with a digit');\n","import { z } from 'zod';\nimport { ContextRefSchema, ScopeRefSchema, FieldOrValueSchema } from './value.schema.js';\nimport { FieldPathSchema } from './identifier.schema.js';\nimport type { ContextRef, ScopeRef, FieldOrValue } from './value.schema.js';\n\nexport type ExistsQuery = {\n from: string[];\n filter?: Filter;\n};\n\nexport type Filter =\n | { exists: ExistsQuery }\n | { eq: [FieldOrValue, FieldOrValue] }\n | { neq: [FieldOrValue, FieldOrValue] }\n | { gt: [FieldOrValue, FieldOrValue] }\n | { gte: [FieldOrValue, FieldOrValue] }\n | { lt: [FieldOrValue, FieldOrValue] }\n | { lte: [FieldOrValue, FieldOrValue] }\n | { in: [string, FieldOrValue[] | ContextRef | ScopeRef] }\n | { notIn: [string, FieldOrValue[] | ContextRef | ScopeRef] }\n | { like: [string, FieldOrValue] }\n | { ilike: [string, FieldOrValue] }\n | { isNull: string }\n | { isNotNull: string }\n | { and: Filter[] }\n | { or: Filter[] }\n | { not: Filter }\n | { semantic: { field: string; query: ContextRef | ScopeRef; minScore?: number } }\n | { fuzzy: { field: string; query: ContextRef | ScopeRef; maxDistance?: number } }\n | { optional: { key: string | string[]; then: Filter } };\n\nconst comparisonPair = z\n .tuple([FieldOrValueSchema, FieldOrValueSchema])\n .describe('[left, right] — both can be field paths, literals, or references');\n\nconst fieldString = FieldPathSchema.describe('Field path in entity.field format');\n\nconst collectionTarget = z\n .union([\n z.array(FieldOrValueSchema).min(1).describe('Array of literal values or references'),\n ContextRefSchema,\n ScopeRefSchema,\n ])\n .describe('A set of values or a reference that resolves to an array');\n\nconst ExistsSchema: z.ZodType<ExistsQuery> = z.lazy(() =>\n z\n .object({\n from: z.array(z.string()).min(1).describe('Entities the subquery reads. Joined by foreign key like any other from.'),\n filter: FilterSchema.optional().describe('The correlation, and any extra condition. Reference the outer query by its own entity path: { eq: [\"<inner>.<fk>\", \"<outer>.id\"] }.'),\n })\n .strict(),\n);\n\nexport const FilterSchema: z.ZodType<Filter> = z.lazy(() =>\n z.union([\n z.object({ exists: ExistsSchema }).strict().describe('EXISTS: true when the subquery matches at least one row. Wrap in `not` for NOT EXISTS.'),\n z.object({ eq: comparisonPair }).strict().describe('Equals: tests equality between two values'),\n z.object({ neq: comparisonPair }).strict().describe('Not equals'),\n z.object({ gt: comparisonPair }).strict().describe('Greater than'),\n z.object({ gte: comparisonPair }).strict().describe('Greater than or equal'),\n z.object({ lt: comparisonPair }).strict().describe('Less than'),\n z.object({ lte: comparisonPair }).strict().describe('Less than or equal'),\n z.object({ in: z.tuple([fieldString, collectionTarget]) }).strict().describe('Field value is in a set'),\n z.object({ notIn: z.tuple([fieldString, collectionTarget]) }).strict().describe('Field value is not in a set'),\n z.object({ like: z.tuple([fieldString, FieldOrValueSchema]) }).strict().describe('Case-sensitive LIKE pattern match (use % as wildcard)'),\n z.object({ ilike: z.tuple([fieldString, FieldOrValueSchema]) }).strict().describe('Case-insensitive ILIKE pattern match (use % as wildcard)'),\n z.object({ isNull: fieldString }).strict().describe('Field value is NULL'),\n z.object({ isNotNull: fieldString }).strict().describe('Field value is NOT NULL'),\n z.object({ and: z.array(FilterSchema).min(2) }).strict().describe('Logical AND: all conditions must be true'),\n z.object({ or: z.array(FilterSchema).min(2) }).strict().describe('Logical OR: at least one condition must be true'),\n z.object({ not: FilterSchema }).strict().describe('Logical NOT: negates the condition'),\n z.object({\n semantic: z.object({\n field: FieldPathSchema.describe('Vector column field path (entity.field)'),\n query: z.union([ContextRefSchema, ScopeRefSchema]).describe('Text to embed and compare'),\n minScore: z.number().min(0).max(1).optional().describe('Minimum cosine similarity (0–1)'),\n }).strict(),\n }).strict().describe('Semantic vector similarity search'),\n z.object({\n fuzzy: z.object({\n field: FieldPathSchema.describe('String field path'),\n query: z.union([ContextRefSchema, ScopeRefSchema]).describe('Text to fuzzy-match'),\n maxDistance: z.number().int().nonnegative().optional().describe('Maximum Levenshtein edit distance'),\n }).strict(),\n }).strict().describe('Fuzzy string match'),\n z.object({\n optional: z.object({\n key: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)])\n .describe('The context key this condition depends on, or EVERY key it depends on. A condition referencing two keys must name both — gating on one leaves the other conditionally required, which surfaces as an empty result rather than as a condition that did not apply.'),\n // Bare, never `.describe()`d: that call clones the schema, and zod's\n // to-json-schema detects recursion by instance identity, so a clone\n // expands the filter union into itself until the stack overflows.\n then: FilterSchema,\n }).strict(),\n }).strict().describe(\n 'A condition the caller turns on by supplying context keys. When any named key is absent the condition is REMOVED from the query before it compiles — it does not match everything, it is not there. Absent means missing, undefined or null; \"\" is a value and keeps the condition. Direction follows position: under `and` supplying the key NARROWS, under `or` it WIDENS. Either way an absent key reads exactly as if the condition had never been written, and scope is injected afterwards regardless. Reads only: a mutation may not contain one, and neither may the inside of an `exists` (its correlation must be unconditional).',\n ),\n ]),\n);\n","import { z } from 'zod';\nimport { FieldOrValueSchema } from './value.schema.js';\nimport { FilterSchema } from './filter.schema.js';\n\nconst CaseWhenSchema = z\n .object({\n condition: FilterSchema,\n then: FieldOrValueSchema.describe('Value when condition is true'),\n })\n .strict();\n\nexport const ComputeExpressionSchema = z\n .union([\n z.object({ add: z.tuple([FieldOrValueSchema, FieldOrValueSchema]) }).strict().describe('Addition: a + b'),\n z.object({ subtract: z.tuple([FieldOrValueSchema, FieldOrValueSchema]) }).strict().describe('Subtraction: a - b'),\n z.object({ multiply: z.tuple([FieldOrValueSchema, FieldOrValueSchema]) }).strict().describe('Multiplication: a * b'),\n z.object({ divide: z.tuple([FieldOrValueSchema, FieldOrValueSchema]) }).strict().describe('Division: a / b'),\n z.object({ concat: z.array(FieldOrValueSchema).min(2) }).strict().describe('String concatenation'),\n z.object({ coalesce: z.array(FieldOrValueSchema).min(2) }).strict().describe('Returns first non-null value'),\n z.object({\n case: z\n .object({\n when: z.array(CaseWhenSchema).min(1).describe('Condition/result pairs evaluated in order'),\n else: FieldOrValueSchema.describe('Default value when no condition matches'),\n })\n .strict(),\n }).strict().describe('CASE WHEN conditional expression'),\n ])\n .describe('Computed expression: arithmetic, string, or conditional');\n\nexport type ComputeExpression = z.infer<typeof ComputeExpressionSchema>;\n","import { z } from 'zod';\nimport { ComputeExpressionSchema } from './compute.schema.js';\nimport { FieldPathSchema } from './identifier.schema.js';\n\nconst fieldPath = FieldPathSchema.describe('Field path in entity.field format');\n\nconst fieldOrExpr = z.union([fieldPath, ComputeExpressionSchema]).describe('A field path or a compute expression');\n\nexport const AggregateExpressionSchema = z\n .union([\n z.object({ count: z.union([FieldPathSchema, z.literal('*')]).describe('Field path or \"*\" for COUNT(*)') }).strict().describe('COUNT'),\n z.object({ countDistinct: FieldPathSchema.describe('Field path whose distinct non-null values are counted') }).strict().describe('COUNT(DISTINCT field)'),\n z.object({ sum: fieldOrExpr }).strict().describe('SUM'),\n z.object({ avg: fieldOrExpr }).strict().describe('AVG'),\n z.object({ min: fieldOrExpr }).strict().describe('MIN'),\n z.object({ max: fieldOrExpr }).strict().describe('MAX'),\n ])\n .describe('Aggregate function applied to a field or expression');\n\nexport type AggregateExpression = z.infer<typeof AggregateExpressionSchema>;\n","import { z } from 'zod';\nimport { FilterSchema } from './filter.schema.js';\nimport { ComputeExpressionSchema } from './compute.schema.js';\nimport { AggregateExpressionSchema } from './aggregate.schema.js';\nimport { FieldPathSchema, IdentifierSchema } from './identifier.schema.js';\nimport type { Filter } from './filter.schema.js';\nimport type { ComputeExpression } from './compute.schema.js';\nimport type { AggregateExpression } from './aggregate.schema.js';\n\nexport const SortEntrySchema = z\n .object({\n field: z.union([FieldPathSchema, IdentifierSchema]).describe('Field path (entity.field), computed field name, or aggregate alias'),\n dir: z.enum(['asc', 'desc']).default('asc').describe('Sort direction'),\n })\n .strict()\n .describe('Sort specification');\n\nexport type SortEntry = z.infer<typeof SortEntrySchema>;\n\nexport type Source = string | { as: string; query: Query };\n\nexport type FieldRef = string | { field: string; as: string };\n\nexport type Query = {\n from: Source[];\n fields?: FieldRef[];\n filter?: Filter;\n compute?: Record<string, ComputeExpression>;\n aggregate?: Record<string, AggregateExpression>;\n groupBy?: string[];\n sort?: SortEntry[];\n limit?: number;\n distinct?: boolean;\n};\n\nconst SubquerySourceSchema = z\n .object({\n as: IdentifierSchema.describe('Alias for subquery results — use as prefix in field paths'),\n query: z.lazy((): z.ZodType<Query> => QuerySchema).describe('A nested query'),\n })\n .strict()\n .describe('Subquery data source: a nested query read as a table under `as`, its columns referenced as `<as>.<field>` anywhere in the outer query. Joined by foreign key like an entity when one links them; otherwise every outer row is paired with every subquery row (a cross join), so a one-row subquery puts its values beside each outer row.');\n\nconst SourceSchema = z\n .union([\n z.string().describe('Entity name from the database schema'),\n SubquerySourceSchema,\n ])\n .describe('Data source: entity name or subquery');\n\nconst FieldRefSchema = z\n .union([\n FieldPathSchema.describe('A column in entity.field format'),\n z\n .object({\n field: FieldPathSchema.describe('A column in entity.field format'),\n as: IdentifierSchema.describe('Output key for this column'),\n })\n .strict()\n .describe('An aliased column: output under `as` instead of the column name'),\n ])\n .describe('A selected field — a bare `entity.field`, or `{ field, as }` to alias the output key');\n\nexport const QuerySchema: z.ZodType<Query> = z.lazy(() =>\n z\n .object({\n from: z.array(SourceSchema).min(1).describe('Data sources — entity names or subqueries. Every entity used anywhere in the query must be listed here. Listed entities are JOINED FOR YOU along their foreign keys — a nullable key as a LEFT JOIN, so a row whose key is empty is kept, with the joined columns null. Never restate a join as a filter comparing the two keys: that throws those rows away.'),\n fields: z.array(FieldRefSchema).optional().describe('Raw columns to select — each `entity.field`, or `{ field, as }` to alias the output key (no SELECT *). Optional: omit it for an aggregate-only query (e.g. a bare COUNT). Do not list compute or aggregate aliases here — those are added automatically.'),\n filter: FilterSchema.optional().describe('Filter conditions'),\n compute: z.record(IdentifierSchema, ComputeExpressionSchema).optional().describe('Computed fields — key is output alias, value is the expression'),\n aggregate: z.record(IdentifierSchema, AggregateExpressionSchema).optional().describe('Aggregate functions — key is output alias, value is the function'),\n groupBy: z.array(FieldPathSchema).optional().describe('Fields to group by for aggregation'),\n sort: z.array(SortEntrySchema).optional().describe('Sort order'),\n limit: z.number().int().positive().optional().describe('Maximum rows to return'),\n distinct: z.boolean().optional().describe('Eliminate duplicate rows'),\n })\n .strict()\n .refine(\n (q) => (q.fields?.length ?? 0) > 0 || Object.keys(q.aggregate ?? {}).length > 0,\n { message: 'A query must select at least one of `fields` or `aggregate`.' },\n ),\n);\n\nexport { SubquerySourceSchema, SourceSchema };\n","import type { Sequence } from '@niscorp/strata';\nimport { z } from 'zod';\nimport { REFRESH_MODES } from '../cache/cache.types.js';\nimport { QuerySchema } from '../schemas/query.schema.js';\n\n// An entry as it is written, without the fingerprint it is kept under.\nexport const VEX_SEQUENCE: Sequence = {\n id: 'nisc.vex',\n documents: { entry: { embeds: { mapping: 'nisc.prism/config' } } },\n migrations: [],\n};\n\n// Read by the grammar check, which snapshots it and fails when it changes\n// without a migration here.\nexport const VEX_SCHEMAS = {\n 'nisc.vex/entry': z\n .object({\n dsl: QuerySchema,\n mapping: z.unknown().optional(),\n shape: z.unknown().optional(),\n intent: z.string().optional(),\n reach: z.string().optional(),\n refresh: z.enum(REFRESH_MODES).optional(),\n })\n .strict(),\n} as const;\n"]}
1
+ {"version":3,"sources":["../../src/cache/cache.types.ts","../../src/schemas/value.schema.ts","../../src/schemas/identifier.schema.ts","../../src/schemas/filter.schema.ts","../../src/schemas/compute.schema.ts","../../src/schemas/aggregate.schema.ts","../../src/schemas/query.schema.ts","../../src/migrations/index.ts"],"names":["z"],"mappings":";;;;;;;AAMO,IAAM,aAAA,GAAgB,CAAC,UAAA,EAAY,UAAU,CAAA;ACJ7C,IAAM,gBAAA,GAAmBA,MAC7B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A,IAC3B,OAAA,EAASA,KAAAA,CAAE,IAAA,CAAK,aAAa,EAAE,QAAA;AAAS,GACzC,EACA,MAAA;AACL","file":"index.cjs","sourcesContent":["import type { Query } from '../schemas/query.schema.js';\nimport type { CompiledIr } from '@niscorp/prism';\nimport type { MutationDefinition } from '../mutations/schema.js';\nimport type { Sequence } from '@niscorp/strata';\nimport type { ScopeValues } from '../scope/scope.types.js';\n\nexport const REFRESH_MODES = ['snapshot', 'reactive'] as const;\nexport type Refresh = (typeof REFRESH_MODES)[number];\n\nexport const isRefresh = (value: unknown): value is Refresh => REFRESH_MODES.some((mode) => mode === value);\n\ntype CacheEntryMeta = {\n createdAt: number;\n lastUsedAt?: number;\n expiresAt?: number;\n protected?: boolean;\n requestHash?: string;\n schemaFingerprint?: string;\n intent?: string;\n shape?: unknown;\n};\n\nexport type OkCacheEntry = CacheEntryMeta & {\n kind: 'ok';\n dsl: Query;\n prismIr?: CompiledIr;\n // The prism config `prismIr` was compiled from, where vex wrote the mapping.\n mapping?: unknown;\n /**\n * The scope profile this read is served at, whatever the caller's roles say:\n * roles merge to the widest reach any of them grants, which is wrong for a\n * read that means \"mine\". A reach the host cannot compile refuses the read.\n */\n reach?: string;\n refresh?: Refresh;\n};\n\nexport type UnsatisfiableCacheEntry = CacheEntryMeta & {\n kind: 'unsatisfiable';\n reason: string;\n};\n\nexport type MutationCacheEntry = CacheEntryMeta & {\n kind: 'mutation';\n mutation: MutationDefinition;\n reach?: string;\n};\n\nexport type CacheEntry = OkCacheEntry | UnsatisfiableCacheEntry | MutationCacheEntry;\n\nexport type CacheBackend = {\n // `scope`: whose request asks, for a cache that answers an entry to some callers and not to others.\n get: (key: string, scope?: ScopeValues) => Promise<CacheEntry | undefined>;\n set: (key: string, entry: CacheEntry) => Promise<void>;\n delete: (key: string) => Promise<void>;\n clear: () => Promise<void>;\n keys: () => Promise<string[]>;\n init?: () => Promise<void>;\n sequence?: Sequence;\n entries?: () => Promise<Array<{ key: string; entry: CacheEntry }>>;\n // Writes `lastUsedAt` alone. Without it, a replay stamps by writing back the whole entry it read.\n touch?: (key: string, lastUsedAt: number) => Promise<void>;\n};\n","import { z } from 'zod';\n\nexport const ContextRefSchema = z\n .object({\n $context: z.string().describe('Key to look up in the request context object'),\n })\n .strict()\n .describe('Reference to a caller-provided context value');\n\nexport const ScopeRefSchema = z\n .object({\n $scope: z.string().describe('Key to look up in the server-side scope values'),\n })\n .strict()\n .describe('Reference to a server-injected scope value (access control)');\n\nexport const FieldOrValueSchema = z\n .union([\n z.string().describe('A field path (entity.field format) or a literal string'),\n z.number().describe('A literal number'),\n z.boolean().describe('A literal boolean'),\n z.null().describe('A literal null'),\n ContextRefSchema,\n ScopeRefSchema,\n ])\n .describe('A field path, literal value, or dynamic reference');\n\nexport type ContextRef = z.infer<typeof ContextRefSchema>;\nexport type ScopeRef = z.infer<typeof ScopeRefSchema>;\nexport type FieldOrValue = z.infer<typeof FieldOrValueSchema>;\n","import { z } from 'zod';\n\n// A name is the only authored text that reaches SQL as text (values bind as\n// parameters or are quoted as literals), so it is held to this grammar. In a\n// value position, `isFieldPathShape` decides whether a string is a column or\n// a literal.\nconst IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;\nconst FIELD_PATH = /^[A-Za-z_][A-Za-z0-9_]*\\.[A-Za-z_][A-Za-z0-9_]*$/;\n\nexport const isIdentifier = (value: string): boolean => IDENTIFIER.test(value);\n\nexport const isFieldPathShape = (value: unknown): value is string => typeof value === 'string' && FIELD_PATH.test(value);\n\nexport const IdentifierSchema = z\n .string()\n .regex(IDENTIFIER, 'A name is letters, digits and underscores, not starting with a digit');\n\nexport const FieldPathSchema = z\n .string()\n .regex(FIELD_PATH, 'A field path is entity.field — each part letters, digits and underscores, not starting with a digit');\n","import { z } from 'zod';\nimport { ContextRefSchema, ScopeRefSchema, FieldOrValueSchema } from './value.schema.js';\nimport { FieldPathSchema } from './identifier.schema.js';\nimport type { ContextRef, ScopeRef, FieldOrValue } from './value.schema.js';\n\nexport type ExistsQuery = {\n from: string[];\n filter?: Filter;\n};\n\nexport type Filter =\n | { exists: ExistsQuery }\n | { eq: [FieldOrValue, FieldOrValue] }\n | { neq: [FieldOrValue, FieldOrValue] }\n | { gt: [FieldOrValue, FieldOrValue] }\n | { gte: [FieldOrValue, FieldOrValue] }\n | { lt: [FieldOrValue, FieldOrValue] }\n | { lte: [FieldOrValue, FieldOrValue] }\n | { in: [string, FieldOrValue[] | ContextRef | ScopeRef] }\n | { notIn: [string, FieldOrValue[] | ContextRef | ScopeRef] }\n | { like: [string, FieldOrValue] }\n | { ilike: [string, FieldOrValue] }\n | { isNull: string }\n | { isNotNull: string }\n | { and: Filter[] }\n | { or: Filter[] }\n | { not: Filter }\n | { semantic: { field: string; query: ContextRef | ScopeRef; minScore?: number } }\n | { fuzzy: { field: string; query: ContextRef | ScopeRef; maxDistance?: number } }\n | { optional: { key: string | string[]; then: Filter } };\n\nconst comparisonPair = z\n .tuple([FieldOrValueSchema, FieldOrValueSchema])\n .describe('[left, right] — both can be field paths, literals, or references');\n\nconst fieldString = FieldPathSchema.describe('Field path in entity.field format');\n\nconst collectionTarget = z\n .union([\n z.array(FieldOrValueSchema).min(1).describe('Array of literal values or references'),\n ContextRefSchema,\n ScopeRefSchema,\n ])\n .describe('A set of values or a reference that resolves to an array');\n\nconst ExistsSchema: z.ZodType<ExistsQuery> = z.lazy(() =>\n z\n .object({\n from: z.array(z.string()).min(1).describe('Entities the subquery reads. Joined by foreign key like any other from.'),\n filter: FilterSchema.optional().describe('The correlation, and any extra condition. Reference the outer query by its own entity path: { eq: [\"<inner>.<fk>\", \"<outer>.id\"] }.'),\n })\n .strict(),\n);\n\nexport const FilterSchema: z.ZodType<Filter> = z.lazy(() =>\n z.union([\n z.object({ exists: ExistsSchema }).strict().describe('EXISTS: true when the subquery matches at least one row. Wrap in `not` for NOT EXISTS.'),\n z.object({ eq: comparisonPair }).strict().describe('Equals: tests equality between two values'),\n z.object({ neq: comparisonPair }).strict().describe('Not equals'),\n z.object({ gt: comparisonPair }).strict().describe('Greater than'),\n z.object({ gte: comparisonPair }).strict().describe('Greater than or equal'),\n z.object({ lt: comparisonPair }).strict().describe('Less than'),\n z.object({ lte: comparisonPair }).strict().describe('Less than or equal'),\n z.object({ in: z.tuple([fieldString, collectionTarget]) }).strict().describe('Field value is in a set'),\n z.object({ notIn: z.tuple([fieldString, collectionTarget]) }).strict().describe('Field value is not in a set'),\n z.object({ like: z.tuple([fieldString, FieldOrValueSchema]) }).strict().describe('Case-sensitive LIKE pattern match (use % as wildcard)'),\n z.object({ ilike: z.tuple([fieldString, FieldOrValueSchema]) }).strict().describe('Case-insensitive ILIKE pattern match (use % as wildcard)'),\n z.object({ isNull: fieldString }).strict().describe('Field value is NULL'),\n z.object({ isNotNull: fieldString }).strict().describe('Field value is NOT NULL'),\n z.object({ and: z.array(FilterSchema).min(2) }).strict().describe('Logical AND: all conditions must be true'),\n z.object({ or: z.array(FilterSchema).min(2) }).strict().describe('Logical OR: at least one condition must be true'),\n z.object({ not: FilterSchema }).strict().describe('Logical NOT: negates the condition'),\n z.object({\n semantic: z.object({\n field: FieldPathSchema.describe('Vector column field path (entity.field)'),\n query: z.union([ContextRefSchema, ScopeRefSchema]).describe('Text to embed and compare'),\n minScore: z.number().min(0).max(1).optional().describe('Minimum cosine similarity (0–1)'),\n }).strict(),\n }).strict().describe('Semantic vector similarity search'),\n z.object({\n fuzzy: z.object({\n field: FieldPathSchema.describe('String field path'),\n query: z.union([ContextRefSchema, ScopeRefSchema]).describe('Text to fuzzy-match'),\n maxDistance: z.number().int().nonnegative().optional().describe('Maximum Levenshtein edit distance'),\n }).strict(),\n }).strict().describe('Fuzzy string match'),\n z.object({\n optional: z.object({\n key: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)])\n .describe('The context key this condition depends on, or EVERY key it depends on. A condition referencing two keys must name both — gating on one leaves the other conditionally required, which surfaces as an empty result rather than as a condition that did not apply.'),\n // Bare, never `.describe()`d: that call clones the schema, and zod's\n // to-json-schema detects recursion by instance identity, so a clone\n // expands the filter union into itself until the stack overflows.\n then: FilterSchema,\n }).strict(),\n }).strict().describe(\n 'A condition the caller turns on by supplying context keys. When any named key is absent the condition is REMOVED from the query before it compiles — it does not match everything, it is not there. Absent means missing, undefined or null; \"\" is a value and keeps the condition. Direction follows position: under `and` supplying the key NARROWS, under `or` it WIDENS. Either way an absent key reads exactly as if the condition had never been written, and scope is injected afterwards regardless. Reads only: a mutation may not contain one, and neither may the inside of an `exists` (its correlation must be unconditional).',\n ),\n ]),\n);\n","import { z } from 'zod';\nimport { FieldOrValueSchema } from './value.schema.js';\nimport { FilterSchema } from './filter.schema.js';\n\nconst CaseWhenSchema = z\n .object({\n condition: FilterSchema,\n then: FieldOrValueSchema.describe('Value when condition is true'),\n })\n .strict();\n\nexport const ComputeExpressionSchema = z\n .union([\n z.object({ add: z.tuple([FieldOrValueSchema, FieldOrValueSchema]) }).strict().describe('Addition: a + b'),\n z.object({ subtract: z.tuple([FieldOrValueSchema, FieldOrValueSchema]) }).strict().describe('Subtraction: a - b'),\n z.object({ multiply: z.tuple([FieldOrValueSchema, FieldOrValueSchema]) }).strict().describe('Multiplication: a * b'),\n z.object({ divide: z.tuple([FieldOrValueSchema, FieldOrValueSchema]) }).strict().describe('Division: a / b'),\n z.object({ concat: z.array(FieldOrValueSchema).min(2) }).strict().describe('String concatenation'),\n z.object({ coalesce: z.array(FieldOrValueSchema).min(2) }).strict().describe('Returns first non-null value'),\n z.object({\n case: z\n .object({\n when: z.array(CaseWhenSchema).min(1).describe('Condition/result pairs evaluated in order'),\n else: FieldOrValueSchema.describe('Default value when no condition matches'),\n })\n .strict(),\n }).strict().describe('CASE WHEN conditional expression'),\n ])\n .describe('Computed expression: arithmetic, string, or conditional');\n\nexport type ComputeExpression = z.infer<typeof ComputeExpressionSchema>;\n","import { z } from 'zod';\nimport { ComputeExpressionSchema } from './compute.schema.js';\nimport { FieldPathSchema } from './identifier.schema.js';\n\nconst fieldPath = FieldPathSchema.describe('Field path in entity.field format');\n\nconst fieldOrExpr = z.union([fieldPath, ComputeExpressionSchema]).describe('A field path or a compute expression');\n\nexport const AggregateExpressionSchema = z\n .union([\n z.object({ count: z.union([FieldPathSchema, z.literal('*')]).describe('Field path or \"*\" for COUNT(*)') }).strict().describe('COUNT'),\n z.object({ countDistinct: FieldPathSchema.describe('Field path whose distinct non-null values are counted') }).strict().describe('COUNT(DISTINCT field)'),\n z.object({ sum: fieldOrExpr }).strict().describe('SUM'),\n z.object({ avg: fieldOrExpr }).strict().describe('AVG'),\n z.object({ min: fieldOrExpr }).strict().describe('MIN'),\n z.object({ max: fieldOrExpr }).strict().describe('MAX'),\n ])\n .describe('Aggregate function applied to a field or expression');\n\nexport type AggregateExpression = z.infer<typeof AggregateExpressionSchema>;\n","import { z } from 'zod';\nimport { FilterSchema } from './filter.schema.js';\nimport { ComputeExpressionSchema } from './compute.schema.js';\nimport { AggregateExpressionSchema } from './aggregate.schema.js';\nimport { FieldPathSchema, IdentifierSchema } from './identifier.schema.js';\nimport type { Filter } from './filter.schema.js';\nimport type { ComputeExpression } from './compute.schema.js';\nimport type { AggregateExpression } from './aggregate.schema.js';\n\nexport const SortEntrySchema = z\n .object({\n field: z.union([FieldPathSchema, IdentifierSchema]).describe('Field path (entity.field), computed field name, or aggregate alias'),\n dir: z.enum(['asc', 'desc']).default('asc').describe('Sort direction'),\n })\n .strict()\n .describe('Sort specification');\n\nexport type SortEntry = z.infer<typeof SortEntrySchema>;\n\nexport type Source = string | { as: string; query: Query };\n\nexport type FieldRef = string | { field: string; as: string };\n\nexport type Query = {\n from: Source[];\n fields?: FieldRef[];\n filter?: Filter;\n compute?: Record<string, ComputeExpression>;\n aggregate?: Record<string, AggregateExpression>;\n groupBy?: string[];\n sort?: SortEntry[];\n limit?: number;\n distinct?: boolean;\n};\n\nconst SubquerySourceSchema = z\n .object({\n as: IdentifierSchema.describe('Alias for subquery results — use as prefix in field paths'),\n query: z.lazy((): z.ZodType<Query> => QuerySchema).describe('A nested query'),\n })\n .strict()\n .describe('Subquery data source: a nested query read as a table under `as`, its columns referenced as `<as>.<field>` anywhere in the outer query. Joined by foreign key like an entity when one links them; otherwise every outer row is paired with every subquery row (a cross join), so a one-row subquery puts its values beside each outer row.');\n\nconst SourceSchema = z\n .union([\n z.string().describe('Entity name from the database schema'),\n SubquerySourceSchema,\n ])\n .describe('Data source: entity name or subquery');\n\nconst FieldRefSchema = z\n .union([\n FieldPathSchema.describe('A column in entity.field format'),\n z\n .object({\n field: FieldPathSchema.describe('A column in entity.field format'),\n as: IdentifierSchema.describe('Output key for this column'),\n })\n .strict()\n .describe('An aliased column: output under `as` instead of the column name'),\n ])\n .describe('A selected field — a bare `entity.field`, or `{ field, as }` to alias the output key');\n\nexport const QuerySchema: z.ZodType<Query> = z.lazy(() =>\n z\n .object({\n from: z.array(SourceSchema).min(1).describe('Data sources — entity names or subqueries. Every entity used anywhere in the query must be listed here. Listed entities are JOINED FOR YOU along their foreign keys — a nullable key as a LEFT JOIN, so a row whose key is empty is kept, with the joined columns null. Never restate a join as a filter comparing the two keys: that throws those rows away.'),\n fields: z.array(FieldRefSchema).optional().describe('Raw columns to select — each `entity.field`, or `{ field, as }` to alias the output key (no SELECT *). Optional: omit it for an aggregate-only query (e.g. a bare COUNT). Do not list compute or aggregate aliases here — those are added automatically.'),\n filter: FilterSchema.optional().describe('Filter conditions'),\n compute: z.record(IdentifierSchema, ComputeExpressionSchema).optional().describe('Computed fields — key is output alias, value is the expression'),\n aggregate: z.record(IdentifierSchema, AggregateExpressionSchema).optional().describe('Aggregate functions — key is output alias, value is the function'),\n groupBy: z.array(FieldPathSchema).optional().describe('Fields to group by for aggregation'),\n sort: z.array(SortEntrySchema).optional().describe('Sort order'),\n limit: z.number().int().positive().optional().describe('Maximum rows to return'),\n distinct: z.boolean().optional().describe('Eliminate duplicate rows'),\n })\n .strict()\n .refine(\n (q) => (q.fields?.length ?? 0) > 0 || Object.keys(q.aggregate ?? {}).length > 0,\n { message: 'A query must select at least one of `fields` or `aggregate`.' },\n ),\n);\n\nexport { SubquerySourceSchema, SourceSchema };\n","import type { Sequence } from '@niscorp/strata';\nimport { z } from 'zod';\nimport { REFRESH_MODES } from '../cache/cache.types.js';\nimport { QuerySchema } from '../schemas/query.schema.js';\n\n// An entry as it is written, without the fingerprint it is kept under.\nexport const VEX_SEQUENCE: Sequence = {\n id: 'nisc.vex',\n documents: { entry: { embeds: { mapping: 'nisc.prism/config' } } },\n migrations: [],\n};\n\n// Read by the grammar check, which snapshots it and fails when it changes\n// without a migration here.\nexport const VEX_SCHEMAS = {\n 'nisc.vex/entry': z\n .object({\n dsl: QuerySchema,\n mapping: z.unknown().optional(),\n shape: z.unknown().optional(),\n intent: z.string().optional(),\n reach: z.string().optional(),\n refresh: z.enum(REFRESH_MODES).optional(),\n })\n .strict(),\n} as const;\n"]}
@@ -1,4 +1,4 @@
1
- import { REFRESH_MODES } from '../chunk-F7RDSWYF.js';
1
+ import { REFRESH_MODES } from '../chunk-VHNCSQPO.js';
2
2
  import { QuerySchema } from '../chunk-UPQMKAAX.js';
3
3
  import { z } from 'zod';
4
4
 
@@ -1,7 +1,7 @@
1
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
3
  import { z } from 'zod';
4
- import { Sequence } from '@niscorp/strata';
4
+ import { Sequence, Upgrader } from '@niscorp/strata';
5
5
 
6
6
  type ScopeValues = Record<string, unknown>;
7
7
  type ScopeMatchOne = {
@@ -450,6 +450,7 @@ type CacheBackend = {
450
450
  key: string;
451
451
  entry: CacheEntry;
452
452
  }>>;
453
+ touch?: (key: string, lastUsedAt: number) => Promise<void>;
453
454
  };
454
455
 
455
456
  declare const NormalizedTypeSchema: z.ZodEnum<{
@@ -612,6 +613,7 @@ declare const DatabaseSchemaSchema: z.ZodObject<{
612
613
  }, z.core.$strip>>;
613
614
  rowCount: z.ZodOptional<z.ZodNumber>;
614
615
  }, z.core.$strip>>;
616
+ namespace: z.ZodOptional<z.ZodString>;
615
617
  }, z.core.$strip>;
616
618
  type NormalizedType = z.infer<typeof NormalizedTypeSchema>;
617
619
  type FieldSchema = z.infer<typeof FieldSchemaSchema>;
@@ -711,6 +713,7 @@ type ParamSlot = {
711
713
  kind: 'context' | 'scope' | 'semantic';
712
714
  type: 'string' | 'number' | 'boolean' | 'string[]' | 'number[]' | 'json';
713
715
  dimensions?: number;
716
+ embed?: true;
714
717
  encode?: 'json';
715
718
  };
716
719
  type ContextContract = Record<string, {
@@ -891,6 +894,35 @@ declare const scopeProfiles: (behaviors: ScopeBehaviors) => ReadonlySet<string>;
891
894
  declare const createScopePolicy: (grants: ReadonlySet<string>, behaviors?: ScopeBehaviors, scoping?: string) => ScopePolicy;
892
895
  declare const mergeScopePolicies: (policies: readonly ScopePolicy[]) => ScopePolicy;
893
896
 
897
+ declare const UNREADABLE_MODES: readonly ["refuse", "omit", "null"];
898
+ declare const UpgradedColumnSchema: z.ZodObject<{
899
+ stamp: z.ZodString;
900
+ kind: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
901
+ grammar: z.ZodString;
902
+ column: z.ZodString;
903
+ }, z.core.$strict>]>;
904
+ unreadable: z.ZodOptional<z.ZodEnum<{
905
+ null: "null";
906
+ refuse: "refuse";
907
+ omit: "omit";
908
+ }>>;
909
+ }, z.core.$strict>;
910
+ declare const UpgradedColumnsSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
911
+ stamp: z.ZodString;
912
+ kind: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
913
+ grammar: z.ZodString;
914
+ column: z.ZodString;
915
+ }, z.core.$strict>]>;
916
+ unreadable: z.ZodOptional<z.ZodEnum<{
917
+ null: "null";
918
+ refuse: "refuse";
919
+ omit: "omit";
920
+ }>>;
921
+ }, z.core.$strict>>>;
922
+ type UpgradedColumn = z.infer<typeof UpgradedColumnSchema>;
923
+ type UpgradedColumns = z.infer<typeof UpgradedColumnsSchema>;
924
+ type ColumnUpgrader = Pick<Upgrader, 'upgrade' | 'locate' | 'stamp'>;
925
+
894
926
  type GenerationCaller = {
895
927
  read: (dsl: Query) => Promise<{
896
928
  rows: Row[];
@@ -928,6 +960,8 @@ type QueryEngineConfig = {
928
960
  */
929
961
  behaviors?: ScopeBehaviors;
930
962
  mapToShape?: MapToShape;
963
+ upgradedColumns?: UpgradedColumns;
964
+ upgrader?: ColumnUpgrader;
931
965
  rows?: LiveRowsConfig;
932
966
  config?: {
933
967
  maxNestingDepth?: number;
@@ -951,6 +985,7 @@ type QueryEngine = {
951
985
  getDslSchema: () => object;
952
986
  getSchema: () => DatabaseSchema | undefined;
953
987
  cache: CacheBackend;
988
+ readonly scopePolicy?: ScopePolicy;
954
989
  invalidate: (tables: readonly string[]) => void;
955
990
  rows: {
956
991
  stats: () => LiveRowsStats;
@@ -962,9 +997,10 @@ type ExecuteOptions = {
962
997
  entities?: string[];
963
998
  locked?: boolean;
964
999
  scopePolicy?: ScopePolicy;
1000
+ policyForReach?: (reach: string) => Promise<ScopePolicy | undefined> | ScopePolicy | undefined;
965
1001
  /** `signal` and `onChange` go together; both are ignored for a snapshot read. */
966
1002
  signal?: AbortSignal;
967
1003
  onChange?: (response: QueryResponse) => void;
968
1004
  };
969
1005
 
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 };
1006
+ export { type ResolvedOnConflict 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 NormalizedType as H, type IndexSchema as I, type QueryErrorResponse as J, type QueryRequest 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, QueryRequestSchema as T, type QueryResponse as U, REFRESH_MODES as V, type RelationSchema as W, type ResolvedField as X, type ResolvedFilter as Y, type ResolvedJoin as Z, type ResolvedMutation as _, type QueryEngine as a, type ResolvedSemantic as a0, type ResolvedSource as a1, type ReturnedRef as a2, SCOPE_VERBS as a3, type ScopeBehaviors as a4, type ScopeBinding as a5, type ScopeEntityRule as a6, type ScopeMatch as a7, type ScopeRule as a8, type ScopeRules as a9, type ScopeSet as aa, type ScopeValues as ab, type TestResult as ac, UNREADABLE_MODES as ad, type UnsatisfiableCacheEntry as ae, type UpgradedColumn as af, type UpgradedColumns as ag, UpgradedColumnsSchema as ah, type VexEvent as ai, type VexEventHandler as aj, createScopePolicy as ak, isRefresh as al, mergeScopePolicies as am, scopeBindings as an, scopeGrants as ao, scopeProfiles as ap, 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 ColumnUpgrader as m, type CoreMutation as n, type ExecuteOptions as o, type GenerationCaller as p, type IntrospectOptions as q, type ItemRef as r, type LiveRowsStats as s, type LookupValue as t, type MapToShape as u, type Mutation as v, type MutationCacheEntry as w, MutationDefinitionSchema as x, MutationSchema as y, type MutationValue as z };
@@ -1,7 +1,7 @@
1
1
  import { a as Filter, F as FieldOrValue, Q as Query, C as ComputeExpression, A as AggregateExpression } from './query.schema-B-LVNfyX.js';
2
2
  import { CompiledIr, JsonValue } from '@niscorp/prism';
3
3
  import { z } from 'zod';
4
- import { Sequence } from '@niscorp/strata';
4
+ import { Sequence, Upgrader } from '@niscorp/strata';
5
5
 
6
6
  type ScopeValues = Record<string, unknown>;
7
7
  type ScopeMatchOne = {
@@ -450,6 +450,7 @@ type CacheBackend = {
450
450
  key: string;
451
451
  entry: CacheEntry;
452
452
  }>>;
453
+ touch?: (key: string, lastUsedAt: number) => Promise<void>;
453
454
  };
454
455
 
455
456
  declare const NormalizedTypeSchema: z.ZodEnum<{
@@ -612,6 +613,7 @@ declare const DatabaseSchemaSchema: z.ZodObject<{
612
613
  }, z.core.$strip>>;
613
614
  rowCount: z.ZodOptional<z.ZodNumber>;
614
615
  }, z.core.$strip>>;
616
+ namespace: z.ZodOptional<z.ZodString>;
615
617
  }, z.core.$strip>;
616
618
  type NormalizedType = z.infer<typeof NormalizedTypeSchema>;
617
619
  type FieldSchema = z.infer<typeof FieldSchemaSchema>;
@@ -711,6 +713,7 @@ type ParamSlot = {
711
713
  kind: 'context' | 'scope' | 'semantic';
712
714
  type: 'string' | 'number' | 'boolean' | 'string[]' | 'number[]' | 'json';
713
715
  dimensions?: number;
716
+ embed?: true;
714
717
  encode?: 'json';
715
718
  };
716
719
  type ContextContract = Record<string, {
@@ -891,6 +894,35 @@ declare const scopeProfiles: (behaviors: ScopeBehaviors) => ReadonlySet<string>;
891
894
  declare const createScopePolicy: (grants: ReadonlySet<string>, behaviors?: ScopeBehaviors, scoping?: string) => ScopePolicy;
892
895
  declare const mergeScopePolicies: (policies: readonly ScopePolicy[]) => ScopePolicy;
893
896
 
897
+ declare const UNREADABLE_MODES: readonly ["refuse", "omit", "null"];
898
+ declare const UpgradedColumnSchema: z.ZodObject<{
899
+ stamp: z.ZodString;
900
+ kind: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
901
+ grammar: z.ZodString;
902
+ column: z.ZodString;
903
+ }, z.core.$strict>]>;
904
+ unreadable: z.ZodOptional<z.ZodEnum<{
905
+ null: "null";
906
+ refuse: "refuse";
907
+ omit: "omit";
908
+ }>>;
909
+ }, z.core.$strict>;
910
+ declare const UpgradedColumnsSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
911
+ stamp: z.ZodString;
912
+ kind: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
913
+ grammar: z.ZodString;
914
+ column: z.ZodString;
915
+ }, z.core.$strict>]>;
916
+ unreadable: z.ZodOptional<z.ZodEnum<{
917
+ null: "null";
918
+ refuse: "refuse";
919
+ omit: "omit";
920
+ }>>;
921
+ }, z.core.$strict>>>;
922
+ type UpgradedColumn = z.infer<typeof UpgradedColumnSchema>;
923
+ type UpgradedColumns = z.infer<typeof UpgradedColumnsSchema>;
924
+ type ColumnUpgrader = Pick<Upgrader, 'upgrade' | 'locate' | 'stamp'>;
925
+
894
926
  type GenerationCaller = {
895
927
  read: (dsl: Query) => Promise<{
896
928
  rows: Row[];
@@ -928,6 +960,8 @@ type QueryEngineConfig = {
928
960
  */
929
961
  behaviors?: ScopeBehaviors;
930
962
  mapToShape?: MapToShape;
963
+ upgradedColumns?: UpgradedColumns;
964
+ upgrader?: ColumnUpgrader;
931
965
  rows?: LiveRowsConfig;
932
966
  config?: {
933
967
  maxNestingDepth?: number;
@@ -951,6 +985,7 @@ type QueryEngine = {
951
985
  getDslSchema: () => object;
952
986
  getSchema: () => DatabaseSchema | undefined;
953
987
  cache: CacheBackend;
988
+ readonly scopePolicy?: ScopePolicy;
954
989
  invalidate: (tables: readonly string[]) => void;
955
990
  rows: {
956
991
  stats: () => LiveRowsStats;
@@ -962,9 +997,10 @@ type ExecuteOptions = {
962
997
  entities?: string[];
963
998
  locked?: boolean;
964
999
  scopePolicy?: ScopePolicy;
1000
+ policyForReach?: (reach: string) => Promise<ScopePolicy | undefined> | ScopePolicy | undefined;
965
1001
  /** `signal` and `onChange` go together; both are ignored for a snapshot read. */
966
1002
  signal?: AbortSignal;
967
1003
  onChange?: (response: QueryResponse) => void;
968
1004
  };
969
1005
 
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 };
1006
+ export { type ResolvedOnConflict 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 NormalizedType as H, type IndexSchema as I, type QueryErrorResponse as J, type QueryRequest 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, QueryRequestSchema as T, type QueryResponse as U, REFRESH_MODES as V, type RelationSchema as W, type ResolvedField as X, type ResolvedFilter as Y, type ResolvedJoin as Z, type ResolvedMutation as _, type QueryEngine as a, type ResolvedSemantic as a0, type ResolvedSource as a1, type ReturnedRef as a2, SCOPE_VERBS as a3, type ScopeBehaviors as a4, type ScopeBinding as a5, type ScopeEntityRule as a6, type ScopeMatch as a7, type ScopeRule as a8, type ScopeRules as a9, type ScopeSet as aa, type ScopeValues as ab, type TestResult as ac, UNREADABLE_MODES as ad, type UnsatisfiableCacheEntry as ae, type UpgradedColumn as af, type UpgradedColumns as ag, UpgradedColumnsSchema as ah, type VexEvent as ai, type VexEventHandler as aj, createScopePolicy as ak, isRefresh as al, mergeScopePolicies as am, scopeBindings as an, scopeGrants as ao, scopeProfiles as ap, 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 ColumnUpgrader as m, type CoreMutation as n, type ExecuteOptions as o, type GenerationCaller as p, type IntrospectOptions as q, type ItemRef as r, type LiveRowsStats as s, type LookupValue as t, type MapToShape as u, type Mutation as v, type MutationCacheEntry as w, MutationDefinitionSchema as x, MutationSchema as y, type MutationValue as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@niscorp/vex",
3
- "version": "0.4.4",
3
+ "version": "0.5.0",
4
4
  "description": "Declarative query synthesis — intent to SQL with caching and scope policies",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -98,9 +98,9 @@
98
98
  "hono": "^4",
99
99
  "pg": "^8",
100
100
  "zod": "^4.2.0",
101
- "@niscorp/cortex": "^0.1.6",
102
- "@niscorp/strata": "^0.1.9",
103
- "@niscorp/prism": "^0.3.3"
101
+ "@niscorp/prism": "^0.4.0",
102
+ "@niscorp/strata": "^0.2.0",
103
+ "@niscorp/cortex": "^0.2.0"
104
104
  },
105
105
  "devDependencies": {
106
106
  "@electric-sql/pglite": "^0.5.1",
@@ -114,10 +114,10 @@
114
114
  "tsx": "^4.20.3",
115
115
  "vitest": "^4.1.2",
116
116
  "zod": "^4.6.5",
117
- "@niscorp/cortex": "^0.1.6",
118
- "@niscorp/signal": "^0.1.9",
119
- "@niscorp/prism": "^0.3.3",
120
- "@niscorp/strata": "^0.1.9"
117
+ "@niscorp/prism": "^0.4.0",
118
+ "@niscorp/cortex": "^0.2.0",
119
+ "@niscorp/signal": "^0.2.0",
120
+ "@niscorp/strata": "^0.2.0"
121
121
  },
122
122
  "peerDependenciesMeta": {
123
123
  "@niscorp/cortex": {