Moving the CultLib pin forward to pick up the presence contract also brought ten unrelated commits, one of which republished the TypeScript packages under the @gamecult scope. Two things broke on that rename. The recipe selected build workspaces by package name, so `--workspace= cultcache-ts` no longer matched anything. Selecting by path instead says what is actually meant and survives the next rename. cultnet-ts depends on cultcache-ts by registry range, not by workspace protocol, so the vendored copy is only used because Heimdall overrides that name to the vendored path. The override still named the old one, and pnpm went looking for @gamecult/cultcache-ts on a registry that does not have it. Heimdall now uses the package's real name in its dependency, its override and its imports. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
84 lines
2.5 KiB
TypeScript
84 lines
2.5 KiB
TypeScript
import { defineDocumentType } from "@gamecult/cultcache-ts";
|
|
import { defineCultNetDocumentBinding } from "cultnet-ts";
|
|
import { CultMesh, type CultMeshRudpEndpoint } from "cultmesh-ts";
|
|
import { z } from "zod";
|
|
|
|
import type { HeimdallConfig } from "./config.js";
|
|
import {
|
|
buildHeimdallVerseRecords,
|
|
type CultCacheRecord,
|
|
type HeimdallRuntimePulse,
|
|
} from "./verse-state.js";
|
|
|
|
const ODIN_DOCUMENT_CATALOG_CONNECTION_ID = 0x0d1d0002;
|
|
const HEIMDALL_ODIN_RUNTIME_ID = "yggdrasil-heimdall";
|
|
|
|
export type HeimdallOdinDocumentPublisher = (
|
|
record: CultCacheRecord,
|
|
endpoint: CultMeshRudpEndpoint,
|
|
) => Promise<void>;
|
|
|
|
export async function publishHeimdallOdinState(
|
|
config: HeimdallConfig,
|
|
pulse: HeimdallRuntimePulse,
|
|
options: {
|
|
environment?: Record<string, string | undefined>;
|
|
publish?: HeimdallOdinDocumentPublisher;
|
|
} = {},
|
|
): Promise<void> {
|
|
if (!config.odinCultMeshUri) {
|
|
return;
|
|
}
|
|
|
|
const endpoint = CultMesh.resolveRudpEndpoint(
|
|
config.odinCultMeshUri,
|
|
options.environment ?? process.env,
|
|
);
|
|
const publish = options.publish ?? publishRecord;
|
|
for (const record of buildHeimdallVerseRecords(config, pulse)) {
|
|
await publish({ ...record, key: odinCatalogKey(record) }, endpoint);
|
|
}
|
|
}
|
|
|
|
function odinCatalogKey(record: CultCacheRecord): string {
|
|
switch (record.schemaId) {
|
|
case "gamecult.eve.provider_advertisement.v1":
|
|
return "eve:provider:heimdall";
|
|
case "heimdall.command_boundary.v1":
|
|
return "heimdall:command-boundary";
|
|
case "gamecult.eve.plugin_advertisement.v1":
|
|
return "eve:plugin:gamecult.heimdall.access";
|
|
case "heimdall.transport_profile.v1":
|
|
return "heimdall:transport-profile";
|
|
default:
|
|
throw new Error(`Heimdall has no Odin catalog key for ${record.schemaId}`);
|
|
}
|
|
}
|
|
|
|
async function publishRecord(
|
|
record: CultCacheRecord,
|
|
endpoint: CultMeshRudpEndpoint,
|
|
): Promise<void> {
|
|
const definition = defineDocumentType({
|
|
type: record.schemaName,
|
|
schemaId: record.schemaId,
|
|
schemaName: record.schemaName,
|
|
schemaVersion: record.schemaVersion,
|
|
schema: z.record(z.unknown()),
|
|
});
|
|
const payload = definition.schema.parse(record.payload);
|
|
await CultMesh.publishRudpDocumentOnce(
|
|
HEIMDALL_ODIN_RUNTIME_ID,
|
|
ODIN_DOCUMENT_CATALOG_CONNECTION_ID,
|
|
endpoint,
|
|
defineCultNetDocumentBinding({ definition }),
|
|
record.key,
|
|
payload,
|
|
{
|
|
flushTimeoutMs: 500,
|
|
resendPollMs: 10,
|
|
sourceRole: "heimdall-auth-authority",
|
|
tags: ["heimdall", "redacted", "discovery"],
|
|
},
|
|
);
|
|
}
|