@vizejs/marquette
v0.818.0
Published
Typed application marquettes for every Vize target
Downloads
45,602
Maintainers
Readme
@vizejs/marquette
Typed application marquettes for every Vize target.
Experimental: serialized contracts are versioned, but the TypeScript API may evolve while target adapters are being validated.
Marquette is the small, language-neutral description shared by web, native, desktop, terminal, backend, transport, testing, and gallery tooling. This package provides literal-preserving TypeScript authoring. Runtime validation is available through a separate entry, while canonicalization and compatibility analysis remain focused layers.
The following named modules form one executable example folder. Install
@vizejs/marquette in an ESM project ("type": "module" in package.json) and
copy the linked sample inputs when running the test-run recipe. Run any module
directly with Node 24, for example node validate.ts.
Author a marquette
import { defineApplicationMarquette } from "@vizejs/marquette";
export const shop = defineApplicationMarquette({
application: "shop",
targets: ["web", "native"],
capabilities: {
"native.rendering": { id: "native.rendering", description: "Render native views", version: 1 },
"native.text": { id: "native.text", description: "Render native text", version: 1 },
"native.camera": { id: "native.camera", description: "Capture images", version: 1 },
"native.notifications": {
id: "native.notifications",
description: "Deliver notifications",
version: 1,
},
},
environments: [
{ id: "web", target: "web", consumer: "client", runtime: "browser" },
{
id: "native",
target: "native",
consumer: "client",
runtime: "native",
capabilities: ["native.rendering"],
},
{ id: "server", target: "web", consumer: "server", runtime: "rust" },
],
backends: [{ id: "api", family: "rust", environment: "server" }],
protocols: [{ id: "api.query", family: "schema-query", backend: "api" }],
routes: [
{
id: "home",
path: "/",
environment: "web",
rendering: "hybrid",
backend: "api",
protocol: "api.query",
},
{
id: "profile",
path: "/users/:userId",
environment: "native",
rendering: "native",
capabilities: ["native.text"],
},
],
});
export default shop;Environment dependencies, backend owners, protocol owners, and route references are checked against identifiers declared in the same object. A misspelled reference is therefore an authoring error rather than a runtime surprise.
Runtime validation
Use the dedicated validation entry when contracts cross file, process, or language boundaries:
import assert from "node:assert/strict";
import { validateApplicationMarquette } from "@vizejs/marquette/validate";
import shop from "./app.marquette.ts";
const diagnostics = validateApplicationMarquette(shop);
assert.deepEqual(diagnostics, []);Validation is deterministic, does not mutate the authored object, and reports stable codes shared with the native contract implementation. Keeping it in a separate entry means authoring-only applications do not include validation code.
Adapter capability negotiation
Adapters publish inclusive capability-version ranges independently from the application marquette. Application capability definitions are the authority for requirements; an undeclared requirement fails closed even when an adapter offers a capability with the same identifier. Adapter-only capabilities are allowed and remain additive until an application requires them.
import assert from "node:assert/strict";
import { defineApplicationMarquette } from "@vizejs/marquette";
import {
negotiateAdapterCapabilities,
type AdapterCapabilityManifest,
} from "@vizejs/marquette/adapter";
const terminal = defineApplicationMarquette({
application: "terminal-example",
targets: ["terminal"],
capabilities: {
"terminal.color": { id: "terminal.color", description: "Render terminal colors", version: 2 },
},
environments: [
{
id: "terminal",
target: "terminal",
consumer: "client",
runtime: "terminal",
capabilities: ["terminal.color"],
},
],
});
const adapter = {
adapter: "terminal.fresco",
capabilities: [{ id: "terminal.color", minVersion: 1, maxVersion: 3 }],
} satisfies AdapterCapabilityManifest;
const result = negotiateAdapterCapabilities(
terminal,
terminal.environments[0].capabilities,
adapter,
);
assert.equal(result.compatible, true);
assert.deepEqual(result.diagnostics, []);
assert.deepEqual(result.mismatches, []);Exact and inclusive-bound matches are compatible. Missing support,
requirements below an adapter's minimum, and requirements above its maximum
use the stable missing-capability, version-below-minimum, and
version-above-maximum codes. Each mismatch also carries a deterministic
path and message, so native adapter diagnostics can be rendered without
target-specific string formatting. Adding a support range or widening either
bound is additive; removing support or narrowing either bound is breaking.
Both negotiation and compatibility reports are sorted deterministically and do
not mutate their inputs. Compatibility reports expose validation diagnostics for
both manifests and omit changes when either input is invalid. The published manifest schema is available from
@vizejs/marquette/adapter/schema.
Capability definitions and adapter bounds use positive unsigned 32-bit integer
versions (1 through 4294967295) in TypeScript, native contracts, and published
schemas. Direct validation and negotiation refuse non-finite, fractional, and
out-of-range numbers. An invalid application requirement produces the stable
invalid-requirement-version mismatch without serializing the invalid number.
Native rendering adapters share one closed version-one baseline for rendering, events, layout, text, images, animation, accessibility, and lifecycle:
import assert from "node:assert/strict";
import {
nativeEngineCapabilityProfile,
type AdapterCapabilityManifest,
} from "@vizejs/marquette/adapter";
export const nativeAdapter = {
adapter: "native.example",
capabilities: [
...nativeEngineCapabilityProfile(),
{ id: "native.camera", minVersion: 1, maxVersion: 1 },
{ id: "native.notifications", minVersion: 1, maxVersion: 1 },
],
} satisfies AdapterCapabilityManifest;
assert.equal(nativeAdapter.capabilities.length, 10);The canonical identifiers use the native.* namespace and are emitted in a
stable order. The helper returns fresh values so an adapter may add private
capabilities without changing the baseline used by another consumer.
Native build profiles
Local and hosted native builders consume the same versioned profile. The profile selects the application marquette environment, lifecycle configuration, platform destinations, signing strategy, capability set, and optional update channel without embedding an executor, credentials, or secret values:
import assert from "node:assert/strict";
import {
defineNativeApplicationBuildProfile,
defineNativeBuildProfile,
} from "@vizejs/marquette/native-build";
import shop from "./app.marquette.ts";
export const profile = defineNativeBuildProfile({
format: "vize.native-build-profile",
formatVersion: 1,
profile: "production",
configuration: "production",
environment: "native",
targets: [
{ platform: "android", destination: "store", signing: "automatic" },
{ platform: "ios", destination: "store", signing: "manual" },
],
capabilities: ["native.camera", "native.notifications"],
updates: { channel: "stable", runtimeVersion: "1.4.0" },
});
assert.equal(defineNativeApplicationBuildProfile(shop, profile), profile);
export default profile;Use parseNativeBuildProfile at an untrusted JSON boundary and
validateNativeBuildProfile before scheduling a build. Parsing rejects
unknown fields, including executor and secret fields. Validation produces
stable path-ordered diagnostics for portable identifiers, duplicate targets,
store signing and production policy, update compatibility, and capabilities.
The published profile schema is available from
@vizejs/marquette/native-build/schema and is embedded by the Rust contract
crate for native hosts.
Admission before scheduling
The experimental defineNativeApplicationBuildProfile(app, profile) helper
infers native client environment identifiers and declared capability identifiers
from app. It preserves the original profile and its literal types. Standalone
defineNativeBuildProfile remains available for portable records.
Local and hosted executors can use the lazy
@vizejs/marquette/native-build/admission entry before scheduling:
import assert from "node:assert/strict";
import { admitNativeBuildProfile } from "@vizejs/marquette/native-build/admission";
import shop from "./app.marquette.ts";
import { nativeAdapter } from "./native-adapter.ts";
import profile from "./native-build-profile.ts";
const result = admitNativeBuildProfile(shop, profile, nativeAdapter);
if (!result.allowed) throw new Error(JSON.stringify(result.diagnostics));
assert.deepEqual(result.diagnostics, []);
assert.deepEqual(result.capabilities, [
"native.camera",
"native.notifications",
"native.rendering",
"native.text",
]);Admission validates the application, profile, and adapter, binds the selected
environment to a native client, and negotiates every capability required by
the profile, that environment, and its routes. A capability offered only by the
adapter cannot authorize an undeclared application requirement. Findings retain
their source, stable code, path, severity, and explanation; application warnings
remain visible. The result is deterministic and does not mutate inputs.
Strict profile and adapter parsing runs before graph inspection. Unknown fields,
invalid enum values, or unsafe numeric bounds throw TypeError; semantic
failures return allowed: false. Executors must treat either as a refusal.
Executors must check the same inputs immediately before scheduling. Admission does not run builds, access signing material, or persist an approval. Its complete emitted runtime dependency graph has an enforced 8 KiB gzip budget; authoring imports do not include admission or validation code.
Typed navigation
@vizejs/marquette/navigation derives programmatic navigation directly from
the route literals in an application marquette. Full :name path segments
accept one string or finite number. A *name segment preserves path separators
while encoding each segment. The host adapter receives only a resolved route,
environment, and encoded path.
import assert from "node:assert/strict";
import { createMarquetteNavigator } from "@vizejs/marquette/navigation";
import shop from "./app.marquette.ts";
const opened: string[] = [];
const navigation = createMarquetteNavigator(shop, (target) => {
opened.push(target.path);
return target;
});
const target = navigation.navigate("profile", { userId: "a user" });
assert.deepEqual(target, { route: "profile", environment: "native", path: "/users/a%20user" });
assert.deepEqual(opened, ["/users/a%20user"]);Unknown routes and missing, extra, empty, or non-finite parameters are rejected
before the target-specific adapter runs. Route identifiers, required parameter
names, and the owning environment remain inferred from app.
Incoming application links
The experimental @vizejs/marquette/navigation/links entry resolves incoming
HTTPS and custom-scheme links against the same authored route contract. Select
the owning environment and explicitly admit each origin:
import assert from "node:assert/strict";
import { createMarquetteLinkResolver } from "@vizejs/marquette/navigation/links";
import shop from "./app.marquette.ts";
const links = createMarquetteLinkResolver(shop, {
environment: "native",
origins: ["https://shop.example", "shop://app"],
});
const incomingLink = "shop://app/users/a%20user";
const result = links.resolve(incomingLink);
assert.deepEqual(result, {
matched: true,
target: {
route: "profile",
environment: "native",
path: "/users/a%20user",
parameters: { userId: "a user" },
},
});Successful targets preserve route and environment literals, infer decoded string
parameters for each route, and provide a canonical encoded path. Static route
segments take precedence over parameters, which take precedence over terminal
*rest segments. Equally specific matches fail with ambiguous-route rather
than relying on declaration order. Only routes in the selected environment
participate in matching.
The boundary refuses untrusted origins, credentials, malformed escaping,
backslashes, control characters, and decoded . or .. segments before URL
normalization can hide them. Query strings and fragments are not forwarded as
route parameters. Invalid origin policies and unsupported route templates fail
at construction. Origins require HTTPS or an explicit custom scheme and host;
HTTP origins are not admitted. Resolution scans precompiled routes in the
selected environment. The entry has an enforced 4 KiB gzip budget and adds no
runtime code to the authoring or programmatic-navigation entries. Device
launch and operating-system link registration remain host responsibilities.
Test-run evidence
Release-bound test-run evidence records live in their own lazy entries so
deployment tooling can bind a tests check to retained, immutable facts.
Copy the sample inputs into examples/. They
retain the shared canonical fixtures and their fixed historical clock; they
demonstrate API behavior and do not authorize a current release.
import assert from "node:assert/strict";
import { defineTestRunEvidence } from "@vizejs/marquette/test-run";
import { validateTestRunEvidence } from "@vizejs/marquette/test-run/validate";
import { testRunAdmissionId } from "@vizejs/marquette/test-run/canonical";
import { admitTestRun, decideTestRunAdmission } from "@vizejs/marquette/test-run/admission";
import { verifyTestRunCheck } from "@vizejs/marquette/test-run/check";
import { verifyTestRunTransition } from "@vizejs/marquette/test-run/transition";
import {
rawEvidence,
candidate,
now,
retainedCheck,
nextTransition,
chainTip,
expectedAdmissionId,
} from "./examples/test-run-inputs.ts";
const evidence = defineTestRunEvidence(rawEvidence);
assert.equal(evidence, rawEvidence);
assert.deepEqual(validateTestRunEvidence(evidence), []);
const admissionId = await testRunAdmissionId(evidence);
assert.equal(admissionId, expectedAdmissionId);
assert.deepEqual(await admitTestRun(evidence, candidate, admissionId, now), []);
const decision = await decideTestRunAdmission(evidence, candidate, admissionId, now);
assert.deepEqual(decision, { allowed: true, denialCodes: [], diagnostics: [] });
assert.deepEqual(await verifyTestRunCheck(retainedCheck, candidate, evidence, now), decision);
assert.deepEqual(await verifyTestRunTransition(nextTransition, chainTip), decision);Validation shares its VIZE_MARQUETTE_1xx codes, paths, and ordering with the
native implementation, and the canonical entry produces byte-identical
serialization and SHA-256 fingerprints, proven by the shared fixtures in
tests/fixtures/test-run-evidence/. Admission decisions carry the stable,
append-only denial-code vocabulary shared by every backend family; the same
fixtures pin every decision so a JavaScript, Rust, Go, or JVM gate denies for
identical machine-readable causes. The check entry replaces every generic
test-result reference in release evidence: a retained vize.test-run.check
record may only name the exact test-run:<sha256> admission id, bind the six
candidate facts, and record an observer independent from the runner. The
transition entry makes each release decision and the complete accepted
anti-replay state one durable atomic record, chained by canonical SHA-256
fingerprints; hosts persist it with a write-then-atomic-rename and verify the
recovered tip before deciding anything new. The published record schema is
available from @vizejs/marquette/test-run/schema, the decision contract from
@vizejs/marquette/test-run/admission/schema, the tests-check contract from
@vizejs/marquette/test-run/check/schema, and the transition contract from
@vizejs/marquette/test-run/transition/schema.
Guarantees
- Exact identifiers remain available as
EnvironmentId,BackendId,ProtocolId, andRouteIdunions. defineApplicationMarquettereturns its input without allocation or normalization.- The published application-contract schema is available from
@vizejs/marquette/schema. - The published adapter manifest schema is available from
@vizejs/marquette/adapter/schema. - The published native build profile schema is available from
@vizejs/marquette/native-build/schema. - Every optional contract field documents its default in JSDoc.
- Package builds enforce a 1 KiB gzip budget for authoring entries and 3 KiB or 4 KiB budgets for the validation entries.
Marquette describes components and environments; it does not author UI
components. Public Vize UI components use real .vue SFC files as their
canonical source, never authored h() calls or handwritten render functions.
