UNPKG

everything-dev

Version:

A consolidated product package for building Module Federation apps with oRPC APIs.

507 lines (505 loc) • 21.5 kB
import * as z$1 from "zod"; import { ComposePayloadSchema } from "every-plugin/ui/manifest"; //#region src/types.ts const JsonValueSchema = z$1.lazy(() => z$1.union([ z$1.string(), z$1.number(), z$1.boolean(), z$1.null(), z$1.array(JsonValueSchema), z$1.record(z$1.string(), JsonValueSchema) ])); const JsonObjectSchema = z$1.record(z$1.string(), JsonValueSchema); const ExtendsSchema = z$1.union([z$1.string(), z$1.object({ development: z$1.string().optional(), production: z$1.string().optional(), staging: z$1.string().optional() })]); const SourceModeSchema = z$1.enum(["local", "remote"]); const SharedConfigSchema = z$1.object({ version: z$1.string(), requiredVersion: z$1.string().optional(), singleton: z$1.boolean().optional(), eager: z$1.boolean().optional(), strictVersion: z$1.boolean().optional(), shareScope: z$1.string().optional() }); const SharedDepConfigSchema = SharedConfigSchema; const SharedDepMapSchema = z$1.record(z$1.string(), SharedConfigSchema); /** * Remote digest (atomic-deploys): an explicit pointer to the remote's * immutable per-deploy WorkspaceVersionManifest — `manifest` is the versioned * manifest filename relative to the remote's production base, `integrity` is * that document's SRI. Resolving the digest derives the remote's entry-level * fields (`entryUrl`, entry integrity, ssr entry). A remote without a * `digest` uses its top-level `integrity` as a direct entry SRI (fixed-name * remotes only). */ const RemoteDigestSchema = z$1.object({ manifest: z$1.string().min(1), integrity: z$1.string().min(1) }); const FederationEntrySchema = z$1.object({ name: z$1.string(), url: z$1.string(), entry: z$1.string(), /** the content-hashed container entry URL (derived from the version * manifest when the slot pins one) — consumers load this instead of * appending the legacy fixed name */ entryUrl: z$1.string().optional(), source: SourceModeSchema, integrity: z$1.string().optional(), /** Resolved artifact URL → SRI for everything the pin attests — the * integrity-in-pipeline registry's keying source (#642 revival, ADR 0046 * ticket 03). */ integrityMap: z$1.record(z$1.string(), z$1.string()).optional(), /** The slot's pin coordinates (what is pinned) — stamped at resolution so * the serving-generation digest derives from pointer inputs + resolved * coordinates (ADR 0046 ticket 04). */ digest: RemoteDigestSchema.optional() }); const PluginUiConfigSchema = z$1.object({ name: z$1.string().optional(), development: z$1.string().optional(), production: z$1.string().optional(), /** browser-facing base overriding `production` when server-side loading * must stay container-local (image-native runtimes, ADR 0011) — may be * same-origin relative (/bundles/<account>/<gateway>/<slot>) */ publicUrl: z$1.string().optional(), integrity: z$1.string().optional(), ssr: z$1.string().optional(), ssrIntegrity: z$1.string().optional(), digest: RemoteDigestSchema.optional() }); const ComposableAppEntrySchema = z$1.object({ extends: ExtendsSchema.optional(), name: z$1.string().optional(), development: z$1.string().optional(), production: z$1.string().optional(), integrity: z$1.string().optional(), proxy: z$1.string().optional(), variables: JsonObjectSchema.optional(), secrets: z$1.array(z$1.string()).optional(), routes: z$1.array(z$1.string()).optional(), shared: SharedDepMapSchema.optional(), connectSrc: z$1.array(z$1.string()).optional(), /** `false` opts a consumer out of the ui the extended provider attaches */ ui: z$1.union([PluginUiConfigSchema, z$1.literal(false)]).optional(), digest: RemoteDigestSchema.optional() }); const ApiPluginConfigSchema = ComposableAppEntrySchema.extend({ dependsOn: z$1.array(z$1.string()).optional() }); const BosPluginRefSchema = ComposableAppEntrySchema.extend({ version: z$1.string().optional(), app: z$1.record(z$1.string(), z$1.unknown()).optional(), plugins: z$1.record(z$1.string(), z$1.unknown()).optional(), dependsOn: z$1.array(z$1.string()).optional(), /** `bos://account/gateway[#target]` — call-only attachments locate their * contract types here; see PluginAttachmentRefSchema. */ contract: z$1.string().optional() }); const PluginRuntimeUiSchema = z$1.object({ name: z$1.string(), url: z$1.string(), entry: z$1.string(), source: SourceModeSchema, /** The slot's pin coordinates (what is pinned) — stamped at resolution so * the serving-generation digest derives from pointer inputs + resolved * coordinates (ADR 0046 ticket 04). */ digest: RemoteDigestSchema.optional(), /** browser-facing base; when set the client config serves this instead of * `url` (server-side loading keeps `url`) */ publicUrl: z$1.string().optional(), localPath: z$1.string().optional(), port: z$1.number().optional(), integrity: z$1.string().optional(), ssrUrl: z$1.string().optional(), ssrIntegrity: z$1.string().optional(), entryUrl: z$1.string().optional(), ssrEntryUrl: z$1.string().optional(), /** pin-derived hashed browser manifest (mf-manifest) — absent for local * slots; registration reads this instead of the overloaded `entry` */ browserManifestUrl: z$1.string().optional(), /** SRI of the pinned compose manifest (manifest.gen.json, from the pin's * per-file digest map) — the compose verifies the mutable fixed-name * manifest against it so a host resolving an older pin never silently * mixes newer manifest bytes into its composed tree */ manifestIntegrity: z$1.string().optional(), /** The compose manifest URL resolved through the pin's immutable version * directory (#826) — absent for local slots and legacy pins, which read * the fixed name at the slot root */ manifestUrl: z$1.string().optional(), /** Shared-singleton `name → version` the pinned build embedded (#546) — * the host's composition guard cross-compares it across UI sources before * loading, so a platform skew fails with a named error instead of the * federation runtime's cryptic singleton error. */ sharedVersions: z$1.record(z$1.string(), z$1.string()).optional(), dependsOn: z$1.array(z$1.string()).optional() }); const RuntimePluginConfigSchema = z$1.object({ name: z$1.string(), url: z$1.string(), entry: z$1.string(), source: SourceModeSchema, extendsRef: z$1.string().optional(), localPath: z$1.string().optional(), port: z$1.number().optional(), proxy: z$1.string().optional(), variables: JsonObjectSchema.optional(), secrets: z$1.array(z$1.string()).optional(), integrity: z$1.string().optional(), entryUrl: z$1.string().optional(), /** Resolved artifact URL → SRI for everything the pin attests (hashed * entry, ssr entry, files-map entries) — the integrity-in-pipeline * registry's keying source (#642 revival, ADR 0046 ticket 03). */ integrityMap: z$1.record(z$1.string(), z$1.string()).optional(), /** The slot's pin coordinates (what is pinned) — stamped at resolution so * the serving-generation digest derives from pointer inputs + resolved * coordinates (ADR 0046 ticket 04). */ digest: RemoteDigestSchema.optional(), shared: SharedDepMapSchema.optional(), connectSrc: z$1.array(z$1.string()).optional(), ui: PluginRuntimeUiSchema.optional(), routes: z$1.array(z$1.string()).optional(), dependsOn: z$1.array(z$1.string()).optional(), /** Call-only attachment: traffic endpoint is `url` (authored `proxy`), * types locator is `contractUrl` — the contract ref's stamped production. */ contractUrl: z$1.string().optional() }); const DependencyNodeKindSchema = z$1.enum([ "api", "auth", "ui", "plugin" ]); const RuntimeDependencyNodeSchema = z$1.object({ key: z$1.string(), kind: DependencyNodeKindSchema, name: z$1.string(), url: z$1.string(), entry: z$1.string(), source: SourceModeSchema, dependsOn: z$1.array(z$1.string()).optional(), extendsRef: z$1.string().optional(), localPath: z$1.string().optional(), port: z$1.number().optional(), proxy: z$1.string().optional(), variables: JsonObjectSchema.optional(), secrets: z$1.array(z$1.string()).optional(), integrity: z$1.string().optional(), /** Resolved artifact URL → SRI for everything the pin attests — the * integrity-in-pipeline registry's keying source (#642 revival, ADR 0046 * ticket 03). */ integrityMap: z$1.record(z$1.string(), z$1.string()).optional(), /** The slot's pin coordinates (what is pinned) — stamped at resolution so * the serving-generation digest derives from pointer inputs + resolved * coordinates (ADR 0046 ticket 04). */ digest: RemoteDigestSchema.optional(), shared: SharedDepMapSchema.optional(), connectSrc: z$1.array(z$1.string()).optional(), ui: PluginRuntimeUiSchema.optional(), routes: z$1.array(z$1.string()).optional(), sourceOrigin: z$1.enum(["config", "manifest"]).optional(), singletonKey: z$1.string().optional(), /** Call-only attachment (see RuntimePluginConfigSchema.contractUrl) */ contractUrl: z$1.string().optional() }); const UiConfigSchema = z$1.object({ name: z$1.string().optional(), development: z$1.string().optional(), production: z$1.string().optional(), /** browser-facing base overriding `production` (see PluginUiConfigSchema) */ publicUrl: z$1.string().optional(), /** direct entry SRI — only for slots without a `pin` */ integrity: z$1.string().optional(), ssr: z$1.string().optional(), ssrIntegrity: z$1.string().optional(), digest: RemoteDigestSchema.optional() }).strict(); const HostConfigSchema = z$1.object({ /** The host slot is local to the running image — published configs strip * workspace-relative `local:` targets (publish canonicalization, #584), so * production reads omit `development` entirely. */ development: z$1.string().optional(), /** Deploy state (ADR 0005) — absent until the first publish writes it. */ production: z$1.string().optional(), /** direct entry SRI — only for slots without a `pin` */ integrity: z$1.string().optional(), secrets: z$1.array(z$1.string()).optional(), digest: RemoteDigestSchema.optional() }); const ClientRuntimeInfoSchema = z$1.object({ accountId: z$1.string(), gatewayId: z$1.string(), runtimeBasePath: z$1.string(), title: z$1.string().nullable(), description: z$1.string().nullable(), hostUrl: z$1.string().nullable() }); const RuntimeLineageSchema = z$1.object({ parent: z$1.string().nullable(), root: z$1.string().nullable(), depth: z$1.number().int().nonnegative(), extendsChain: z$1.array(z$1.string()) }); const BosStagingSchema = z$1.object({ domain: z$1.string(), account: z$1.string().optional() }); const BosConfigInputAppEntrySchema = z$1.record(z$1.string(), z$1.unknown()); const BosConfigInputSchema = z$1.lazy(() => z$1.object({ extends: ExtendsSchema.optional(), account: z$1.string().optional(), domain: z$1.string().optional(), status: z$1.enum([ "active", "suspended", "pending_deletion" ]).optional(), testnet: z$1.string().optional(), staging: BosStagingSchema.optional(), template: z$1.string().optional(), gateway: z$1.object({ development: z$1.string().optional(), production: z$1.string().optional(), account: z$1.string().optional() }).optional(), development: z$1.string().optional(), production: z$1.string().optional(), integrity: z$1.string().optional(), name: z$1.string().optional(), version: z$1.string().optional(), proxy: z$1.string().optional(), variables: JsonObjectSchema.optional(), secrets: z$1.array(z$1.string()).optional(), routes: z$1.array(z$1.string()).optional(), app: z$1.record(z$1.string(), BosConfigInputAppEntrySchema).optional(), plugins: z$1.record(z$1.string(), z$1.union([z$1.string(), BosConfigInputSchema])).optional(), publish: z$1.object({ auth: z$1.enum([ "session", "key", "custody" ]).optional(), /** Manifest attribution key record (ADR 0046 ticket 05) — mirrors * PublishConfigSchema.verification; the chain walker reads it from * the config it walks (authored or published — publish survives * canonicalization because children inherit it). */ verification: z$1.union([z$1.object({ publicKey: z$1.string().min(1) }), z$1.literal("off")]).optional() }).optional(), /** The authored release (ADR 0034): the exact framework version this app targets. */ release: z$1.string().optional(), /** The authored seed declaration (#865). */ seed: SeedConfigSchema.optional(), ci: CiConfigSchema.optional(), cdn: CdnConfigSchema.optional() })); const StarterLevelSchema = z$1.enum(["simple", "advanced"]); const StarterLevelConfigSchema = z$1.object({ include: z$1.array(z$1.string()).optional(), exclude: z$1.array(z$1.string()).optional() }); const ParentStarterConfigSchema = z$1.object({ levels: z$1.record(z$1.string(), StarterLevelConfigSchema).optional(), exclude: z$1.array(z$1.string()).optional() }); const RailwayCiSchema = z$1.object({ service: z$1.string() }); const CiConfigSchema = z$1.object({ railway: RailwayCiSchema.optional() }); /** Where this runtime's built bundles are served from. Inherited via extends. */ const CdnConfigSchema = z$1.object({ origin: z$1.string().optional() }); /** * The `seed.auth.ownerAdmin` identity (#865): `true` derives the NEAR account * from the app's top-level `account`; an object names it explicitly (NEAR * account and/or email). */ const SeedOwnerAdminSchema = z$1.union([z$1.literal(true), z$1.object({ nearAccount: z$1.string().optional(), email: z$1.string().optional() }).strict()]); /** * The authored seed declaration (#865). `steps` are workspace-relative script * paths, idempotent by contract (upserts) — they run once per `version`; * bumping the version re-runs them deliberately. Dev: `bos dev` seeds * automatically before services spawn. Production: never implicit — `bos seed` * runs it with explicit, env-provided owner credentials. */ const SeedConfigSchema = z$1.object({ version: z$1.number().int().positive(), auth: z$1.object({ ownerAdmin: SeedOwnerAdminSchema }).strict().optional(), steps: z$1.array(z$1.string()).optional() }).strict(); const PublishAuthSchema = z$1.enum([ "session", "key", "custody" ]); const PublishConfigSchema = z$1.object({ auth: PublishAuthSchema.optional(), /** Publish per-workspace source archives beside the dists (#406). */ sourcePublish: z$1.boolean().optional(), /** * Manifest attribution (ADR 0046 ticket 05): the verifying public key the * deploy train signs version manifests with and the chain walker demands * signatures against — `{ publicKey: "ed25519:<base58>" }`, or `"off"` to * disable explicitly. Absent means off (the rollout default): unsigned * manifests verify as today. The key record publishes inside the on-chain * config, so it inherits chain authenticity and rotation is a config * publish. */ verification: z$1.union([z$1.object({ publicKey: z$1.string().min(1) }), z$1.literal("off")]).optional() }); const PluginKeySchema = z$1.string().regex(/^[a-zA-Z0-9._-]+$/, "plugin key must match [a-zA-Z0-9._-] — keys from remote/extended configs are interpolated into shells and generated code"); const BosConfigSchema = z$1.object({ account: z$1.string(), extends: ExtendsSchema.optional(), domain: z$1.string().optional(), title: z$1.string().optional(), description: z$1.string().optional(), testnet: z$1.string().optional(), staging: BosStagingSchema.optional(), repository: z$1.string().optional(), publish: PublishConfigSchema.optional(), /** The authored release (ADR 0034): the exact framework version this app targets. */ release: z$1.string().optional(), /** The authored seed declaration (#865) — dev boots seed automatically; * the published payload strips it (workspace-relative steps). */ seed: SeedConfigSchema.optional(), ci: CiConfigSchema.optional(), cdn: CdnConfigSchema.optional(), rolledBackFrom: z$1.string().optional(), starter: z$1.union([ParentStarterConfigSchema, StarterLevelSchema]).optional(), plugins: z$1.record(PluginKeySchema, z$1.union([z$1.string(), BosPluginRefSchema])).optional(), app: z$1.object({ host: HostConfigSchema, ui: UiConfigSchema, api: ApiPluginConfigSchema, auth: ComposableAppEntrySchema.optional() }) }); const RuntimeConfigSchema = z$1.object({ env: z$1.enum([ "development", "production", "staging" ]), account: z$1.string(), domain: z$1.string().optional(), networkId: z$1.enum(["mainnet", "testnet"]), /** the serving-generation digest of the snapshot this config came from * (atomic-deploys 10) — rides the client config for the soft-refresh signal */ deploymentDigest: z$1.string().optional(), title: z$1.string().optional(), description: z$1.string().optional(), repository: z$1.string().optional(), host: FederationEntrySchema.extend({ localPath: z$1.string().optional(), port: z$1.number().optional(), secrets: z$1.array(z$1.string()).optional(), remoteUrl: z$1.string().optional() }), ui: FederationEntrySchema.extend({ localPath: z$1.string().optional(), port: z$1.number().optional(), /** browser-facing base; when set the client config serves this instead * of `url` (server-side loading keeps `url`) */ publicUrl: z$1.string().optional(), ssrUrl: z$1.string().optional(), ssrIntegrity: z$1.string().optional(), ssrEntryUrl: z$1.string().optional(), /** pin-derived hashed browser manifest (mf-manifest) */ browserManifestUrl: z$1.string().optional(), /** SRI of the pinned compose manifest (manifest.gen.json) — verified by * the host compose on every fetch (see PluginRuntimeUiSchema) */ manifestIntegrity: z$1.string().optional(), /** The compose manifest URL resolved through the pin's immutable version * directory (#826) — see PluginRuntimeUiSchema */ manifestUrl: z$1.string().optional(), /** Shared-singleton `name → version` the pinned build embedded (#546) — * see PluginRuntimeUiSchema; mirrors the runtime slot type */ sharedVersions: z$1.record(z$1.string(), z$1.string()).optional(), dependsOn: z$1.array(z$1.string()).optional() }), api: FederationEntrySchema.extend({ localPath: z$1.string().optional(), port: z$1.number().optional(), proxy: z$1.string().optional(), variables: JsonObjectSchema.optional(), secrets: z$1.array(z$1.string()).optional(), shared: SharedDepMapSchema.optional(), dependsOn: z$1.array(z$1.string()).optional() }), auth: FederationEntrySchema.extend({ extendsRef: z$1.string().optional(), localPath: z$1.string().optional(), port: z$1.number().optional(), proxy: z$1.string().optional(), variables: JsonObjectSchema.optional(), secrets: z$1.array(z$1.string()).optional(), shared: SharedDepMapSchema.optional(), dependsOn: z$1.array(z$1.string()).optional(), ui: PluginRuntimeUiSchema.optional() }).optional(), plugins: z$1.record(PluginKeySchema, RuntimePluginConfigSchema).optional(), nodes: z$1.record(z$1.string(), RuntimeDependencyNodeSchema).optional() }); const ClientRuntimeConfigSchema = z$1.object({ env: z$1.enum([ "development", "production", "staging" ]), account: z$1.string(), networkId: z$1.enum(["mainnet", "testnet"]), /** the serving-generation digest this document was rendered from (soft refresh) */ deploymentDigest: z$1.string().optional(), hostUrl: z$1.string().optional(), assetsUrl: z$1.string(), apiBase: z$1.string(), rpcBase: z$1.templateLiteral([z$1.literal("/"), z$1.string()]), repository: z$1.string().optional(), authAvailable: z$1.boolean().optional(), runtime: ClientRuntimeInfoSchema.optional(), ui: z$1.object({ name: z$1.string(), url: z$1.string(), entry: z$1.string(), integrity: z$1.string().optional(), /** the content-hashed container entry URL when the slot pins a version manifest */ entryUrl: z$1.string().optional(), /** composition payload — the server sets it; the client reconstructs the same tree from it before hydrate */ compose: ComposePayloadSchema.optional() }).optional(), api: z$1.object({ name: z$1.string(), url: z$1.string(), entry: z$1.string(), integrity: z$1.string().optional(), variables: JsonObjectSchema.optional() }).optional(), auth: z$1.object({ name: z$1.string(), url: z$1.string(), entry: z$1.string(), integrity: z$1.string().optional(), variables: JsonObjectSchema.optional() }).optional(), plugins: z$1.record(z$1.string(), z$1.object({ name: z$1.string(), url: z$1.string(), entry: z$1.string(), integrity: z$1.string().optional(), variables: JsonObjectSchema.optional(), ui: z$1.object({ name: z$1.string(), url: z$1.string(), entry: z$1.string(), source: SourceModeSchema, integrity: z$1.string().optional(), ssrUrl: z$1.string().optional(), ssrIntegrity: z$1.string().optional(), entryUrl: z$1.string().optional() }).optional() })).optional() }); //#endregion export { ApiPluginConfigSchema, BosConfigInputSchema, BosConfigSchema, BosPluginRefSchema, BosStagingSchema, CdnConfigSchema, CiConfigSchema, ClientRuntimeConfigSchema, ClientRuntimeInfoSchema, ComposableAppEntrySchema, DependencyNodeKindSchema, ExtendsSchema, FederationEntrySchema, HostConfigSchema, JsonObjectSchema, JsonValueSchema, ParentStarterConfigSchema, PluginUiConfigSchema, PublishAuthSchema, PublishConfigSchema, RailwayCiSchema, RemoteDigestSchema, RuntimeConfigSchema, RuntimeDependencyNodeSchema, RuntimeLineageSchema, RuntimePluginConfigSchema, SeedConfigSchema, SeedOwnerAdminSchema, SharedConfigSchema, SharedDepConfigSchema, SharedDepMapSchema, SourceModeSchema, StarterLevelConfigSchema, StarterLevelSchema, UiConfigSchema }; //# sourceMappingURL=types.mjs.map