@fabricorg/sdui-release 0.3.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.
- package/CHANGELOG.md +125 -0
- package/LICENSE +21 -0
- package/README.md +103 -0
- package/dist/index.cjs +893 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +334 -0
- package/dist/index.d.ts +334 -0
- package/dist/index.js +855 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../index.ts","../types.ts","../structural.ts","../helpers.ts","../validate.ts","../digest.ts","../capabilities.ts","../walker.ts","../channel.ts","../schemas.ts"],"sourcesContent":["// ── Public API ──────────────────────────────────────────────────────────────\n//\n// The SDUI release package is split into cohesive private modules. This file\n// is the single public entry point: it re-exports every type, constant, and\n// function that consumers import. The internal modules (types, helpers,\n// structural, digest, capabilities, walker, channel, schemas, validate) are\n// implementation details and are not separately exported.\n\n// Format version constants\nexport {\n\tSDUI_DOCUMENT_FORMAT_VERSION,\n\tSDUI_TOKEN_SET_FORMAT_VERSION,\n\tSDUI_COMPONENT_PACK_FORMAT_VERSION,\n\tSDUI_RELEASE_FORMAT_VERSION,\n} from \"./types\";\n\n// Types\nexport type {\n\tSduiCapabilityRef,\n\tSduiFragmentValue,\n\tSduiActionRef,\n\tSduiFragment,\n\tSduiTokenType,\n\tSduiToken,\n\tSduiTokenSet,\n\tSduiComponentDefinition,\n\tSduiComponentPack,\n\tSduiComponentPackReference,\n\tSduiTokenSetReference,\n\tSduiDocument,\n\tResolvedSduiComponentPack,\n\tSduiRelease,\n\tSduiFindingCode,\n\tSduiFinding,\n\tSduiValidationResult,\n\tSduiAuthorizationGrants,\n\tSduiValidationInput,\n\tJsonValue,\n} from \"./types\";\n\n// Structural validation\nexport {\n\tassertSduiTokenSet,\n\tassertSduiComponentPack,\n\tassertSduiFragment,\n\tassertSduiDocument,\n\tassertSduiAuthorizationGrants,\n\tassertSduiRelease,\n} from \"./structural\";\n\n// Release validation\nexport {\n\tvalidateSduiRelease,\n\tassertSduiReleaseValid,\n} from \"./validate\";\n\n// Release digest\nexport { assertSduiReleaseIntegrity, computeReleaseDigest } from \"./digest\";\n\n// Channel consumption\nexport {\n\tcreateSduiChannel,\n\ttype SduiChannel,\n\ttype SduiChannelConsumptionResult,\n} from \"./channel\";\n\n// JSON schemas\nexport {\n\tSDUI_DOCUMENT_JSON_SCHEMA,\n\tSDUI_RELEASE_JSON_SCHEMA,\n} from \"./schemas\";\n","import type { JsonValue, PortableJsonSchema } from \"@fabricorg/platform\";\nimport type { UsageContractDocument } from \"@fabricorg/gen-capability\";\nimport type { AssemblyLockfile } from \"@fabricorg/assembly\";\n\n/**\n * Version of the SDUI document contract. A vertical negotiates on this, not on\n * this package's version, and it moves only when the serialized shape changes.\n */\nexport const SDUI_DOCUMENT_FORMAT_VERSION = 1 as const;\n\n/**\n * Version of the SDUI token-set contract.\n */\nexport const SDUI_TOKEN_SET_FORMAT_VERSION = 1 as const;\n\n/**\n * Version of the SDUI component-pack contract.\n */\nexport const SDUI_COMPONENT_PACK_FORMAT_VERSION = 1 as const;\n\n/**\n * Version of the promoted SDUI release contract.\n */\nexport const SDUI_RELEASE_FORMAT_VERSION = 2 as const;\n\n// ── Fragment value: literal or capability read reference ────────────────────\n\n/**\n * A capability read reference embedded in fragment props. The `capability://`\n * scheme ties a data binding to a published view; the host resolves it through\n * `ProjectionHost`, never through a direct query.\n */\nexport interface SduiCapabilityRef {\n\t$ref: `capability://${string}`;\n}\n\n/**\n * A value that may appear in fragment props: a JSON literal, an array, an\n * object, or a `capability://` read reference. Direct mutation endpoints,\n * API URLs, or code strings are not valid fragment values.\n */\nexport type SduiFragmentValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| SduiFragmentValue[]\n\t| SduiCapabilityRef\n\t| { [key: string]: SduiFragmentValue };\n\n// ── Action reference: must route through a governed action ─────────────────\n\n/**\n * An action declared on a fragment. The `intent` must be a `capability://`\n * reference to a published action intent; the host dispatches it through\n * `PlatformHost`, preserving governance. A bare endpoint URL, function name,\n * or inline script is a mutation bypass and is rejected.\n */\nexport interface SduiActionRef {\n\tintent: `capability://${string}`;\n\tparams?: Record<string, SduiFragmentValue>;\n}\n\n// ── Fragment: a node in the document tree ───────────────────────────────────\n\n/**\n * A node in an SDUI document tree. A fragment either renders a component from\n * a declared pack, binds data from a capability view, or both. Actions on a\n * fragment are always capability action-intent references — never direct\n * mutations.\n */\nexport interface SduiFragment {\n\t/** Unique identifier within the document. */\n\tid: string;\n\t/** Namespaced component (`pack.Component`) or a core component name. */\n\tcomponent?: string;\n\t/** Props for the component; values may be literals or capability refs. */\n\tprops?: Record<string, SduiFragmentValue>;\n\t/** Named slot this fragment fills in its parent component. */\n\tslot?: string;\n\t/** A capability view reference for data-driven fragments. */\n\tdataRef?: `capability://${string}`;\n\t/** Action handlers; every entry must be a capability action-intent reference. */\n\tactions?: Record<string, SduiActionRef>;\n\t/** Child fragments. */\n\tchildren?: SduiFragment[];\n}\n\n// ── Token set: renderer-neutral design tokens ───────────────────────────────\n\nexport type SduiTokenType = \"color\" | \"spacing\" | \"fontSize\" | \"fontWeight\" | \"radius\" | \"border\" | \"shadow\";\n\nexport interface SduiToken {\n\ttype: SduiTokenType;\n\tvalue: string;\n\tdescription?: string;\n}\n\n/**\n * A versioned set of design tokens. Tokens are semantic, not literal CSS — a\n * renderer maps them to its own platform. Two channels consuming the same\n * token set apply the same visual intent through different renderings.\n */\nexport interface SduiTokenSet {\n\tformatVersion: typeof SDUI_TOKEN_SET_FORMAT_VERSION;\n\tname: string;\n\tversion: string;\n\ttokens: Record<string, SduiToken>;\n}\n\n// ── Component pack: available components for rendering ──────────────────────\n\nexport interface SduiComponentDefinition {\n\t/** Roles this component implements (for adoption-binding validation). */\n\timplements?: string[];\n\t/** JSON Schema for component props. */\n\tpropsSchema?: PortableJsonSchema;\n\t/** Named slots this component accepts. */\n\tslots?: string[];\n}\n\n/**\n * A versioned pack of SDUI components. Compatible with the adoption-bindings\n * `ComponentPackManifest` but adds prop schemas and slot declarations so a\n * document can be validated without a renderer.\n */\nexport interface SduiComponentPack {\n\tformatVersion: typeof SDUI_COMPONENT_PACK_FORMAT_VERSION;\n\tpack: string;\n\tnamespace: string;\n\tversion: string;\n\t/** SHA-256 digest of the published component-pack artifact. */\n\tartifactDigest: string;\n\t/**\n\t * Where this pack is loaded from when it is delivered as a federated\n\t * remote. The artifact digest identifies the pack that was reviewed; this\n\t * is what a shell actually executes, so validation requires the two to be\n\t * locked together or the review covers something other than what runs.\n\t */\n\tremote?: SduiComponentPackRemote;\n\tcomponents: Record<string, SduiComponentDefinition>;\n}\n\n/** Delivery binding for a federated component pack. */\nexport interface SduiComponentPackRemote {\n\t/** Remote entry URL the shell loads. */\n\tentry: string;\n\t/** Subresource-integrity value for that entry, e.g. `sha384-…`. */\n\tintegrity: string;\n\t/** Exposed module path keyed by the component name it provides. */\n\texposes: Record<string, string>;\n}\n\n// ── Document: a versioned tree of fragments ──────────────────────────────────\n\nexport interface SduiComponentPackReference {\n\tpack: string;\n\tnamespace: string;\n\t/** Semver range, e.g. `^1.0.0`. */\n\trange: string;\n}\n\nexport interface SduiTokenSetReference {\n\tname: string;\n\tversion: string;\n}\n\n/**\n * A versioned SDUI document: a tree of fragments, a token-set reference, and\n * the component packs it depends on. This is the build-time input; the release\n * is the validated, resolved output.\n */\nexport interface SduiDocument {\n\tformatVersion: typeof SDUI_DOCUMENT_FORMAT_VERSION;\n\tname: string;\n\tversion: string;\n\t/** The tree rendered when no variant is selected. */\n\troot: SduiFragment;\n\t/**\n\t * Alternative trees a compositor may select at request time, for experiment\n\t * arms and personalization. Every variant is enumerated here and validated\n\t * against the same grants as `root`, and all of them are covered by the\n\t * release digest.\n\t *\n\t * Enumeration is what makes selection safe. A selector that can produce a\n\t * tree outside this set cannot be validated at promotion, so \"selection may\n\t * never widen grants\" would be unenforceable rather than merely unenforced.\n\t */\n\tvariants?: SduiVariant[];\n\ttokenSet: SduiTokenSetReference;\n\tcomponentPacks: SduiComponentPackReference[];\n}\n\n/** One selectable alternative to a document's default tree. */\nexport interface SduiVariant {\n\t/** Stable key the compositor matches on. Unique within the document. */\n\tid: string;\n\t/** The audience or experiment arm this arm serves. */\n\tdescription?: string;\n\troot: SduiFragment;\n}\n\n// ── Release: a promoted, validated, immutable bundle ─────────────────────────\n\nexport interface ResolvedSduiComponentPack {\n\tpack: string;\n\tnamespace: string;\n\tversion: string;\n\trange: string;\n\tartifactDigest: string;\n\t/**\n\t * The locked delivery binding, carried onto the release so the digest\n\t * identifies which remote a channel is expected to load. Omitting it would\n\t * let two releases differing only in their remote share a digest.\n\t */\n\tremote?: SduiComponentPackRemote;\n}\n\n/**\n * A promoted, validated, immutable SDUI release. It bundles a document, a\n * resolved token set, and locked component packs. Two channels (web, mobile,\n * CLI) can consume the same release and render it through their own renderers\n * while reads and actions remain capability references.\n */\nexport interface SduiRelease {\n\tformatVersion: typeof SDUI_RELEASE_FORMAT_VERSION;\n\t/** SHA-256 of the canonical document, token set, resolved packs, grants, and assembly identity. */\n\treleaseDigest: string;\n\t/** Approved application assembly this release was validated against. */\n\tassemblyDigest: string;\n\tdocument: SduiDocument;\n\ttokenSet: SduiTokenSet;\n\tcomponentPacks: ResolvedSduiComponentPack[];\n\tgrants: SduiAuthorizationGrants;\n}\n\n// ── Findings ─────────────────────────────────────────────────────────────────\n\nexport type SduiFindingCode =\n\t| \"unknown_component\"\n\t| \"incompatible_pack\"\n\t| \"unauthorized_data_ref\"\n\t| \"denied_view_ref\"\n\t| \"mutation_bypass\"\n\t| \"denied_intent_ref\"\n\t| \"intent_action_not_found\"\n\t| \"invalid_fragment\"\n\t| \"invalid_action_ref\"\n\t| \"unknown_token\"\n\t| \"duplicate_fragment_id\"\n\t| \"invalid_token_set\"\n\t| \"invalid_component_pack\"\n\t| \"invalid_document\"\n\t| \"missing_token_set\"\n\t| \"missing_component_pack\"\n\t| \"component_pack_not_in_assembly\"\n\t| \"capability_contract_not_in_assembly\"\n\t| \"duplicate_variant_id\"\n\t| \"fragment_grant_exceeds_release\"\n\t| \"remote_not_locked\";\n\nexport interface SduiFinding {\n\tcode: SduiFindingCode;\n\tpath: string;\n\tmessage: string;\n}\n\nexport interface SduiValidationResult {\n\tvalid: boolean;\n\tfindings: SduiFinding[];\n\trelease: SduiRelease | undefined;\n}\n\n// ── Validation input ─────────────────────────────────────────────────────────\n\n/**\n * Explicit capability references authorized for an SDUI release.\n *\n * The presence of a view or action in a supplied usage contract proves that\n * the capability publishes it, not that this document may use it. The\n * experience host must therefore provide both grant lists explicitly.\n */\nexport interface SduiAuthorizationGrants {\n\t/** Full `capability://namespace/view` references allowed in data bindings. */\n\tviews: readonly string[];\n\t/** Full `capability://namespace/intent` references allowed in actions. */\n\tintents: readonly string[];\n\t/**\n\t * Per-fragment narrowing, keyed by fragment id.\n\t *\n\t * The release-wide lists above are the ceiling. A listed fragment may use\n\t * only the references named for it, and the narrowing is inherited by that\n\t * fragment's children, so a page assembled from several teams' fragments\n\t * gets least privilege rather than the union of everything any of them\n\t * needs. A fragment entry can only ever narrow: naming a reference outside\n\t * the release-wide list is an authoring error and is reported rather than\n\t * silently granted.\n\t *\n\t * Keys are fragment ids, which are unique within a tree but may repeat\n\t * across variants, so two variants using the same fragment id share one\n\t * entry. Give them distinct ids when they need distinct narrowing. This\n\t * cannot widen either fragment, since narrowing stays an intersection.\n\t */\n\tfragments?: Record<string, SduiFragmentGrants>;\n}\n\n/** References one fragment subtree may use, drawn from the release-wide lists. */\nexport interface SduiFragmentGrants {\n\tviews?: readonly string[];\n\tintents?: readonly string[];\n}\n\nexport interface SduiValidationInput {\n\tdocument: SduiDocument;\n\ttokenSet: SduiTokenSet;\n\t/** Available component packs for version resolution. */\n\tcomponentPacks: SduiComponentPack[];\n\t/** Capability contracts available for data-ref and action validation. */\n\tcontracts: UsageContractDocument[];\n\t/**\n\t * Explicit authorization grants for every capability view and action\n\t * reference used by the document. Contract membership alone never grants\n\t * access.\n\t */\n\tgrants: SduiAuthorizationGrants;\n\t/** Approved resolved application composition. */\n\tassembly: AssemblyLockfile;\n\t/** Core component vocabulary every renderer implements. */\n\tcoreComponents?: readonly string[];\n}\n\n// Re-export JsonValue for consumers that build contracts programmatically.\nexport type { JsonValue };\n","import { assertPortableJsonSchema, type PortableJsonSchema } from \"@fabricorg/platform\";\nimport { parseSemverRange } from \"@fabricorg/assembly\";\nimport type {\n\tSduiAuthorizationGrants,\n\tSduiComponentPack,\n\tSduiDocument,\n\tSduiFragment,\n\tSduiRelease,\n\tSduiTokenSet,\n\tSduiTokenType,\n} from \"./types\";\nimport { fail, parseCapabilityRef, requireArray, requireRecord, requireString } from \"./helpers\";\n\n// ── Token set structural validation ──────────────────────────────────────────\n\nconst TOKEN_TYPES = new Set<SduiTokenType>([\"color\", \"spacing\", \"fontSize\", \"fontWeight\", \"radius\", \"border\", \"shadow\"]);\n\nexport function assertSduiTokenSet(value: unknown, path = \"tokenSet\"): asserts value is SduiTokenSet {\n\tconst tokenSet = requireRecord(value, path);\n\tif (tokenSet.formatVersion !== 1) {\n\t\tfail(`${path}.formatVersion`, `must be 1, received ${JSON.stringify(tokenSet.formatVersion)}`);\n\t}\n\tif (!/^[a-z][a-z0-9-]*$/.test(requireString(tokenSet.name, `${path}.name`))) {\n\t\tfail(`${path}.name`, \"must be lowercase letters, numbers and hyphens\");\n\t}\n\tif (!/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/.test(requireString(tokenSet.version, `${path}.version`))) {\n\t\tfail(`${path}.version`, \"must be a semver version\");\n\t}\n\tconst tokens = requireRecord(tokenSet.tokens, `${path}.tokens`);\n\tfor (const [name, token] of Object.entries(tokens)) {\n\t\tconst tokenPath = `${path}.tokens.${name}`;\n\t\tif (!/^[a-z][a-z0-9-]*$/.test(name)) fail(tokenPath, \"token name must be lowercase letters, numbers and hyphens\");\n\t\tconst entry = requireRecord(token, tokenPath);\n\t\tconst type = requireString(entry.type, `${tokenPath}.type`);\n\t\tif (!TOKEN_TYPES.has(type as SduiTokenType)) fail(`${tokenPath}.type`, `must be one of ${[...TOKEN_TYPES].join(\", \")}`);\n\t\trequireString(entry.value, `${tokenPath}.value`);\n\t}\n}\n\n// ── Component pack structural validation ────────────────────────────────────\n\nexport function assertSduiComponentPack(value: unknown, path = \"componentPack\"): asserts value is SduiComponentPack {\n\tconst pack = requireRecord(value, path);\n\tif (pack.formatVersion !== 1) {\n\t\tfail(`${path}.formatVersion`, `must be 1, received ${JSON.stringify(pack.formatVersion)}`);\n\t}\n\tif (!/^[a-z][a-z0-9-]*$/.test(requireString(pack.pack, `${path}.pack`))) {\n\t\tfail(`${path}.pack`, \"must be lowercase letters, numbers and hyphens\");\n\t}\n\tif (!/^[a-z][a-z0-9-]*$/.test(requireString(pack.namespace, `${path}.namespace`))) {\n\t\tfail(`${path}.namespace`, \"must be lowercase letters, numbers and hyphens\");\n\t}\n\tif (!/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/.test(requireString(pack.version, `${path}.version`))) {\n\t\tfail(`${path}.version`, \"must be a semver version\");\n\t}\n\tif (!/^[0-9a-f]{64}$/.test(requireString(pack.artifactDigest, `${path}.artifactDigest`))) {\n\t\tfail(`${path}.artifactDigest`, \"must be a lowercase SHA-256 digest\");\n\t}\n\tif (pack.remote !== undefined) {\n\t\tconst remote = requireRecord(pack.remote, `${path}.remote`);\n\t\trequireString(remote.entry, `${path}.remote.entry`);\n\t\tif (!/^sha(256|384|512)-[A-Za-z0-9+/]+={0,2}$/.test(requireString(remote.integrity, `${path}.remote.integrity`))) {\n\t\t\tfail(`${path}.remote.integrity`, \"must be a subresource-integrity value, e.g. \\\"sha384-…\\\"\");\n\t\t}\n\t\tconst exposes = requireRecord(remote.exposes, `${path}.remote.exposes`);\n\t\tfor (const [component, modulePath] of Object.entries(exposes)) {\n\t\t\trequireString(modulePath, `${path}.remote.exposes.${component}`);\n\t\t}\n\t}\n\tconst components = requireRecord(pack.components, `${path}.components`);\n\tfor (const [name, definition] of Object.entries(components)) {\n\t\tconst componentPath = `${path}.components.${name}`;\n\t\tif (!/^[a-z][a-z0-9-]*$/.test(name)) fail(componentPath, \"component name must be lowercase letters, numbers and hyphens\");\n\t\tconst def = requireRecord(definition, componentPath);\n\t\tif (def.implements !== undefined) {\n\t\t\tif (!Array.isArray(def.implements)) fail(`${componentPath}.implements`, \"must be an array\");\n\t\t\tfor (const impl of def.implements as unknown[]) {\n\t\t\t\tif (typeof impl !== \"string\" || !impl.trim()) fail(`${componentPath}.implements`, \"entries must be non-empty strings\");\n\t\t\t}\n\t\t}\n\t\tif (def.propsSchema !== undefined) {\n\t\t\ttry { assertPortableJsonSchema(def.propsSchema as PortableJsonSchema, `${componentPath}.propsSchema`); }\n\t\t\tcatch (error) { fail(componentPath, error instanceof Error ? error.message : String(error)); }\n\t\t}\n\t\tif (def.slots !== undefined) {\n\t\t\tif (!Array.isArray(def.slots)) fail(`${componentPath}.slots`, \"must be an array\");\n\t\t\tfor (const slot of def.slots as unknown[]) {\n\t\t\t\tif (typeof slot !== \"string\" || !/^[a-z][a-z0-9-]*$/.test(slot)) fail(`${componentPath}.slots`, \"slot names must be lowercase letters, numbers and hyphens\");\n\t\t\t}\n\t\t}\n\t}\n}\n\n// ── Fragment structural validation ──────────────────────────────────────────\n\nexport function assertSduiFragment(value: unknown, path = \"fragment\"): asserts value is SduiFragment {\n\tconst fragment = requireRecord(value, path);\n\trequireString(fragment.id, `${path}.id`);\n\tif (fragment.component !== undefined) requireString(fragment.component, `${path}.component`);\n\tif (fragment.slot !== undefined) {\n\t\tif (!/^[a-z][a-z0-9-]*$/.test(requireString(fragment.slot, `${path}.slot`))) {\n\t\t\tfail(`${path}.slot`, \"must be lowercase letters, numbers and hyphens\");\n\t\t}\n\t}\n\tif (fragment.dataRef !== undefined) {\n\t\tconst dataRef = requireString(fragment.dataRef, `${path}.dataRef`);\n\t\tif (!dataRef.startsWith(\"capability://\")) fail(`${path}.dataRef`, \"must be a capability:// reference\");\n\t}\n\tif (fragment.props !== undefined) {\n\t\trequireRecord(fragment.props, `${path}.props`);\n\t}\n\tif (fragment.actions !== undefined) {\n\t\tconst actions = requireRecord(fragment.actions, `${path}.actions`);\n\t\tfor (const [name, ref] of Object.entries(actions)) {\n\t\t\tconst actionPath = `${path}.actions.${name}`;\n\t\t\tconst actionRef = requireRecord(ref, actionPath);\n\t\t\trequireString(actionRef.intent, `${actionPath}.intent`);\n\t\t}\n\t}\n\tif (fragment.children !== undefined) {\n\t\tconst children = requireArray(fragment.children, `${path}.children`);\n\t\tchildren.forEach((child, index) => assertSduiFragment(child, `${path}.children[${index}]`));\n\t}\n}\n\n// ── Document structural validation ───────────────────────────────────────────\n\nexport function assertSduiDocument(value: unknown, path = \"document\"): asserts value is SduiDocument {\n\tconst document = requireRecord(value, path);\n\tif (document.formatVersion !== 1) {\n\t\tfail(`${path}.formatVersion`, `must be 1, received ${JSON.stringify(document.formatVersion)}`);\n\t}\n\tif (!/^[a-z][a-z0-9-]*$/.test(requireString(document.name, `${path}.name`))) {\n\t\tfail(`${path}.name`, \"must be lowercase letters, numbers and hyphens\");\n\t}\n\tif (!/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/.test(requireString(document.version, `${path}.version`))) {\n\t\tfail(`${path}.version`, \"must be a semver version\");\n\t}\n\tassertSduiFragment(document.root, `${path}.root`);\n\tif (document.variants !== undefined) {\n\t\trequireArray(document.variants, `${path}.variants`).forEach((entry, index) => {\n\t\t\tconst variantPath = `${path}.variants[${index}]`;\n\t\t\tconst variant = requireRecord(entry, variantPath);\n\t\t\tif (!/^[a-z][a-z0-9-]*$/.test(requireString(variant.id, `${variantPath}.id`))) {\n\t\t\t\tfail(`${variantPath}.id`, \"must be lowercase letters, numbers and hyphens\");\n\t\t\t}\n\t\t\tif (variant.description !== undefined) requireString(variant.description, `${variantPath}.description`);\n\t\t\tassertSduiFragment(variant.root, `${variantPath}.root`);\n\t\t});\n\t}\n\tconst tokenSet = requireRecord(document.tokenSet, `${path}.tokenSet`);\n\trequireString(tokenSet.name, `${path}.tokenSet.name`);\n\trequireString(tokenSet.version, `${path}.tokenSet.version`);\n\trequireArray(document.componentPacks, `${path}.componentPacks`).forEach((entry, index) => {\n\t\tconst pack = requireRecord(entry, `${path}.componentPacks[${index}]`);\n\t\trequireString(pack.pack, `${path}.componentPacks[${index}].pack`);\n\t\trequireString(pack.namespace, `${path}.componentPacks[${index}].namespace`);\n\t\trequireString(pack.range, `${path}.componentPacks[${index}].range`);\n\t});\n}\n\n// ── Authorization grants structural validation ──────────────────────────────\n\n/**\n * Validate the grant envelope before semantic release checks. Grants are\n * intentionally references rather than capability names: a capability may\n * publish several views and intents with different authorization decisions.\n */\nexport function assertSduiAuthorizationGrants(\n\tvalue: unknown,\n\tpath = \"grants\",\n): asserts value is SduiAuthorizationGrants {\n\tconst grants = requireRecord(value, path);\n\tconst views = requireArray(grants.views, `${path}.views`);\n\tconst intents = requireArray(grants.intents, `${path}.intents`);\n\tfor (const [index, reference] of views.entries()) {\n\t\tconst referencePath = `${path}.views[${index}]`;\n\t\tif (!parseCapabilityRef(requireString(reference, referencePath))) {\n\t\t\tfail(referencePath, \"must be a valid capability:// reference\");\n\t\t}\n\t}\n\tfor (const [index, reference] of intents.entries()) {\n\t\tconst referencePath = `${path}.intents[${index}]`;\n\t\tif (!parseCapabilityRef(requireString(reference, referencePath))) {\n\t\t\tfail(referencePath, \"must be a valid capability:// reference\");\n\t\t}\n\t}\n\tif (grants.fragments !== undefined) {\n\t\tconst fragments = requireRecord(grants.fragments, `${path}.fragments`);\n\t\t// An object literal written `{ __proto__: { … } }` sets the prototype\n\t\t// instead of creating the entry, so the narrowing would disappear and the\n\t\t// fragment would keep release-wide grants. Fail rather than silently widen.\n\t\tconst prototype = Object.getPrototypeOf(fragments);\n\t\tif (prototype !== Object.prototype && prototype !== null) {\n\t\t\tfail(`${path}.fragments`, \"must be a plain object; a fragment grant assigned through __proto__ would be silently discarded\");\n\t\t}\n\t\tfor (const [fragmentId, declared] of Object.entries(fragments)) {\n\t\t\tconst fragmentPath = `${path}.fragments.${fragmentId}`;\n\t\t\tconst scoped = requireRecord(declared, fragmentPath);\n\t\t\tfor (const field of [\"views\", \"intents\"] as const) {\n\t\t\t\tif (scoped[field] === undefined) continue;\n\t\t\t\trequireArray(scoped[field], `${fragmentPath}.${field}`).forEach((reference, index) => {\n\t\t\t\t\tconst referencePath = `${fragmentPath}.${field}[${index}]`;\n\t\t\t\t\tif (!parseCapabilityRef(requireString(reference, referencePath))) {\n\t\t\t\t\t\tfail(referencePath, \"must be a valid capability:// reference\");\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Validate a promoted release loaded from an untyped persistence or network seam. */\nexport function assertSduiRelease(value: unknown, path = \"release\"): asserts value is SduiRelease {\n\tconst release = requireRecord(value, path);\n\tif (release.formatVersion !== 2) {\n\t\tfail(`${path}.formatVersion`, `must be 2, received ${JSON.stringify(release.formatVersion)}`);\n\t}\n\tfor (const field of [\"releaseDigest\", \"assemblyDigest\"] as const) {\n\t\tif (!/^[0-9a-f]{64}$/.test(requireString(release[field], `${path}.${field}`))) {\n\t\t\tfail(`${path}.${field}`, \"must be a lowercase SHA-256 digest\");\n\t\t}\n\t}\n\tassertSduiDocument(release.document, `${path}.document`);\n\tassertSduiTokenSet(release.tokenSet, `${path}.tokenSet`);\n\tassertSduiAuthorizationGrants(release.grants, `${path}.grants`);\n\trequireArray(release.componentPacks, `${path}.componentPacks`).forEach((value, index) => {\n\t\tconst packPath = `${path}.componentPacks[${index}]`;\n\t\tconst pack = requireRecord(value, packPath);\n\t\tfor (const field of [\"pack\", \"namespace\"] as const) {\n\t\t\tif (!/^[a-z][a-z0-9-]*$/.test(requireString(pack[field], `${packPath}.${field}`))) {\n\t\t\t\tfail(`${packPath}.${field}`, \"must be lowercase letters, numbers and hyphens\");\n\t\t\t}\n\t\t}\n\t\tif (!/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/.test(\n\t\t\trequireString(pack.version, `${packPath}.version`),\n\t\t)) {\n\t\t\tfail(`${packPath}.version`, \"must be a semver version\");\n\t\t}\n\t\tconst range = requireString(pack.range, `${packPath}.range`);\n\t\tif (!parseSemverRange(range)) {\n\t\t\tfail(`${packPath}.range`, \"must be a supported semver range\");\n\t\t}\n\t\tif (!/^[0-9a-f]{64}$/.test(requireString(pack.artifactDigest, `${packPath}.artifactDigest`))) {\n\t\t\tfail(`${packPath}.artifactDigest`, \"must be a lowercase SHA-256 digest\");\n\t\t}\n\t});\n}\n","// ── Shared validation helpers ───────────────────────────────────────────────\n\nexport function fail(path: string, message: string): never {\n\tthrow new Error(`SDUI ${path} ${message}.`);\n}\n\nexport function requireString(value: unknown, path: string): string {\n\tif (typeof value !== \"string\" || !value.trim()) fail(path, \"must be a non-empty string\");\n\treturn value;\n}\n\nexport function requireRecord(value: unknown, path: string): Record<string, unknown> {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) fail(path, \"must be an object\");\n\treturn value as Record<string, unknown>;\n}\n\nexport function requireArray(value: unknown, path: string): unknown[] {\n\tif (!Array.isArray(value)) fail(path, \"must be an array\");\n\treturn value;\n}\n\n// ── Capability reference parsing ────────────────────────────────────────────\n\nexport function parseCapabilityRef(ref: string): { namespace: string; name: string } | undefined {\n\tconst match = /^capability:\\/\\/([a-z][a-z0-9-]*)\\/(.+)$/.exec(ref);\n\tif (!match) return undefined;\n\treturn { namespace: match[1]!, name: match[2]! };\n}\n","import {\n\tassertAssemblyLockfile,\n\tcomputeUsageContractDocumentDigest,\n\tparseSemverRange,\n\tresolveVersionRange,\n} from \"@fabricorg/assembly\";\nimport { assertUsageContractDocument } from \"@fabricorg/gen-capability\";\nimport type {\n\tResolvedSduiComponentPack,\n\tSduiComponentPack,\n\tSduiDocument,\n\tSduiFinding,\n\tSduiFindingCode,\n\tSduiRelease,\n\tSduiTokenSet,\n\tSduiValidationInput,\n\tSduiValidationResult,\n} from \"./types\";\nimport { canonicalFragmentGrants, releaseDigest } from \"./digest\";\nimport { assertSduiAuthorizationGrants, assertSduiComponentPack, assertSduiDocument, assertSduiTokenSet } from \"./structural\";\nimport {\n\tbuildGrantedReferences,\n\tbuildKnownActionIntents,\n\tbuildKnownViews,\n\tvalidateIntentActionDeclarations,\n} from \"./capabilities\";\nimport { walkFragment } from \"./walker\";\n\n/**\n * Validate an SDUI document and its dependencies, producing a promoted release\n * when every check passes. This is the single build gate: it rejects unknown\n * components, incompatible packs, unauthorized data references, and mutation\n * bypasses. Returns every finding rather than throwing, so one CI run tells a\n * vertical everything it has to change. Use {@link assertSduiReleaseValid} to\n * throw on the first invalid result.\n */\nexport function validateSduiRelease(input: SduiValidationInput): SduiValidationResult {\n\t// ── Structural validation ────────────────────────────────────────────\n\tif (!input.assembly) throw new Error(\"An approved assembly lockfile is required for every SDUI release.\");\n\tassertSduiDocument(input.document);\n\tassertSduiTokenSet(input.tokenSet);\n\tfor (const pack of input.componentPacks) assertSduiComponentPack(pack);\n\tfor (const contract of input.contracts) assertUsageContractDocument(contract);\n\tassertSduiAuthorizationGrants(input.grants);\n\tassertAssemblyLockfile(input.assembly);\n\tconst contracts = input.contracts.map((document) => document.capability);\n\n\tconst findings: SduiFinding[] = [];\n\tconst add = (code: SduiFindingCode, path: string, message: string): void => {\n\t\tfindings.push({ code, path, message });\n\t};\n\n\t// ── Token set reference matches ─────────────────────────────────────\n\tif (input.document.tokenSet.name !== input.tokenSet.name) {\n\t\tadd(\"missing_token_set\", \"document.tokenSet.name\",\n\t\t\t`document references token set \"${input.document.tokenSet.name}\" but the provided set is \"${input.tokenSet.name}\"`);\n\t}\n\tif (input.document.tokenSet.version !== input.tokenSet.version) {\n\t\tadd(\"missing_token_set\", \"document.tokenSet.version\",\n\t\t\t`document references token set version \"${input.document.tokenSet.version}\" but the provided set is version \"${input.tokenSet.version}\"`);\n\t}\n\n\t// ── Component pack resolution ──────────────────────────────────────\n\tconst packsByKey = new Map<string, SduiComponentPack[]>();\n\tfor (const pack of input.componentPacks) {\n\t\tconst key = `${pack.namespace}/${pack.pack}`;\n\t\tconst list = packsByKey.get(key) ?? [];\n\t\tlist.push(pack);\n\t\tpacksByKey.set(key, list);\n\t}\n\n\tconst resolvedPacks: ResolvedSduiComponentPack[] = [];\n\tconst resolvedPackDefinitions: SduiComponentPack[] = [];\n\tfor (const ref of input.document.componentPacks) {\n\t\tconst key = `${ref.namespace}/${ref.pack}`;\n\t\tconst available = packsByKey.get(key) ?? [];\n\t\tconst range = parseSemverRange(ref.range);\n\t\tif (!range) {\n\t\t\tadd(\"incompatible_pack\", `document.componentPacks.${key}`,\n\t\t\t\t`no available version of pack \"${key}\" satisfies range \"${ref.range}\"`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst resolvedVersion = resolveVersionRange(range, available.map((pack) => pack.version));\n\t\tif (!resolvedVersion) {\n\t\t\tadd(\"incompatible_pack\", `document.componentPacks.${key}`,\n\t\t\t\t`no available version of pack \"${key}\" satisfies range \"${ref.range}\"`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst resolved = available.find((pack) => pack.version === resolvedVersion)!;\n\t\tresolvedPackDefinitions.push(resolved);\n\t\tresolvedPacks.push({\n\t\t\tpack: resolved.pack,\n\t\t\tnamespace: resolved.namespace,\n\t\t\tversion: resolved.version,\n\t\t\trange: ref.range,\n\t\t\tartifactDigest: resolved.artifactDigest,\n\t\t\t...(resolved.remote ? { remote: resolved.remote } : {}),\n\t\t});\n\t}\n\n\t// ── Approved assembly identity ─────────────────────────────────────\n\t{\n\t\tfor (const pack of resolvedPacks) {\n\t\t\tconst approved = input.assembly.componentPacks.find((candidate) =>\n\t\t\t\tcandidate.namespace === pack.namespace &&\n\t\t\t\tcandidate.pack === pack.pack &&\n\t\t\t\tcandidate.version === pack.version &&\n\t\t\t\tcandidate.artifactDigest === pack.artifactDigest\n\t\t\t);\n\t\t\tif (!approved) {\n\t\t\t\tadd(\"component_pack_not_in_assembly\", `componentPacks.${pack.namespace}/${pack.pack}`,\n\t\t\t\t\t`pack \"${pack.namespace}/${pack.pack}@${pack.version}\" with artifact digest \"${pack.artifactDigest}\" is not in assembly \"${input.assembly.assemblyDigest}\"`);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// A federated pack executes whatever its remote entry serves. Unless\n\t\t\t// the entry and its integrity are the ones assembly locked, the\n\t\t\t// approved artifact digest says nothing about what actually runs.\n\t\t\tconst declaredRemote = resolvedPackDefinitions.find((definition) =>\n\t\t\t\tdefinition.namespace === pack.namespace &&\n\t\t\t\tdefinition.pack === pack.pack &&\n\t\t\t\tdefinition.version === pack.version &&\n\t\t\t\tdefinition.artifactDigest === pack.artifactDigest)?.remote;\n\t\t\tconst remotePath = `componentPacks.${pack.namespace}/${pack.pack}.remote`;\n\t\t\tif (declaredRemote && !approved.remote) {\n\t\t\t\tadd(\"remote_not_locked\", remotePath,\n\t\t\t\t\t`pack \"${pack.namespace}/${pack.pack}\" is delivered as a federated remote, which assembly \"${input.assembly.assemblyDigest}\" has not locked`);\n\t\t\t} else if (declaredRemote && approved.remote) {\n\t\t\t\tif (declaredRemote.entry !== approved.remote.entry) {\n\t\t\t\t\tadd(\"remote_not_locked\", `${remotePath}.entry`,\n\t\t\t\t\t\t`remote entry \"${declaredRemote.entry}\" does not match the locked entry \"${approved.remote.entry}\"`);\n\t\t\t\t}\n\t\t\t\tif (declaredRemote.integrity !== approved.remote.integrity) {\n\t\t\t\t\tadd(\"remote_not_locked\", `${remotePath}.integrity`,\n\t\t\t\t\t\t`remote integrity \"${declaredRemote.integrity}\" does not match the locked integrity \"${approved.remote.integrity}\"`);\n\t\t\t\t}\n\t\t\t\tif (canonicalExposes(declaredRemote.exposes) !== canonicalExposes(approved.remote.exposes)) {\n\t\t\t\t\tadd(\"remote_not_locked\", `${remotePath}.exposes`,\n\t\t\t\t\t\t\"remote exposed modules do not match the locked mapping\");\n\t\t\t\t}\n\t\t\t} else if (!declaredRemote && approved.remote) {\n\t\t\t\tadd(\"remote_not_locked\", remotePath,\n\t\t\t\t\t`assembly \"${input.assembly.assemblyDigest}\" locks a federated remote for \"${pack.namespace}/${pack.pack}\", but the supplied pack declares none`);\n\t\t\t}\n\t\t}\n\t\tfor (const document of input.contracts) {\n\t\t\tconst approved = input.assembly.capabilities.find((capability) =>\n\t\t\t\tcapability.namespace === document.capability.namespace &&\n\t\t\t\tcapability.usageContractDigest === computeUsageContractDocumentDigest(document)\n\t\t\t);\n\t\t\tif (!approved) {\n\t\t\t\tadd(\"capability_contract_not_in_assembly\", `contracts.${document.capability.namespace}`,\n\t\t\t\t\t`contract \"${document.capability.namespace}\" is not the generated usage-contract document approved by assembly \"${input.assembly.assemblyDigest}\"`);\n\t\t\t}\n\t\t}\n\t}\n\n\t// ── Build known component set from resolved packs ───────────────────\n\tconst knownComponents = new Set<string>();\n\tfor (const pack of resolvedPackDefinitions) {\n\t\tfor (const name of Object.keys(pack.components)) {\n\t\t\tknownComponents.add(`${pack.namespace}.${name}`);\n\t\t}\n\t}\n\tconst coreComponents = new Set(input.coreComponents ?? []);\n\n\t// ── Build known views and action intents from contracts ─────────────\n\tconst knownViews = buildKnownViews(contracts);\n\tconst knownIntents = buildKnownActionIntents(contracts);\n\tconst grantedViews = buildGrantedReferences(input.grants.views, \"grants.views\");\n\tconst grantedIntents = buildGrantedReferences(input.grants.intents, \"grants.intents\");\n\n\t// ── Verify experience intents resolve to governed actions ───────────\n\tvalidateIntentActionDeclarations(contracts, add);\n\n\t// ── Per-fragment narrowing may only narrow ──────────────────────────\n\t// Intersection in the walker already makes an out-of-release reference\n\t// unusable; reporting it here turns a silently ineffective grant into an\n\t// authoring error, which is what the author actually needs to know.\n\tconst fragmentGrants = new Map<string, { views?: readonly string[]; intents?: readonly string[] }>();\n\tfor (const [fragmentId, declared] of Object.entries(input.grants.fragments ?? {})) {\n\t\tfor (const view of declared.views ?? []) {\n\t\t\tif (!grantedViews.has(view)) {\n\t\t\t\tadd(\"fragment_grant_exceeds_release\", `grants.fragments.${fragmentId}.views`,\n\t\t\t\t\t`fragment \"${fragmentId}\" is granted view \"${view}\", which the release itself does not grant`);\n\t\t\t}\n\t\t}\n\t\tfor (const intent of declared.intents ?? []) {\n\t\t\tif (!grantedIntents.has(intent)) {\n\t\t\t\tadd(\"fragment_grant_exceeds_release\", `grants.fragments.${fragmentId}.intents`,\n\t\t\t\t\t`fragment \"${fragmentId}\" is granted intent \"${intent}\", which the release itself does not grant`);\n\t\t\t}\n\t\t}\n\t\tfragmentGrants.set(fragmentId, declared);\n\t}\n\n\t// ── Walk the default tree and every selectable variant ──────────────\n\t// Each tree gets its own id set: ids must be unique within a tree, but two\n\t// variants of the same page naturally reuse them, and only one ever renders.\n\tconst walkTree = (root: typeof input.document.root, path: string): void => {\n\t\twalkFragment(root, path, {\n\t\t\tids: new Set(),\n\t\t\tknownComponents,\n\t\t\tknownViews,\n\t\t\tgrantedViews,\n\t\t\tknownIntents,\n\t\t\tgrantedIntents,\n\t\t\tfragmentGrants,\n\t\t\tcoreComponents,\n\t\t\tfindings,\n\t\t\tadd,\n\t\t});\n\t};\n\n\twalkTree(input.document.root, \"document.root\");\n\n\tconst seenVariantIds = new Set<string>();\n\t(input.document.variants ?? []).forEach((variant, index) => {\n\t\tif (seenVariantIds.has(variant.id)) {\n\t\t\tadd(\"duplicate_variant_id\", `document.variants[${index}].id`,\n\t\t\t\t`variant id \"${variant.id}\" is declared more than once`);\n\t\t} else {\n\t\t\tseenVariantIds.add(variant.id);\n\t\t}\n\t\twalkTree(variant.root, `document.variants[${index}].root`);\n\t});\n\n\t// ── Produce release ─────────────────────────────────────────────────\n\tif (findings.length > 0) {\n\t\treturn { valid: false, findings, release: undefined };\n\t}\n\n\tconst release: SduiRelease = {\n\t\tformatVersion: 2,\n\t\treleaseDigest: releaseDigest(\n\t\t\tinput.document,\n\t\t\tinput.tokenSet,\n\t\t\tresolvedPacks,\n\t\t\tinput.grants,\n\t\t\tinput.assembly.assemblyDigest,\n\t\t),\n\t\tassemblyDigest: input.assembly.assemblyDigest,\n\t\tdocument: input.document,\n\t\ttokenSet: input.tokenSet,\n\t\tcomponentPacks: [...resolvedPacks].sort((a, b) => {\n\t\t\tconst key = (e: ResolvedSduiComponentPack) => `${e.namespace}/${e.pack}`;\n\t\t\treturn key(a) < key(b) ? -1 : key(a) > key(b) ? 1 : 0;\n\t\t}),\n\t\tgrants: {\n\t\t\tviews: [...input.grants.views].sort(),\n\t\t\tintents: [...input.grants.intents].sort(),\n\t\t\t...(input.grants.fragments ? { fragments: canonicalFragmentGrants(input.grants.fragments) } : {}),\n\t\t},\n\t};\n\n\treturn { valid: true, findings: [], release };\n}\n\n/**\n * Throw with every finding listed, for use as a build step. Returns the\n * promoted release when valid.\n */\nexport function assertSduiReleaseValid(input: SduiValidationInput): SduiRelease {\n\tconst result = validateSduiRelease(input);\n\tif (result.valid) return result.release!;\n\tthrow new Error([\n\t\t`SDUI release \"${input.document.name}@${input.document.version}\" is not valid:`,\n\t\t...result.findings.map((finding) => ` - [${finding.code}] ${finding.path}: ${finding.message}`),\n\t].join(\"\\n\"));\n}\n\n\n/** Stable comparison key for an exposed-module mapping. */\nfunction canonicalExposes(exposes: Record<string, string>): string {\n\treturn JSON.stringify(\n\t\tObject.keys(exposes).sort().map((component) => [component, exposes[component]]),\n\t);\n}\n","import { createHash } from \"node:crypto\";\nimport type {\n\tResolvedSduiComponentPack,\n\tSduiAuthorizationGrants,\n\tSduiComponentPackReference,\n\tSduiDocument,\n\tSduiRelease,\n\tSduiTokenSet,\n} from \"./types\";\nimport { assertSduiRelease } from \"./structural\";\n\n// ── Stable serialization ───────────────────────────────────────────────────\n\nfunction sortJson(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(sortJson);\n\tif (value && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value as Record<string, unknown>)\n\t\t\t\t.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))\n\t\t\t\t.map(([key, child]) => [key, sortJson(child)]),\n\t\t);\n\t}\n\treturn value;\n}\n\nfunction stableStringify(value: unknown): string {\n\treturn JSON.stringify(sortJson(value));\n}\n\n/**\n * Canonical form for per-fragment grants: fragment ids and their reference\n * lists in sorted order.\n *\n * The digest and the promoted release must both use this. Hashing the caller's\n * raw grants while storing a canonicalised copy produces a release that fails\n * its own integrity check the moment a hand-authored grant file is not already\n * sorted. `Object.fromEntries` is deliberate: plain assignment to a key named\n * `__proto__` sets the prototype instead of recording the entry, which would\n * drop that fragment's narrowing from the release.\n */\nexport function canonicalFragmentGrants(\n\tfragments: Record<string, { views?: readonly string[]; intents?: readonly string[] }> | undefined,\n): Record<string, { views?: string[]; intents?: string[] }> {\n\tif (!fragments) return {};\n\treturn Object.fromEntries(\n\t\tObject.keys(fragments)\n\t\t\t.sort()\n\t\t\t.map((fragmentId) => {\n\t\t\t\tconst declared = fragments[fragmentId] as { views?: readonly string[]; intents?: readonly string[] };\n\t\t\t\treturn [fragmentId, {\n\t\t\t\t\t...(declared.views ? { views: [...declared.views].sort() } : {}),\n\t\t\t\t\t...(declared.intents ? { intents: [...declared.intents].sort() } : {}),\n\t\t\t\t}];\n\t\t\t}),\n\t);\n}\n\nexport function releaseDigest(\n\tdocument: SduiDocument,\n\ttokenSet: SduiTokenSet,\n\tcomponentPacks: ResolvedSduiComponentPack[],\n\tgrants: SduiAuthorizationGrants,\n\tassemblyDigest: string,\n): string {\n\tconst canonical = stableStringify({\n\t\tdocument: {\n\t\t\tformatVersion: document.formatVersion,\n\t\t\tname: document.name,\n\t\t\tversion: document.version,\n\t\t\troot: document.root,\n\t\t\t// Selectable trees, so two documents differing only in their variants\n\t\t\t// must not share a digest. Sorted by id, because reordering the same\n\t\t\t// set does not change which trees can render. Omitted entirely when\n\t\t\t// absent, so a document that declares none digests exactly as it did\n\t\t\t// before variants existed.\n\t\t\t...(document.variants?.length\n\t\t\t\t? {\n\t\t\t\t\tvariants: [...document.variants].sort((left, right) =>\n\t\t\t\t\t\tleft.id < right.id ? -1 : left.id > right.id ? 1 : 0),\n\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\ttokenSet: document.tokenSet,\n\t\t\tcomponentPacks: [...document.componentPacks].sort((a: SduiComponentPackReference, b: SduiComponentPackReference) => {\n\t\t\t\tconst key = (e: SduiComponentPackReference) => `${e.namespace}/${e.pack}`;\n\t\t\t\treturn key(a) < key(b) ? -1 : key(a) > key(b) ? 1 : 0;\n\t\t\t}),\n\t\t},\n\t\ttokenSet: {\n\t\t\tformatVersion: tokenSet.formatVersion,\n\t\t\tname: tokenSet.name,\n\t\t\tversion: tokenSet.version,\n\t\t\ttokens: tokenSet.tokens,\n\t\t},\n\t\tcomponentPacks: [...componentPacks].sort((a, b) => {\n\t\t\tconst key = (e: ResolvedSduiComponentPack) => `${e.namespace}/${e.pack}`;\n\t\t\treturn key(a) < key(b) ? -1 : key(a) > key(b) ? 1 : 0;\n\t\t}),\n\t\tgrants: {\n\t\t\tviews: [...grants.views].sort(),\n\t\t\tintents: [...grants.intents].sort(),\n\t\t\t// Omitted when absent for the same reason as variants: a release with\n\t\t\t// no per-fragment narrowing must digest as it did before the field\n\t\t\t// existed, or every previously promoted release stops verifying.\n\t\t\t...(grants.fragments && Object.keys(grants.fragments).length\n\t\t\t\t? { fragments: canonicalFragmentGrants(grants.fragments) }\n\t\t\t\t: {}),\n\t\t},\n\t\tassemblyDigest,\n\t});\n\treturn createHash(\"sha256\").update(canonical).digest(\"hex\");\n}\n\n/**\n * Compute the canonical release digest for a valid release. Two releases with\n * the same document, token set, and resolved packs produce the same digest,\n * so a channel can verify it is consuming the exact release it was built for.\n */\nexport function computeReleaseDigest(\n\tdocument: SduiDocument,\n\ttokenSet: SduiTokenSet,\n\tcomponentPacks: ResolvedSduiComponentPack[],\n\tgrants: SduiAuthorizationGrants,\n\tassemblyDigest: string,\n): string {\n\treturn releaseDigest(document, tokenSet, componentPacks, grants, assemblyDigest);\n}\n\n/** Reject promoted release content that no longer matches its immutable digest. */\nexport function assertSduiReleaseIntegrity(release: SduiRelease): void {\n\tassertSduiRelease(release);\n\tconst expected = releaseDigest(\n\t\trelease.document,\n\t\trelease.tokenSet,\n\t\trelease.componentPacks,\n\t\trelease.grants,\n\t\trelease.assemblyDigest,\n\t);\n\tif (release.releaseDigest !== expected) {\n\t\tthrow new Error(`SDUI release releaseDigest does not match promoted content; expected \"${expected}\".`);\n\t}\n}\n","import type { UsageContract } from \"@fabricorg/gen-capability\";\nimport type { SduiFindingCode } from \"./types\";\nimport { fail, parseCapabilityRef } from \"./helpers\";\n\nexport function buildKnownViews(contracts: readonly UsageContract[]): Set<string> {\n\tconst views = new Set<string>();\n\tfor (const contract of contracts) {\n\t\tfor (const view of contract.views) {\n\t\t\tconst name = view.name.startsWith(`${contract.namespace}/`)\n\t\t\t\t? view.name.slice(contract.namespace.length + 1)\n\t\t\t\t: view.name;\n\t\t\tviews.add(`${contract.namespace}/${name}`);\n\t\t}\n\t}\n\treturn views;\n}\n\nexport function buildKnownActionIntents(contracts: readonly UsageContract[]): Set<string> {\n\tconst intents = new Set<string>();\n\tfor (const contract of contracts) {\n\t\tconst experience = contract.extensions?.[\"fabric.experience/v1\"] as\n\t\t\t| { actionIntents?: Array<{ name: string; actionId: string }> }\n\t\t\t| undefined;\n\t\tfor (const intent of experience?.actionIntents ?? []) {\n\t\t\t// The intent name is dotted (e.g., \"orders.submit\"); the capability\n\t\t\t// ref uses the part after the namespace prefix.\n\t\t\tconst shortName = intent.name.startsWith(`${contract.namespace}.`)\n\t\t\t\t? intent.name.slice(contract.namespace.length + 1)\n\t\t\t\t: intent.name;\n\t\t\tintents.add(`${contract.namespace}/${shortName}`);\n\t\t}\n\t}\n\treturn intents;\n}\n\nexport function buildGrantedReferences(\n\treferences: readonly string[],\n\tpath: string,\n): Set<string> {\n\tconst granted = new Set<string>();\n\tfor (const [index, reference] of references.entries()) {\n\t\tconst referencePath = `${path}[${index}]`;\n\t\tif (!parseCapabilityRef(reference)) {\n\t\t\tfail(referencePath, \"must be a valid capability:// reference\");\n\t\t}\n\t\tgranted.add(reference);\n\t}\n\treturn granted;\n}\n\nexport function validateIntentActionDeclarations(\n\tcontracts: readonly UsageContract[],\n\tadd: (code: SduiFindingCode, path: string, message: string) => void,\n): void {\n\tfor (const contract of contracts) {\n\t\tconst experience = contract.extensions?.[\"fabric.experience/v1\"] as\n\t\t\t| { actionIntents?: Array<{ name: string; actionId: string }> }\n\t\t\t| undefined;\n\t\tconst actions = new Set(contract.actions.map((action) => action.actionId));\n\t\tfor (const [index, intent] of (experience?.actionIntents ?? []).entries()) {\n\t\t\tif (!actions.has(intent.actionId)) {\n\t\t\t\tadd(\n\t\t\t\t\t\"intent_action_not_found\",\n\t\t\t\t\t`contracts.${contract.namespace}.actionIntents[${index}].actionId`,\n\t\t\t\t\t`intent \"${intent.name}\" references action \"${intent.actionId}\", which the capability does not declare`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n","import type { SduiCapabilityRef, SduiFinding, SduiFindingCode, SduiFragment, SduiFragmentValue } from \"./types\";\nimport { parseCapabilityRef } from \"./helpers\";\n\n/** Deep enough for any authored document; shallow enough to bound a cycle. */\nconst MAX_PROP_DEPTH = 64;\n\n// ── Fragment tree walker ────────────────────────────────────────────────────\n\nexport interface FragmentWalkContext {\n\tids: Set<string>;\n\tknownComponents: Set<string>;\n\tknownViews: Set<string>;\n\t/** Grants in force for the fragment being walked, already narrowed. */\n\tgrantedViews: ReadonlySet<string>;\n\tknownIntents: Set<string>;\n\tgrantedIntents: ReadonlySet<string>;\n\t/** Per-fragment narrowing declared by the release, keyed by fragment id. */\n\tfragmentGrants?: ReadonlyMap<string, { views?: readonly string[]; intents?: readonly string[] }>;\n\tcoreComponents: Set<string>;\n\tfindings: SduiFinding[];\n\tadd: (code: SduiFindingCode, path: string, message: string) => void;\n}\n\nexport function isCapabilityRefValue(value: unknown): value is SduiCapabilityRef {\n\treturn (\n\t\tvalue !== null &&\n\t\ttypeof value === \"object\" &&\n\t\t!Array.isArray(value) &&\n\t\ttypeof (value as SduiCapabilityRef).$ref === \"string\" &&\n\t\t(value as SduiCapabilityRef).$ref.startsWith(\"capability://\")\n\t);\n}\n\n/**\n * Intersect the grants in force with what a fragment declares. Intersection\n * rather than replacement is what makes a fragment entry unable to widen: a\n * reference the release never granted cannot re-enter through a subtree.\n */\nfunction narrowGrants(current: ReadonlySet<string>, declared: readonly string[] | undefined): ReadonlySet<string> {\n\tif (declared === undefined) return current;\n\treturn new Set(declared.filter((reference) => current.has(reference)));\n}\n\nexport function walkFragment(fragment: SduiFragment, path: string, context: FragmentWalkContext): void {\n\t// ── Narrow grants for this fragment and everything beneath it ───────\n\tconst declared = context.fragmentGrants?.get(fragment.id);\n\tconst scoped: FragmentWalkContext = declared\n\t\t? {\n\t\t\t...context,\n\t\t\tgrantedViews: narrowGrants(context.grantedViews, declared.views),\n\t\t\tgrantedIntents: narrowGrants(context.grantedIntents, declared.intents),\n\t\t}\n\t\t: context;\n\n\t// ── Duplicate fragment IDs ──────────────────────────────────────────\n\tif (scoped.ids.has(fragment.id)) {\n\t\tscoped.add(\"duplicate_fragment_id\", `${path}.id`, `fragment id \"${fragment.id}\" is declared more than once`);\n\t} else {\n\t\tscoped.ids.add(fragment.id);\n\t}\n\n\t// ── Unknown components ──────────────────────────────────────────────\n\tif (fragment.component !== undefined) {\n\t\tconst separator = fragment.component.indexOf(\".\");\n\t\tif (separator === -1) {\n\t\t\tif (!scoped.coreComponents.has(fragment.component)) {\n\t\t\t\tscoped.add(\"unknown_component\", `${path}.component`,\n\t\t\t\t\t`component \"${fragment.component}\" is not a core component or in any declared pack`);\n\t\t\t}\n\t\t} else if (!scoped.knownComponents.has(fragment.component)) {\n\t\t\tscoped.add(\"unknown_component\", `${path}.component`,\n\t\t\t\t`component \"${fragment.component}\" is not in any declared component pack`);\n\t\t}\n\t}\n\n\t// ── Unauthorized data references ────────────────────────────────────\n\tif (fragment.dataRef !== undefined) {\n\t\tconst ref = parseCapabilityRef(fragment.dataRef);\n\t\tif (!ref) {\n\t\t\tscoped.add(\"unauthorized_data_ref\", `${path}.dataRef`,\n\t\t\t\t`\"${fragment.dataRef}\" is not a valid capability:// view reference`);\n\t\t} else if (!scoped.knownViews.has(`${ref.namespace}/${ref.name}`)) {\n\t\t\tscoped.add(\"unauthorized_data_ref\", `${path}.dataRef`,\n\t\t\t\t`fragment references view \"${fragment.dataRef}\" which no known capability publishes`);\n\t\t} else if (!scoped.grantedViews.has(fragment.dataRef)) {\n\t\t\tscoped.add(\"denied_view_ref\", `${path}.dataRef`,\n\t\t\t\t`fragment references view \"${fragment.dataRef}\" which is published but not granted to this release`);\n\t\t}\n\t}\n\n\t// ── Mutation bypass: actions must be capability action-intent refs ──\n\tfor (const [name, actionRef] of Object.entries(fragment.actions ?? {})) {\n\t\tconst actionPath = `${path}.actions.${name}`;\n\t\tconst ref = parseCapabilityRef(actionRef.intent);\n\t\tif (!ref) {\n\t\t\tscoped.add(\"mutation_bypass\", `${actionPath}.intent`,\n\t\t\t\t`action \"${name}\" intent \"${actionRef.intent}\" is not a capability:// reference; direct mutations bypass governance`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!scoped.knownIntents.has(`${ref.namespace}/${ref.name}`)) {\n\t\t\tscoped.add(\"mutation_bypass\", `${actionPath}.intent`,\n\t\t\t\t`action \"${name}\" references intent \"${actionRef.intent}\" which no known capability declares`);\n\t\t} else if (!scoped.grantedIntents.has(actionRef.intent)) {\n\t\t\tscoped.add(\"denied_intent_ref\", `${actionPath}.intent`,\n\t\t\t\t`action \"${name}\" references intent \"${actionRef.intent}\" which is published but not granted to this release`);\n\t\t}\n\t\tif (actionRef.params !== undefined) {\n\t\t\tcheckPropValues(actionRef.params, `${actionPath}.params`, scoped);\n\t\t}\n\t}\n\n\t// ── Check prop values for unauthorized data refs ───────────────────\n\tif (fragment.props !== undefined) {\n\t\tcheckPropValues(fragment.props, `${path}.props`, scoped);\n\t}\n\n\t// ── Recurse into children ───────────────────────────────────────────\n\tif (fragment.children !== undefined) {\n\t\tfragment.children.forEach((child, index) => {\n\t\t\twalkFragment(child, `${path}.children[${index}]`, scoped);\n\t\t});\n\t}\n}\n\n/**\n * Check one prop value wherever it sits: at a key, inside an array, or nested\n * in either. Every container routes back through this function, so a\n * capability reference resolves against the grant list at any depth. Checking\n * only at key positions leaves array elements unvalidated, and an array is the\n * ordinary shape for list props, so that gap is a grant bypass rather than an\n * edge case.\n */\nexport function checkValue(value: SduiFragmentValue, path: string, context: FragmentWalkContext, depth = 0): void {\n\tif (depth > MAX_PROP_DEPTH) {\n\t\tcontext.add(\"invalid_fragment\", path,\n\t\t\t`prop nesting exceeds ${MAX_PROP_DEPTH} levels; a cyclic or pathologically deep value cannot be checked`);\n\t\treturn;\n\t}\n\tif (isCapabilityRefValue(value)) {\n\t\tconst ref = parseCapabilityRef(value.$ref);\n\t\tif (!ref) {\n\t\t\tcontext.add(\"unauthorized_data_ref\", `${path}.$ref`,\n\t\t\t\t`\"${value.$ref}\" is not a valid capability:// view reference`);\n\t\t} else if (!context.knownViews.has(`${ref.namespace}/${ref.name}`)) {\n\t\t\tcontext.add(\"unauthorized_data_ref\", `${path}.$ref`,\n\t\t\t\t`prop references view \"${value.$ref}\" which no known capability publishes`);\n\t\t} else if (!context.grantedViews.has(value.$ref)) {\n\t\t\tcontext.add(\"denied_view_ref\", `${path}.$ref`,\n\t\t\t\t`prop references view \"${value.$ref}\" which is published but not granted to this release`);\n\t\t}\n\t\t// A reference object is not a leaf. Returning here would let a granted\n\t\t// reference shield ungranted ones parked beside it on the same object.\n\t\tfor (const [key, sibling] of Object.entries(value)) {\n\t\t\tif (key === \"$ref\") continue;\n\t\t\tcheckValue(sibling as SduiFragmentValue, `${path}.${key}`, context, depth + 1);\n\t\t}\n\t\treturn;\n\t}\n\tif (Array.isArray(value)) {\n\t\tvalue.forEach((item, index) => checkValue(item, `${path}[${index}]`, context, depth + 1));\n\t\treturn;\n\t}\n\tif (value !== null && typeof value === \"object\") {\n\t\tcheckPropValues(value as Record<string, SduiFragmentValue>, path, context, depth + 1);\n\t}\n}\n\nexport function checkPropValues(props: Record<string, SduiFragmentValue>, path: string, context: FragmentWalkContext, depth = 0): void {\n\tfor (const [key, value] of Object.entries(props)) {\n\t\tcheckValue(value, `${path}.${key}`, context, depth);\n\t}\n}\n","import type { SduiFragment, SduiRelease } from \"./types\";\nimport { assertSduiReleaseIntegrity } from \"./digest\";\n\n// ── Channel consumption contract ────────────────────────────────────────────\n\n/**\n * A channel is a rendering target (web, mobile, CLI). A channel consumes a\n * validated release and resolves capability references through its own host\n * adapters. Reads go through `ProjectionHost`; actions go through\n * `PlatformHost`. The channel never interprets or bypasses capability\n * references — it renders fragments and forwards action intents.\n */\nexport interface SduiChannel {\n\tid: string;\n\t/** Core components this channel renderer implements. */\n\tcoreComponents: readonly string[];\n\t/** Consume a validated release; returns the release if the channel's core\n\t * vocabulary covers every core component the document uses. */\n\tconsume(release: SduiRelease): SduiChannelConsumptionResult;\n}\n\nexport interface SduiChannelConsumptionResult {\n\t/** The release the channel consumed. */\n\trelease: SduiRelease;\n\t/** Whether the channel's core vocabulary covers the document. */\n\tcompatible: boolean;\n\t/** Core components the document uses that the channel does not implement. */\n\tmissingCoreComponents: string[];\n}\n\n/**\n * Create a channel that consumes a release. The channel verifies that every\n * core component the document references is in its vocabulary; pack-namespaced\n * components are resolved from the release's locked packs, not the channel.\n */\nexport function createSduiChannel(id: string, coreComponents: readonly string[]): SduiChannel {\n\treturn {\n\t\tid,\n\t\tcoreComponents,\n\t\tconsume(release) {\n\t\t\tassertSduiReleaseIntegrity(release);\n\t\t\tconst used = collectCoreComponents(release.document.root);\n\t\t\tfor (const variant of release.document.variants ?? []) {\n\t\t\t\tfor (const component of collectCoreComponents(variant.root)) used.add(component);\n\t\t\t}\n\t\t\tconst missing = [...used].filter((component) => !coreComponents.includes(component));\n\t\t\treturn {\n\t\t\t\trelease,\n\t\t\t\tcompatible: missing.length === 0,\n\t\t\t\tmissingCoreComponents: missing,\n\t\t\t};\n\t\t},\n\t};\n}\n\nfunction collectCoreComponents(fragment: SduiFragment): Set<string> {\n\tconst used = new Set<string>();\n\tif (fragment.component !== undefined && !fragment.component.includes(\".\")) {\n\t\tused.add(fragment.component);\n\t}\n\tif (fragment.children !== undefined) {\n\t\tfor (const child of fragment.children) {\n\t\t\tfor (const component of collectCoreComponents(child)) used.add(component);\n\t\t}\n\t}\n\treturn used;\n}\n","import type { PortableJsonSchema } from \"@fabricorg/platform\";\n\n// ── JSON Schema for the release document (machine-readable) ─────────────────\n\nexport const SDUI_DOCUMENT_JSON_SCHEMA: PortableJsonSchema = {\n\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\ttitle: \"Fabric SDUI document\",\n\ttype: \"object\",\n\trequired: [\"formatVersion\", \"name\", \"version\", \"root\", \"tokenSet\", \"componentPacks\"],\n\tproperties: {\n\t\tformatVersion: { type: \"integer\", enum: [1] },\n\t\tname: { type: \"string\", pattern: \"^[a-z][a-z0-9-]*$\" },\n\t\tversion: { type: \"string\", pattern: \"^\\\\d+\\\\.\\\\d+\\\\.\\\\d+\" },\n\t\troot: { type: \"object\" },\n\t\ttokenSet: { type: \"object\", required: [\"name\", \"version\"] },\n\t\tcomponentPacks: { type: \"array\" },\n\t},\n} as unknown as PortableJsonSchema;\n\nexport const SDUI_RELEASE_JSON_SCHEMA: PortableJsonSchema = {\n\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\ttitle: \"Fabric SDUI promoted release\",\n\ttype: \"object\",\n\trequired: [\"formatVersion\", \"releaseDigest\", \"assemblyDigest\", \"document\", \"tokenSet\", \"componentPacks\", \"grants\"],\n\tproperties: {\n\t\tformatVersion: { type: \"integer\", enum: [2] },\n\t\treleaseDigest: { type: \"string\", pattern: \"^[0-9a-f]{64}$\" },\n\t\tassemblyDigest: { type: \"string\", pattern: \"^[0-9a-f]{64}$\" },\n\t\tdocument: { type: \"object\" },\n\t\ttokenSet: { type: \"object\" },\n\t\tcomponentPacks: {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AAA,IACX,eAAe,EAAE,MAAM,WAAW,MAAM,CAAC,CAAC,EAAE;AAAA,IAC5C,MAAM,EAAE,MAAM,UAAU,SAAS,oBAAoB;AAAA,IACrD,SAAS,EAAE,MAAM,UAAU,SAAS,sBAAsB;AAAA,IAC1D,MAAM,EAAE,MAAM,SAAS;AAAA,IACvB,UAAU,EAAE,MAAM,UAAU,UAAU,CAAC,QAAQ,SAAS,EAAE;AAAA,IAC1D,gBAAgB,EAAE,MAAM,QAAQ;AAAA,EACjC;AACD;AAEO,IAAM,2BAA+C;AAAA,EAC3D,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AAAA,EACN,UAAU,CAAC,iBAAiB,iBAAiB,kBAAkB,YAAY,YAAY,kBAAkB,QAAQ;AAAA,EACjH,YAAY;AAAA,IACX,eAAe,EAAE,MAAM,WAAW,MAAM,CAAC,CAAC,EAAE;AAAA,IAC5C,eAAe,EAAE,MAAM,UAAU,SAAS,iBAAiB;AAAA,IAC3D,gBAAgB,EAAE,MAAM,UAAU,SAAS,iBAAiB;AAAA,IAC5D,UAAU,EAAE,MAAM,SAAS;AAAA,IAC3B,UAAU,EAAE,MAAM,SAAS;AAAA,IAC3B,gBAAgB,EAAE,MAAM,QAAQ;AAAA,IAChC,QAAQ,EAAE,MAAM,UAAU,UAAU,CAAC,SAAS,SAAS,EAAE;AAAA,EAC1D;AACD;","names":["value","import_assembly"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { PortableJsonSchema } from '@fabricorg/platform';
|
|
2
|
+
export { JsonValue } from '@fabricorg/platform';
|
|
3
|
+
import { UsageContractDocument } from '@fabricorg/gen-capability';
|
|
4
|
+
import { AssemblyLockfile } from '@fabricorg/assembly';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Version of the SDUI document contract. A vertical negotiates on this, not on
|
|
8
|
+
* this package's version, and it moves only when the serialized shape changes.
|
|
9
|
+
*/
|
|
10
|
+
declare const SDUI_DOCUMENT_FORMAT_VERSION: 1;
|
|
11
|
+
/**
|
|
12
|
+
* Version of the SDUI token-set contract.
|
|
13
|
+
*/
|
|
14
|
+
declare const SDUI_TOKEN_SET_FORMAT_VERSION: 1;
|
|
15
|
+
/**
|
|
16
|
+
* Version of the SDUI component-pack contract.
|
|
17
|
+
*/
|
|
18
|
+
declare const SDUI_COMPONENT_PACK_FORMAT_VERSION: 1;
|
|
19
|
+
/**
|
|
20
|
+
* Version of the promoted SDUI release contract.
|
|
21
|
+
*/
|
|
22
|
+
declare const SDUI_RELEASE_FORMAT_VERSION: 2;
|
|
23
|
+
/**
|
|
24
|
+
* A capability read reference embedded in fragment props. The `capability://`
|
|
25
|
+
* scheme ties a data binding to a published view; the host resolves it through
|
|
26
|
+
* `ProjectionHost`, never through a direct query.
|
|
27
|
+
*/
|
|
28
|
+
interface SduiCapabilityRef {
|
|
29
|
+
$ref: `capability://${string}`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A value that may appear in fragment props: a JSON literal, an array, an
|
|
33
|
+
* object, or a `capability://` read reference. Direct mutation endpoints,
|
|
34
|
+
* API URLs, or code strings are not valid fragment values.
|
|
35
|
+
*/
|
|
36
|
+
type SduiFragmentValue = string | number | boolean | null | SduiFragmentValue[] | SduiCapabilityRef | {
|
|
37
|
+
[key: string]: SduiFragmentValue;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* An action declared on a fragment. The `intent` must be a `capability://`
|
|
41
|
+
* reference to a published action intent; the host dispatches it through
|
|
42
|
+
* `PlatformHost`, preserving governance. A bare endpoint URL, function name,
|
|
43
|
+
* or inline script is a mutation bypass and is rejected.
|
|
44
|
+
*/
|
|
45
|
+
interface SduiActionRef {
|
|
46
|
+
intent: `capability://${string}`;
|
|
47
|
+
params?: Record<string, SduiFragmentValue>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A node in an SDUI document tree. A fragment either renders a component from
|
|
51
|
+
* a declared pack, binds data from a capability view, or both. Actions on a
|
|
52
|
+
* fragment are always capability action-intent references — never direct
|
|
53
|
+
* mutations.
|
|
54
|
+
*/
|
|
55
|
+
interface SduiFragment {
|
|
56
|
+
/** Unique identifier within the document. */
|
|
57
|
+
id: string;
|
|
58
|
+
/** Namespaced component (`pack.Component`) or a core component name. */
|
|
59
|
+
component?: string;
|
|
60
|
+
/** Props for the component; values may be literals or capability refs. */
|
|
61
|
+
props?: Record<string, SduiFragmentValue>;
|
|
62
|
+
/** Named slot this fragment fills in its parent component. */
|
|
63
|
+
slot?: string;
|
|
64
|
+
/** A capability view reference for data-driven fragments. */
|
|
65
|
+
dataRef?: `capability://${string}`;
|
|
66
|
+
/** Action handlers; every entry must be a capability action-intent reference. */
|
|
67
|
+
actions?: Record<string, SduiActionRef>;
|
|
68
|
+
/** Child fragments. */
|
|
69
|
+
children?: SduiFragment[];
|
|
70
|
+
}
|
|
71
|
+
type SduiTokenType = "color" | "spacing" | "fontSize" | "fontWeight" | "radius" | "border" | "shadow";
|
|
72
|
+
interface SduiToken {
|
|
73
|
+
type: SduiTokenType;
|
|
74
|
+
value: string;
|
|
75
|
+
description?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A versioned set of design tokens. Tokens are semantic, not literal CSS — a
|
|
79
|
+
* renderer maps them to its own platform. Two channels consuming the same
|
|
80
|
+
* token set apply the same visual intent through different renderings.
|
|
81
|
+
*/
|
|
82
|
+
interface SduiTokenSet {
|
|
83
|
+
formatVersion: typeof SDUI_TOKEN_SET_FORMAT_VERSION;
|
|
84
|
+
name: string;
|
|
85
|
+
version: string;
|
|
86
|
+
tokens: Record<string, SduiToken>;
|
|
87
|
+
}
|
|
88
|
+
interface SduiComponentDefinition {
|
|
89
|
+
/** Roles this component implements (for adoption-binding validation). */
|
|
90
|
+
implements?: string[];
|
|
91
|
+
/** JSON Schema for component props. */
|
|
92
|
+
propsSchema?: PortableJsonSchema;
|
|
93
|
+
/** Named slots this component accepts. */
|
|
94
|
+
slots?: string[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A versioned pack of SDUI components. Compatible with the adoption-bindings
|
|
98
|
+
* `ComponentPackManifest` but adds prop schemas and slot declarations so a
|
|
99
|
+
* document can be validated without a renderer.
|
|
100
|
+
*/
|
|
101
|
+
interface SduiComponentPack {
|
|
102
|
+
formatVersion: typeof SDUI_COMPONENT_PACK_FORMAT_VERSION;
|
|
103
|
+
pack: string;
|
|
104
|
+
namespace: string;
|
|
105
|
+
version: string;
|
|
106
|
+
/** SHA-256 digest of the published component-pack artifact. */
|
|
107
|
+
artifactDigest: string;
|
|
108
|
+
/**
|
|
109
|
+
* Where this pack is loaded from when it is delivered as a federated
|
|
110
|
+
* remote. The artifact digest identifies the pack that was reviewed; this
|
|
111
|
+
* is what a shell actually executes, so validation requires the two to be
|
|
112
|
+
* locked together or the review covers something other than what runs.
|
|
113
|
+
*/
|
|
114
|
+
remote?: SduiComponentPackRemote;
|
|
115
|
+
components: Record<string, SduiComponentDefinition>;
|
|
116
|
+
}
|
|
117
|
+
/** Delivery binding for a federated component pack. */
|
|
118
|
+
interface SduiComponentPackRemote {
|
|
119
|
+
/** Remote entry URL the shell loads. */
|
|
120
|
+
entry: string;
|
|
121
|
+
/** Subresource-integrity value for that entry, e.g. `sha384-…`. */
|
|
122
|
+
integrity: string;
|
|
123
|
+
/** Exposed module path keyed by the component name it provides. */
|
|
124
|
+
exposes: Record<string, string>;
|
|
125
|
+
}
|
|
126
|
+
interface SduiComponentPackReference {
|
|
127
|
+
pack: string;
|
|
128
|
+
namespace: string;
|
|
129
|
+
/** Semver range, e.g. `^1.0.0`. */
|
|
130
|
+
range: string;
|
|
131
|
+
}
|
|
132
|
+
interface SduiTokenSetReference {
|
|
133
|
+
name: string;
|
|
134
|
+
version: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A versioned SDUI document: a tree of fragments, a token-set reference, and
|
|
138
|
+
* the component packs it depends on. This is the build-time input; the release
|
|
139
|
+
* is the validated, resolved output.
|
|
140
|
+
*/
|
|
141
|
+
interface SduiDocument {
|
|
142
|
+
formatVersion: typeof SDUI_DOCUMENT_FORMAT_VERSION;
|
|
143
|
+
name: string;
|
|
144
|
+
version: string;
|
|
145
|
+
/** The tree rendered when no variant is selected. */
|
|
146
|
+
root: SduiFragment;
|
|
147
|
+
/**
|
|
148
|
+
* Alternative trees a compositor may select at request time, for experiment
|
|
149
|
+
* arms and personalization. Every variant is enumerated here and validated
|
|
150
|
+
* against the same grants as `root`, and all of them are covered by the
|
|
151
|
+
* release digest.
|
|
152
|
+
*
|
|
153
|
+
* Enumeration is what makes selection safe. A selector that can produce a
|
|
154
|
+
* tree outside this set cannot be validated at promotion, so "selection may
|
|
155
|
+
* never widen grants" would be unenforceable rather than merely unenforced.
|
|
156
|
+
*/
|
|
157
|
+
variants?: SduiVariant[];
|
|
158
|
+
tokenSet: SduiTokenSetReference;
|
|
159
|
+
componentPacks: SduiComponentPackReference[];
|
|
160
|
+
}
|
|
161
|
+
/** One selectable alternative to a document's default tree. */
|
|
162
|
+
interface SduiVariant {
|
|
163
|
+
/** Stable key the compositor matches on. Unique within the document. */
|
|
164
|
+
id: string;
|
|
165
|
+
/** The audience or experiment arm this arm serves. */
|
|
166
|
+
description?: string;
|
|
167
|
+
root: SduiFragment;
|
|
168
|
+
}
|
|
169
|
+
interface ResolvedSduiComponentPack {
|
|
170
|
+
pack: string;
|
|
171
|
+
namespace: string;
|
|
172
|
+
version: string;
|
|
173
|
+
range: string;
|
|
174
|
+
artifactDigest: string;
|
|
175
|
+
/**
|
|
176
|
+
* The locked delivery binding, carried onto the release so the digest
|
|
177
|
+
* identifies which remote a channel is expected to load. Omitting it would
|
|
178
|
+
* let two releases differing only in their remote share a digest.
|
|
179
|
+
*/
|
|
180
|
+
remote?: SduiComponentPackRemote;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* A promoted, validated, immutable SDUI release. It bundles a document, a
|
|
184
|
+
* resolved token set, and locked component packs. Two channels (web, mobile,
|
|
185
|
+
* CLI) can consume the same release and render it through their own renderers
|
|
186
|
+
* while reads and actions remain capability references.
|
|
187
|
+
*/
|
|
188
|
+
interface SduiRelease {
|
|
189
|
+
formatVersion: typeof SDUI_RELEASE_FORMAT_VERSION;
|
|
190
|
+
/** SHA-256 of the canonical document, token set, resolved packs, grants, and assembly identity. */
|
|
191
|
+
releaseDigest: string;
|
|
192
|
+
/** Approved application assembly this release was validated against. */
|
|
193
|
+
assemblyDigest: string;
|
|
194
|
+
document: SduiDocument;
|
|
195
|
+
tokenSet: SduiTokenSet;
|
|
196
|
+
componentPacks: ResolvedSduiComponentPack[];
|
|
197
|
+
grants: SduiAuthorizationGrants;
|
|
198
|
+
}
|
|
199
|
+
type SduiFindingCode = "unknown_component" | "incompatible_pack" | "unauthorized_data_ref" | "denied_view_ref" | "mutation_bypass" | "denied_intent_ref" | "intent_action_not_found" | "invalid_fragment" | "invalid_action_ref" | "unknown_token" | "duplicate_fragment_id" | "invalid_token_set" | "invalid_component_pack" | "invalid_document" | "missing_token_set" | "missing_component_pack" | "component_pack_not_in_assembly" | "capability_contract_not_in_assembly" | "duplicate_variant_id" | "fragment_grant_exceeds_release" | "remote_not_locked";
|
|
200
|
+
interface SduiFinding {
|
|
201
|
+
code: SduiFindingCode;
|
|
202
|
+
path: string;
|
|
203
|
+
message: string;
|
|
204
|
+
}
|
|
205
|
+
interface SduiValidationResult {
|
|
206
|
+
valid: boolean;
|
|
207
|
+
findings: SduiFinding[];
|
|
208
|
+
release: SduiRelease | undefined;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Explicit capability references authorized for an SDUI release.
|
|
212
|
+
*
|
|
213
|
+
* The presence of a view or action in a supplied usage contract proves that
|
|
214
|
+
* the capability publishes it, not that this document may use it. The
|
|
215
|
+
* experience host must therefore provide both grant lists explicitly.
|
|
216
|
+
*/
|
|
217
|
+
interface SduiAuthorizationGrants {
|
|
218
|
+
/** Full `capability://namespace/view` references allowed in data bindings. */
|
|
219
|
+
views: readonly string[];
|
|
220
|
+
/** Full `capability://namespace/intent` references allowed in actions. */
|
|
221
|
+
intents: readonly string[];
|
|
222
|
+
/**
|
|
223
|
+
* Per-fragment narrowing, keyed by fragment id.
|
|
224
|
+
*
|
|
225
|
+
* The release-wide lists above are the ceiling. A listed fragment may use
|
|
226
|
+
* only the references named for it, and the narrowing is inherited by that
|
|
227
|
+
* fragment's children, so a page assembled from several teams' fragments
|
|
228
|
+
* gets least privilege rather than the union of everything any of them
|
|
229
|
+
* needs. A fragment entry can only ever narrow: naming a reference outside
|
|
230
|
+
* the release-wide list is an authoring error and is reported rather than
|
|
231
|
+
* silently granted.
|
|
232
|
+
*
|
|
233
|
+
* Keys are fragment ids, which are unique within a tree but may repeat
|
|
234
|
+
* across variants, so two variants using the same fragment id share one
|
|
235
|
+
* entry. Give them distinct ids when they need distinct narrowing. This
|
|
236
|
+
* cannot widen either fragment, since narrowing stays an intersection.
|
|
237
|
+
*/
|
|
238
|
+
fragments?: Record<string, SduiFragmentGrants>;
|
|
239
|
+
}
|
|
240
|
+
/** References one fragment subtree may use, drawn from the release-wide lists. */
|
|
241
|
+
interface SduiFragmentGrants {
|
|
242
|
+
views?: readonly string[];
|
|
243
|
+
intents?: readonly string[];
|
|
244
|
+
}
|
|
245
|
+
interface SduiValidationInput {
|
|
246
|
+
document: SduiDocument;
|
|
247
|
+
tokenSet: SduiTokenSet;
|
|
248
|
+
/** Available component packs for version resolution. */
|
|
249
|
+
componentPacks: SduiComponentPack[];
|
|
250
|
+
/** Capability contracts available for data-ref and action validation. */
|
|
251
|
+
contracts: UsageContractDocument[];
|
|
252
|
+
/**
|
|
253
|
+
* Explicit authorization grants for every capability view and action
|
|
254
|
+
* reference used by the document. Contract membership alone never grants
|
|
255
|
+
* access.
|
|
256
|
+
*/
|
|
257
|
+
grants: SduiAuthorizationGrants;
|
|
258
|
+
/** Approved resolved application composition. */
|
|
259
|
+
assembly: AssemblyLockfile;
|
|
260
|
+
/** Core component vocabulary every renderer implements. */
|
|
261
|
+
coreComponents?: readonly string[];
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
declare function assertSduiTokenSet(value: unknown, path?: string): asserts value is SduiTokenSet;
|
|
265
|
+
declare function assertSduiComponentPack(value: unknown, path?: string): asserts value is SduiComponentPack;
|
|
266
|
+
declare function assertSduiFragment(value: unknown, path?: string): asserts value is SduiFragment;
|
|
267
|
+
declare function assertSduiDocument(value: unknown, path?: string): asserts value is SduiDocument;
|
|
268
|
+
/**
|
|
269
|
+
* Validate the grant envelope before semantic release checks. Grants are
|
|
270
|
+
* intentionally references rather than capability names: a capability may
|
|
271
|
+
* publish several views and intents with different authorization decisions.
|
|
272
|
+
*/
|
|
273
|
+
declare function assertSduiAuthorizationGrants(value: unknown, path?: string): asserts value is SduiAuthorizationGrants;
|
|
274
|
+
/** Validate a promoted release loaded from an untyped persistence or network seam. */
|
|
275
|
+
declare function assertSduiRelease(value: unknown, path?: string): asserts value is SduiRelease;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Validate an SDUI document and its dependencies, producing a promoted release
|
|
279
|
+
* when every check passes. This is the single build gate: it rejects unknown
|
|
280
|
+
* components, incompatible packs, unauthorized data references, and mutation
|
|
281
|
+
* bypasses. Returns every finding rather than throwing, so one CI run tells a
|
|
282
|
+
* vertical everything it has to change. Use {@link assertSduiReleaseValid} to
|
|
283
|
+
* throw on the first invalid result.
|
|
284
|
+
*/
|
|
285
|
+
declare function validateSduiRelease(input: SduiValidationInput): SduiValidationResult;
|
|
286
|
+
/**
|
|
287
|
+
* Throw with every finding listed, for use as a build step. Returns the
|
|
288
|
+
* promoted release when valid.
|
|
289
|
+
*/
|
|
290
|
+
declare function assertSduiReleaseValid(input: SduiValidationInput): SduiRelease;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Compute the canonical release digest for a valid release. Two releases with
|
|
294
|
+
* the same document, token set, and resolved packs produce the same digest,
|
|
295
|
+
* so a channel can verify it is consuming the exact release it was built for.
|
|
296
|
+
*/
|
|
297
|
+
declare function computeReleaseDigest(document: SduiDocument, tokenSet: SduiTokenSet, componentPacks: ResolvedSduiComponentPack[], grants: SduiAuthorizationGrants, assemblyDigest: string): string;
|
|
298
|
+
/** Reject promoted release content that no longer matches its immutable digest. */
|
|
299
|
+
declare function assertSduiReleaseIntegrity(release: SduiRelease): void;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* A channel is a rendering target (web, mobile, CLI). A channel consumes a
|
|
303
|
+
* validated release and resolves capability references through its own host
|
|
304
|
+
* adapters. Reads go through `ProjectionHost`; actions go through
|
|
305
|
+
* `PlatformHost`. The channel never interprets or bypasses capability
|
|
306
|
+
* references — it renders fragments and forwards action intents.
|
|
307
|
+
*/
|
|
308
|
+
interface SduiChannel {
|
|
309
|
+
id: string;
|
|
310
|
+
/** Core components this channel renderer implements. */
|
|
311
|
+
coreComponents: readonly string[];
|
|
312
|
+
/** Consume a validated release; returns the release if the channel's core
|
|
313
|
+
* vocabulary covers every core component the document uses. */
|
|
314
|
+
consume(release: SduiRelease): SduiChannelConsumptionResult;
|
|
315
|
+
}
|
|
316
|
+
interface SduiChannelConsumptionResult {
|
|
317
|
+
/** The release the channel consumed. */
|
|
318
|
+
release: SduiRelease;
|
|
319
|
+
/** Whether the channel's core vocabulary covers the document. */
|
|
320
|
+
compatible: boolean;
|
|
321
|
+
/** Core components the document uses that the channel does not implement. */
|
|
322
|
+
missingCoreComponents: string[];
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Create a channel that consumes a release. The channel verifies that every
|
|
326
|
+
* core component the document references is in its vocabulary; pack-namespaced
|
|
327
|
+
* components are resolved from the release's locked packs, not the channel.
|
|
328
|
+
*/
|
|
329
|
+
declare function createSduiChannel(id: string, coreComponents: readonly string[]): SduiChannel;
|
|
330
|
+
|
|
331
|
+
declare const SDUI_DOCUMENT_JSON_SCHEMA: PortableJsonSchema;
|
|
332
|
+
declare const SDUI_RELEASE_JSON_SCHEMA: PortableJsonSchema;
|
|
333
|
+
|
|
334
|
+
export { type ResolvedSduiComponentPack, SDUI_COMPONENT_PACK_FORMAT_VERSION, SDUI_DOCUMENT_FORMAT_VERSION, SDUI_DOCUMENT_JSON_SCHEMA, SDUI_RELEASE_FORMAT_VERSION, SDUI_RELEASE_JSON_SCHEMA, SDUI_TOKEN_SET_FORMAT_VERSION, type SduiActionRef, type SduiAuthorizationGrants, type SduiCapabilityRef, type SduiChannel, type SduiChannelConsumptionResult, type SduiComponentDefinition, type SduiComponentPack, type SduiComponentPackReference, type SduiDocument, type SduiFinding, type SduiFindingCode, type SduiFragment, type SduiFragmentValue, type SduiRelease, type SduiToken, type SduiTokenSet, type SduiTokenSetReference, type SduiTokenType, type SduiValidationInput, type SduiValidationResult, assertSduiAuthorizationGrants, assertSduiComponentPack, assertSduiDocument, assertSduiFragment, assertSduiRelease, assertSduiReleaseIntegrity, assertSduiReleaseValid, assertSduiTokenSet, computeReleaseDigest, createSduiChannel, validateSduiRelease };
|