everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
90 lines (88 loc) • 3.74 kB
JavaScript
let zod = require("zod");
let node_crypto = require("node:crypto");
//#region src/services/platform/manifest-schema.ts
/**
* The platform release manifest's wire schema (ADR 0034) — a leaf module so
* the registry's resolution machine and the manifest's composer can both
* import it without a cycle. The composer, inventory, compat gate, and
* resolution machine live in `platform/manifest.ts` and
* `registry/resolution.ts` respectively; this file holds only the schema.
*/
/** The release that cut the registry wire over (ticket 10): extends targets
* still publishing the pre-cutover composition must redeploy on this
* version or newer — resolution rejects their tags with exactly that
* instruction. */
const CUTOVER_RELEASE = "2.0.0-rc.37";
const ManifestSchema = zod.z.object({
schemaVersion: zod.z.literal(1),
kind: zod.z.literal("everything-dev/platform-manifest"),
frameworkVersion: zod.z.string().min(1),
everyPluginVersion: zod.z.string().min(1),
/** The serving build's repo HEAD (full sha) — omitted when the compose
* context has no git (regression image builds, build-arg-less builds). */
gitSha: zod.z.string().min(7).optional(),
image: zod.z.object({
ref: zod.z.string().min(1),
tags: zod.z.array(zod.z.string().min(1))
}),
catalog: zod.z.record(zod.z.string(), zod.z.string()),
sharedDeps: zod.z.record(zod.z.string(), zod.z.object({
version: zod.z.string(),
requiredVersion: zod.z.union([zod.z.string(), zod.z.boolean()]),
singleton: zod.z.boolean(),
eager: zod.z.boolean(),
strictVersion: zod.z.boolean(),
shareScope: zod.z.string()
})),
templateInventory: zod.z.array(zod.z.object({
path: zod.z.string(),
sha256: zod.z.string().regex(/^[0-9a-f]{64}$/)
})),
compat: zod.z.object({ minChild: zod.z.string().min(1) }),
/**
* The release's remote-record map (ADR 0034 amendment — release-scoped
* extends inheritance): each entry records the immutable descriptor the
* release published for a config remote (dotted config path, e.g.
* `app.auth`, `app.auth.ui`, `plugins.votes.ui`) — children authored to
* this release re-point inherited remotes at THESE bytes instead of the
* parent's live config whenever the parent publishes. Optional: releases
* composed before the field carry no remotes, and old readers strip
* unknown keys.
*/
remotes: zod.z.record(zod.z.string(), zod.z.object({
base: zod.z.string().min(1),
digest: zod.z.object({
manifest: zod.z.string().min(1),
integrity: zod.z.string().min(1)
})
})).optional()
});
/** The thin tag — the manifest.json home carries `{ schemaVersion, version,
* digest }` and nothing else; the full manifest lives at the immutable
* `versions/<v>.json` and the digest pins its exact bytes. */
const ManifestTagSchema = zod.z.object({
schemaVersion: zod.z.literal(1),
version: zod.z.string().min(1),
digest: zod.z.string().min(1)
});
/** The digest of a manifest's serialized bytes — the train hashes the exact
* string it publishes; the resolution machine re-serializes the fetched
* record and verifies (JSON preserves key order, so the bytes round-trip). */
function digestOfManifest(serialized) {
return (0, node_crypto.createHash)("sha256").update(serialized).digest("hex");
}
/** The thin tag for a composed manifest, over its serialized record bytes. */
function manifestTagOf(manifest, serialized) {
return {
schemaVersion: 1,
version: manifest.frameworkVersion,
digest: digestOfManifest(serialized)
};
}
//#endregion
exports.CUTOVER_RELEASE = CUTOVER_RELEASE;
exports.ManifestSchema = ManifestSchema;
exports.ManifestTagSchema = ManifestTagSchema;
exports.digestOfManifest = digestOfManifest;
exports.manifestTagOf = manifestTagOf;
//# sourceMappingURL=manifest-schema.cjs.map