veryfront/release-assets

Import

ts
import {
  clearCachedReleaseAssetManifests,
  clearReleaseAssetManifestCache,
  contentTypeForExtension,
  describeReadyReleaseAssetManifestRejection,
  getReadyManifestForRender,
  getReadyManifestForRenderAsync,
} from "veryfront/release-assets";

Examples

Validate an API response before consuming its manifest body.

ts
import { parseReadyReleaseAssetManifestResponse } from "veryfront/release-assets";

const expectedReleaseId = "release-123";
const response = await fetch(
  `https://api.veryfront.com/projects/<PROJECT_SLUG>/releases/${expectedReleaseId}/asset-manifest`,
  { headers: { Authorization: "Bearer <API_KEY>" } },
);
const ready = parseReadyReleaseAssetManifestResponse(
  await response.json(),
  expectedReleaseId,
);
if (!ready) throw new Error("Invalid release asset manifest response");
const manifest = ready.manifest;

Build an immutable URL for a published JavaScript asset

ts
import { releaseAssetUrl } from "veryfront/release-assets";

const url = releaseAssetUrl("a".repeat(64), "js");

Exports

Components

NameDescriptionSource
RELEASE_ASSET_BASE_PATHPublic asset base path served on the project's own domain (proxy-owned).source
RELEASE_ASSET_CONTENT_TYPE_ALLOWLISTAllowlist of accepted content types (upstream + upload validation).source
RELEASE_ASSET_CONTENT_TYPESContent types permitted for release assets.source
RELEASE_ASSET_DEPENDENCY_IMPORT_MAP_ENV_FLAGEnv flag that enables manifest dependency import-map rewrites (default OFF).source
RELEASE_ASSET_IMMUTABLE_MAX_AGE_SECONDSImmutable cache max-age in seconds (1 year).source
RELEASE_ASSET_MANIFEST_ENV_FLAGEnv flag that enables HTML manifest consumption in production (default OFF).source
RELEASE_ASSET_MANIFEST_LIMITSWork and memory bounds enforced by every manifest producer and consumer.source
RELEASE_ASSET_MANIFEST_SCHEMA_VERSIONCurrent manifest body schema version.source
RELEASE_ASSET_MAX_PENDING_BYTESMaximum aggregate bytes retained while preparing one asset generation.source
RELEASE_ASSET_MAX_SIZE_BYTESMaximum size (bytes) for a single uploaded asset (10 MB).source
RELEASE_ASSET_UPLOAD_CONCURRENCYBounded upload concurrency when posting assets during a build.source
RELEASE_MODULE_RUNTIME_VERSION_PARAMQuery param that scopes fallback module URLs to the Veryfront runtime build.source
RELEASE_MODULE_VERSION_PARAMQuery param that scopes fallback module URLs to an immutable release.source

Functions

NameDescriptionSource
clearCachedReleaseAssetManifestsClear cached manifest bodies while keeping registered fetchers intact.source
clearReleaseAssetManifestCacheClear the cache and fetcher registry (tests / adapter teardown).source
contentTypeForExtensionResolve the content type for an extension, or null if not allowed.source
describeReadyReleaseAssetManifestRejectionExplain why a ready manifest response was rejected.source
getReadyManifestForRenderReturn a ready manifest for releaseId if one is cached, else null.source
getReadyManifestForRenderAsyncAwait a ready manifest for rendering when release-manifest consumption is enabled.source
hasImmutableReleaseAssetDependenciesTrue only when manifest dependency entries are safe immutable rewrite targets.source
isAllowedReleaseAssetContentTypeTrue when the value is a valid allowlisted release asset content type.source
isReleaseAssetManifestEnabledTrue when production manifest consumption is enabled via env flag.source
isSafeBoundedTextCheck that an untrusted value is a non-empty, trimmed string within maxLength that contains no control characters.source
isValidContentHashValidate a content hash is exactly 64 lowercase hex characters.source
normalizeManifestModuleKeyNormalize a logical module path to the manifest's key convention.source
parseReadyReleaseAssetManifestResponseParse an untrusted ready response without executing accessors.source
parseReleaseAssetManifestParse an untrusted manifest without requiring a registered schema extension.source
readUntrustedOwnDataPropertyRead an own data property from an untrusted value without invoking accessors.source
registerManifestFetcherForReleaseRegister a project-scoped manifest fetcher for the given releaseId.source
releaseAssetUrlMap a 64-hex content hash + extension to its public asset URL.source
resolveManifestModuleUrlResolve a module URL through the manifest.source
resolveManifestRoutePreloadUrlsResolve the route closure module URLs for preload hints from the manifest.source
routeForPageDerive a route path from a page module logical path.source
unregisterManifestFetcherForReleaseRemove the manifest fetcher for the given releaseId.source

Types

NameDescriptionSource
ImmutableReleaseAssetManifestManifest whose dependency entries name uploaded content-addressed assets.source
ReadyManifestReadOptionsControls revalidation behavior for awaited manifest reads.source
ReadyReleaseAssetManifestResponseStrict ready response with a generation-matched validated manifest body.source
ReleaseAssetContentTypeMIME types accepted for immutable release asset uploads and responses.source
ReleaseAssetCssEntryContent-addressed CSS entry.source
ReleaseAssetDependencyModeCapability represented by entries in the manifest dependency map.source
ReleaseAssetEntryContent-addressed JavaScript module entry.source
ReleaseAssetExtensionFile extensions supported by the immutable release asset endpoint.source
ReleaseAssetManifestValidated, immutable release asset manifest v2 body.source
ReleaseAssetManifestFetchContextCancellation context passed to a release-scoped manifest fetcher.source
ReleaseAssetManifestFetcherFetcher used to retrieve a manifest for a release. Registered per-release ID by the runtime adapter that owns that release, so the correct project-scoped token is always used. Returns null when the manifest is unavailable.source
ReleaseAssetManifestFetcherCleanupIdempotent cleanup for one fetcher registration.source
ReleaseAssetManifestParseOptionsOptions shared by the dependency-free consumption parsers. acceptLegacyV1 defaults to false, so a v1 manifest body is rejected as a schema skew; set it to true only on read paths that must still adapt a readable v1 manifest.source
ReleaseAssetManifestResponseResponse shape for the GET asset-manifest endpoint.source
ReleaseAssetManifestStateManifest lifecycle states (DB-owned; mirrored here for runtime checks).source
ReleaseAssetRouteEntryPer-route module and CSS closure.source

Constants

NameDescriptionSource
getReleaseAssetManifestSchemaExtension-backed validator for the strict release asset manifest v2 body.source