@niscorp/vex 0.2.3 → 0.3.1

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 +79 -0
  2. package/DESIGN.md +26 -11
  3. package/DOCS.md +39 -9
  4. package/dist/adapters/express/index.cjs +6 -24
  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/express/index.js.map +1 -1
  10. package/dist/adapters/hono/index.cjs +6 -24
  11. package/dist/adapters/hono/index.cjs.map +1 -1
  12. package/dist/adapters/hono/index.d.cts +2 -2
  13. package/dist/adapters/hono/index.d.ts +2 -2
  14. package/dist/adapters/hono/index.js +2 -2
  15. package/dist/adapters/hono/index.js.map +1 -1
  16. package/dist/adapters/pglite/index.cjs.map +1 -1
  17. package/dist/adapters/pglite/index.js.map +1 -1
  18. package/dist/agent/index.cjs +5 -11
  19. package/dist/agent/index.cjs.map +1 -1
  20. package/dist/agent/index.d.cts +1 -1
  21. package/dist/agent/index.d.ts +1 -1
  22. package/dist/agent/index.js +3 -6
  23. package/dist/agent/index.js.map +1 -1
  24. package/dist/{chunk-IQM4SQE2.js → chunk-3HORTMZ7.js} +6 -21
  25. package/dist/chunk-3HORTMZ7.js.map +1 -0
  26. package/dist/{chunk-H4BHW76Q.js → chunk-J7JYKCUA.js} +5 -8
  27. package/dist/chunk-J7JYKCUA.js.map +1 -0
  28. package/dist/{handler-CMrjTXNx.d.cts → handler-B4NAi4k_.d.cts} +1 -1
  29. package/dist/{handler-BGCL6_Si.d.ts → handler-BRVhWuNk.d.ts} +1 -1
  30. package/dist/index.cjs +23 -79
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +14 -62
  33. package/dist/index.d.ts +14 -62
  34. package/dist/index.js +21 -59
  35. package/dist/index.js.map +1 -1
  36. package/dist/{types-Bi-Lg86b.d.cts → types-DUJp5B3o.d.cts} +9 -124
  37. package/dist/{types-Bi-Lg86b.d.ts → types-DUJp5B3o.d.ts} +9 -124
  38. package/package.json +7 -7
  39. package/dist/chunk-H4BHW76Q.js.map +0 -1
  40. package/dist/chunk-IQM4SQE2.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { a as QueryEngine, al as ScopeValues } from '../../types-Bi-Lg86b.cjs';
2
- import { V as VexHandlerConfig } from '../../handler-CMrjTXNx.cjs';
1
+ import { a as QueryEngine, al as ScopeValues } from '../../types-DUJp5B3o.cjs';
2
+ import { V as VexHandlerConfig } from '../../handler-B4NAi4k_.cjs';
3
3
  import 'zod';
4
4
  import '@niscorp/prism';
5
5
  import '@niscorp/strata';
@@ -1,5 +1,5 @@
1
- import { a as QueryEngine, al as ScopeValues } from '../../types-Bi-Lg86b.js';
2
- import { V as VexHandlerConfig } from '../../handler-BGCL6_Si.js';
1
+ import { a as QueryEngine, al as ScopeValues } from '../../types-DUJp5B3o.js';
2
+ import { V as VexHandlerConfig } from '../../handler-BRVhWuNk.js';
3
3
  import 'zod';
4
4
  import '@niscorp/prism';
5
5
  import '@niscorp/strata';
@@ -1,5 +1,5 @@
1
- import { handleDiscovery, handleQuery, handleFingerprintPatch, handleFingerprintDelete } from '../../chunk-IQM4SQE2.js';
2
- import '../../chunk-H4BHW76Q.js';
1
+ import { handleDiscovery, handleQuery, handleFingerprintPatch, handleFingerprintDelete } from '../../chunk-3HORTMZ7.js';
2
+ import '../../chunk-J7JYKCUA.js';
3
3
 
4
4
  // src/adapters/express/index.ts
5
5
  var fingerprintFromBody = (body) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/express/index.ts"],"names":[],"mappings":";;;;AAgCA,IAAM,mBAAA,GAAsB,CAAC,IAAA,KAAsC;AACjE,EAAA,IAAI,IAAA,KAAS,IAAA,IAAQ,OAAO,IAAA,KAAS,UAAU,OAAO,MAAA;AACtD,EAAA,MAAM,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CAAK,EAAE,KAAA,EAAO,iBAAA,EAAmB,OAAA,EAAS,mCAAA,EAAqC,CAAA;AAC/F,QAAA;AAAA,MACF;AACA,MAAA,MAAM,MAAA,GAAU,GAAA,CAAI,IAAA,CAAiC,WAAW,CAAA;AAChE,MAAA,MAAM,MAAA,GAAS,MAAM,sBAAA,CAAuB,aAAA,EAAe,WAAA,EAAa;AAAA,QACtE,GAAI,OAAO,MAAA,KAAW,SAAA,GAAY,EAAE,SAAA,EAAW,MAAA,KAAW;AAAC,OAC5D,CAAA;AACD,MAAA,GAAA,CAAI,OAAO,MAAA,CAAO,MAAM,CAAA,CAAE,IAAA,CAAK,OAAO,IAAI,CAAA;AAC1C,MAAA;AAAA,IACF;AAEA,IAAA,IAAI,GAAA,CAAI,WAAW,QAAA,EAAU;AAC3B,MAAA,MAAM,WAAA,GAAc,mBAAA,CAAoB,GAAA,CAAI,IAAI,CAAA;AAChD,MAAA,IAAI,gBAAgB,MAAA,EAAW;AAC7B,QAAA,GAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK,EAAE,KAAA,EAAO,iBAAA,EAAmB,OAAA,EAAS,mCAAA,EAAqC,CAAA;AAC/F,QAAA;AAAA,MACF;AACA,MAAA,MAAM,MAAA,GAAS,MAAM,uBAAA,CAAwB,aAAA,EAAe,WAAW,CAAA;AACvE,MAAA,GAAA,CAAI,OAAO,MAAA,CAAO,MAAM,CAAA,CAAE,IAAA,CAAK,OAAO,IAAI,CAAA;AAC1C,MAAA;AAAA,IACF;AAEA,IAAA,GAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK;AAAA,MACnB,KAAA,EAAO,oBAAA;AAAA,MACP,OAAA,EAAS;AAAA,KACV,CAAA;AAAA,EACH,CAAA;AACF","file":"index.js","sourcesContent":["import type { QueryEngine } from '../../types.js';\nimport type { ScopeValues } from '../../scope/scope.types.js';\nimport type { VexHandlerConfig } from '../../handler.js';\nimport { handleDiscovery, handleQuery, handleFingerprintPatch, handleFingerprintDelete } from '../../handler.js';\n\n// Minimal structural types — Express.Request/Response satisfy these\n// without requiring express as a runtime dependency.\n\nexport type VexExpressRequest = {\n method: string;\n body: unknown;\n query: Record<string, unknown>;\n};\n\nexport type VexExpressResponse = {\n json(body: unknown): unknown;\n status(code: number): VexExpressResponse;\n};\n\nexport type VexExpressConfig<TReq extends VexExpressRequest = VexExpressRequest> = {\n engine: QueryEngine;\n entities?: string[];\n // Replay-only posture: no generation, no fingerprint management.\n // (Writes are unaffected — mutation replay is always replay-only.)\n locked?: boolean;\n getScope?: (req: TReq) => Promise<ScopeValues> | ScopeValues;\n // Enables replay of `kind: 'mutation'` cache entries on this endpoint.\n mutations?: VexHandlerConfig['mutations'];\n};\n\n// Fingerprints may contain '/' (named slots like \"deals/table\"), so\n// management rides the request BODY, not the path.\nconst fingerprintFromBody = (body: unknown): string | undefined => {\n if (body === null || typeof body !== 'object') return undefined;\n const fp = (body as Record<string, unknown>)['fingerprint'];\n return typeof fp === 'string' && fp.length > 0 ? fp : undefined;\n};\n\nexport const vex = <TReq extends VexExpressRequest = VexExpressRequest>(\n config: VexExpressConfig<TReq>,\n): ((req: TReq, res: VexExpressResponse) => Promise<void>) => {\n const handlerConfig = {\n engine: config.engine,\n entities: config.entities,\n ...(config.locked === true ? { locked: true } : {}),\n ...(config.mutations !== undefined ? { mutations: config.mutations } : {}),\n };\n\n return async (req: TReq, res: VexExpressResponse): Promise<void> => {\n if (req.method === 'GET') {\n res.json(await handleDiscovery(handlerConfig));\n return;\n }\n\n if (req.method === 'POST') {\n const scope = config.getScope ? await config.getScope(req) : {};\n const result = await handleQuery(handlerConfig, req.body, scope);\n res.status(result.status).json(result.body);\n return;\n }\n\n if (req.method === 'PATCH') {\n const fingerprint = fingerprintFromBody(req.body);\n if (fingerprint === undefined) {\n res.status(400).json({ error: 'invalid_request', message: 'Body must include { fingerprint }' });\n return;\n }\n const wanted = (req.body as Record<string, unknown>)['protected'];\n const result = await handleFingerprintPatch(handlerConfig, fingerprint, {\n ...(typeof wanted === 'boolean' ? { protected: wanted } : {}),\n });\n res.status(result.status).json(result.body);\n return;\n }\n\n if (req.method === 'DELETE') {\n const fingerprint = fingerprintFromBody(req.body);\n if (fingerprint === undefined) {\n res.status(400).json({ error: 'invalid_request', message: 'Body must include { fingerprint }' });\n return;\n }\n const result = await handleFingerprintDelete(handlerConfig, fingerprint);\n res.status(result.status).json(result.body);\n return;\n }\n\n res.status(405).json({\n error: 'method_not_allowed',\n message: 'GET discovery · POST query · PATCH/DELETE fingerprint management',\n });\n };\n};\n"]}
1
+ {"version":3,"sources":["../../../src/adapters/express/index.ts"],"names":[],"mappings":";;;;AA0BA,IAAM,mBAAA,GAAsB,CAAC,IAAA,KAAsC;AACjE,EAAA,IAAI,IAAA,KAAS,IAAA,IAAQ,OAAO,IAAA,KAAS,UAAU,OAAO,MAAA;AACtD,EAAA,MAAM,EAAA,GAAM,KAAiC,aAAa,CAAA;AAC1D,EAAA,OAAO,OAAO,EAAA,KAAO,QAAA,IAAY,EAAA,CAAG,MAAA,GAAS,IAAI,EAAA,GAAK,MAAA;AACxD,CAAA;AAEO,IAAM,GAAA,GAAM,CACjB,MAAA,KAC4D;AAC5D,EAAA,MAAM,aAAA,GAAgB;AAAA,IACpB,QAAQ,MAAA,CAAO,MAAA;AAAA,IACf,UAAU,MAAA,CAAO,QAAA;AAAA,IACjB,GAAI,OAAO,MAAA,KAAW,IAAA,GAAO,EAAE,MAAA,EAAQ,IAAA,KAAS,EAAC;AAAA,IACjD,GAAI,OAAO,SAAA,KAAc,MAAA,GAAY,EAAE,SAAA,EAAW,MAAA,CAAO,SAAA,EAAU,GAAI;AAAC,GAC1E;AAEA,EAAA,OAAO,OAAO,KAAW,GAAA,KAA2C;AAClE,IAAA,IAAI,GAAA,CAAI,WAAW,KAAA,EAAO;AACxB,MAAA,GAAA,CAAI,IAAA,CAAK,MAAM,eAAA,CAAgB,aAAa,CAAC,CAAA;AAC7C,MAAA;AAAA,I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,EAAE,KAAA,EAAO,iBAAA,EAAmB,OAAA,EAAS,mCAAA,EAAqC,CAAA;AAC/F,QAAA;AAAA,MACF;AACA,MAAA,MAAM,MAAA,GAAS,MAAM,uBAAA,CAAwB,aAAA,EAAe,WAAW,CAAA;AACvE,MAAA,GAAA,CAAI,OAAO,MAAA,CAAO,MAAM,CAAA,CAAE,IAAA,CAAK,OAAO,IAAI,CAAA;AAC1C,MAAA;AAAA,IACF;AAEA,IAAA,GAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK;AAAA,MACnB,KAAA,EAAO,oBAAA;AAAA,MACP,OAAA,EAAS;AAAA,KACV,CAAA;AAAA,EACH,CAAA;AACF","file":"index.js","sourcesContent":["import type { QueryEngine } from '../../types.js';\nimport type { ScopeValues } from '../../scope/scope.types.js';\nimport type { VexHandlerConfig } from '../../handler.js';\nimport { handleDiscovery, handleQuery, handleFingerprintPatch, handleFingerprintDelete } from '../../handler.js';\n\nexport type VexExpressRequest = {\n method: string;\n body: unknown;\n query: Record<string, unknown>;\n};\n\nexport type VexExpressResponse = {\n json(body: unknown): unknown;\n status(code: number): VexExpressResponse;\n};\n\nexport type VexExpressConfig<TReq extends VexExpressRequest = VexExpressRequest> = {\n engine: QueryEngine;\n entities?: string[];\n locked?: boolean;\n getScope?: (req: TReq) => Promise<ScopeValues> | ScopeValues;\n mutations?: VexHandlerConfig['mutations'];\n};\n\n// A fingerprint may contain '/' (a named slot such as \"deals/table\"), so it\n// travels in the request body, not the path.\nconst fingerprintFromBody = (body: unknown): string | undefined => {\n if (body === null || typeof body !== 'object') return undefined;\n const fp = (body as Record<string, unknown>)['fingerprint'];\n return typeof fp === 'string' && fp.length > 0 ? fp : undefined;\n};\n\nexport const vex = <TReq extends VexExpressRequest = VexExpressRequest>(\n config: VexExpressConfig<TReq>,\n): ((req: TReq, res: VexExpressResponse) => Promise<void>) => {\n const handlerConfig = {\n engine: config.engine,\n entities: config.entities,\n ...(config.locked === true ? { locked: true } : {}),\n ...(config.mutations !== undefined ? { mutations: config.mutations } : {}),\n };\n\n return async (req: TReq, res: VexExpressResponse): Promise<void> => {\n if (req.method === 'GET') {\n res.json(await handleDiscovery(handlerConfig));\n return;\n }\n\n if (req.method === 'POST') {\n const scope = config.getScope ? await config.getScope(req) : {};\n const result = await handleQuery(handlerConfig, req.body, scope);\n res.status(result.status).json(result.body);\n return;\n }\n\n if (req.method === 'PATCH') {\n const fingerprint = fingerprintFromBody(req.body);\n if (fingerprint === undefined) {\n res.status(400).json({ error: 'invalid_request', message: 'Body must include { fingerprint }' });\n return;\n }\n const wanted = (req.body as Record<string, unknown>)['protected'];\n const result = await handleFingerprintPatch(handlerConfig, fingerprint, {\n ...(typeof wanted === 'boolean' ? { protected: wanted } : {}),\n });\n res.status(result.status).json(result.body);\n return;\n }\n\n if (req.method === 'DELETE') {\n const fingerprint = fingerprintFromBody(req.body);\n if (fingerprint === undefined) {\n res.status(400).json({ error: 'invalid_request', message: 'Body must include { fingerprint }' });\n return;\n }\n const result = await handleFingerprintDelete(handlerConfig, fingerprint);\n res.status(result.status).json(result.body);\n return;\n }\n\n res.status(405).json({\n error: 'method_not_allowed',\n message: 'GET discovery · POST query · PATCH/DELETE fingerprint management',\n });\n };\n};\n"]}
@@ -13,11 +13,6 @@ var ContextSchema = zod.z.object({
13
13
  'Caller runtime values. Keys referenced from the DSL via { $context: "key" } are bound as SQL parameters. `sortBy` (an entity.field, schema-validated) and `sortDir` ("asc"|"desc") are reserved keys that drive ORDER BY directly and are never bound as parameters.'
14
14
  );
15
15
  var QueryRequestSchema = zod.z.object({
16
- // The ONE cache identity. Server-minted (`fp_…`) when absent — returned in
17
- // meta.cache.fingerprint, an immutable pin. Caller-chosen strings are
18
- // mutable named slots: the name is yours, its content follows your request.
19
- // Alone → replay-or-error. With intent/shape → hit when the stored request
20
- // matches, regenerate-and-replace when it differs (409 when protected).
21
16
  fingerprint: zod.z.string().min(1).optional(),
22
17
  intent: zod.z.string().optional(),
23
18
  shape: zod.z.unknown().optional(),
@@ -92,12 +87,9 @@ var FilterSchema = zod.z.lazy(
92
87
  zod.z.object({
93
88
  optional: zod.z.object({
94
89
  key: zod.z.union([zod.z.string().min(1), zod.z.array(zod.z.string().min(1)).min(1)]).describe("The context key this condition depends on, or EVERY key it depends on. A condition referencing two keys must name both \u2014 gating on one leaves the other conditionally required, which surfaces as an empty result rather than as a condition that did not apply."),
95
- // BARE, never `.describe()`d. That call CLONES the schema, and zod
96
- // detects a recursive reference by instance identity — a clone is a
97
- // different instance, so `to-json-schema` stops seeing the cycle and
98
- // expands the filter union into itself until the stack goes. Every
99
- // other recursive slot here (`not`, `and`, `or`) uses it bare for the
100
- // same reason; the description belongs on the wrapper below.
90
+ // Bare, never `.describe()`d: that call clones the schema, and zod's
91
+ // to-json-schema detects recursion by instance identity, so a clone
92
+ // expands the filter union into itself until the stack overflows.
101
93
  then: FilterSchema
102
94
  }).strict()
103
95
  }).strict().describe(
@@ -336,13 +328,9 @@ var computeSchemaFingerprint = (schema) => {
336
328
  primaryKey: f.primaryKey,
337
329
  ...f.vectorDimensions !== void 0 ? { vectorDimensions: f.vectorDimensions } : {}
338
330
  })),
339
- // Column order within a relation is the key's own order, so it is
340
- // preserved; relations are sorted by target and columns. This shape
341
- // changed when keys became composite, so every entry cached before
342
- // revalidates once on the next boot — the drift eviction, by design.
331
+ // Column order within a relation is the key's own order, so it is not sorted.
343
332
  relations: [...e.relations].sort((a, b) => `${a.entity}.${a.localFields.join(",")}`.localeCompare(`${b.entity}.${b.localFields.join(",")}`)).map((r) => ({ type: r.type, entity: r.entity, localFields: r.localFields, foreignFields: r.foreignFields })),
344
- // Index field order is significant (composite indexes) and stable
345
- // from introspection, so it is preserved; indexes are sorted by name.
333
+ // Index field order is significant (composite indexes) and stable from introspection.
346
334
  indexes: [...e.indexes].sort(byName).map((i) => ({
347
335
  name: i.name,
348
336
  fields: i.fields,
@@ -461,8 +449,7 @@ var compileFilter = (filter, ctx) => {
461
449
  const inner = {
462
450
  ...ctx,
463
451
  resolvedPaths: resolved.filter?.resolvedPaths ?? ctx.resolvedPaths,
464
- // The inner map LAYERS OVER the outer one, so an inner path resolves to
465
- // the inner alias and an outer path — the correlation — still resolves.
452
+ // Inner over outer: an outer path, the correlation, still resolves.
466
453
  aliasMap: new Map([...ctx.aliasMap, ...resolved.aliasMap])
467
454
  };
468
455
  const parts = ["SELECT 1"];
@@ -683,9 +670,7 @@ var UpsertSchema = zod.z.object({
683
670
  op: zod.z.literal("upsert"),
684
671
  table: zod.z.string(),
685
672
  columns: Columns,
686
- // set on BOTH branches (update SET, and part of the insert)
687
673
  insert: Columns.optional(),
688
- // extra columns set ONLY on insert — immutable-on-create (e.g. a FK)
689
674
  key: zod.z.string()
690
675
  }).strict().describe('Sugar: insert-or-update by `key` (e.g. "id"). Desugars to update (SET columns WHERE key) when the key is present, else insert (columns + `insert`-only).');
691
676
  var MutationSchema = zod.z.discriminatedUnion("op", [InsertSchema, InsertEachSchema, UpdateSchema, DeleteSchema, UpsertSchema]);
@@ -1302,7 +1287,6 @@ var listFingerprints = async (engine, policy) => {
1302
1287
  ...entry.intent !== void 0 ? { intent: entry.intent } : {},
1303
1288
  createdAt: entry.createdAt,
1304
1289
  ...entry.lastUsedAt !== void 0 ? { lastUsedAt: entry.lastUsedAt } : {},
1305
- // The derived contract — what to pass, straight from the stored def.
1306
1290
  ...entry.kind === "ok" ? {
1307
1291
  context: collectQueryContext(entry.dsl, schema),
1308
1292
  ...entry.shape !== void 0 ? { shape: entry.shape } : {}
@@ -1378,8 +1362,6 @@ var handleQuery = async (config, body, scope, live) => {
1378
1362
  const result = await runQuery(config, body, scope, probe, live);
1379
1363
  const record = {
1380
1364
  kind: probe.kind,
1381
- // 200 succeeded; 403 is a policy/reach refusal (a normal outcome, not a
1382
- // fault); everything else is an error.
1383
1365
  status: result.status === 200 ? "ok" : result.status === 403 ? "refused" : "error",
1384
1366
  startUnixNano,
1385
1367
  endUnixNano: startUnixNano + (elapsedClock() - t0) * 1e6,