npm.io
0.0.0 • Published 2d ago

@game-infra/common-data-model

Licence
Version
0.0.0
Deps
0
Size
188 kB
Vulns
0
Weekly
0

@game-infra/common-data-model

Generic data-model mechanism for narrative game content: a codec registry, entity/schema-config types (items, personas, organizations, cities), display and editor schema types, maturity tiers, event-JSON types, formation and objective types. Every file here is mechanism; games supply the actual content via value-level registries and config injection.

Published to npm. Also consumable as sibling source.

Install

"@game-infra/common-data-model": "link:../../game-infra/packages/common-data-model"
// or from npm
"@game-infra/common-data-model": "^0.1.0"

valibot is a peer dependency (^1.4.0).

Usage

The extension pattern is value-level registries + config injection, not module augmentation. A game defines extra codecs and merges them with the common set:

import { createCodecRegistry, commonPreconditionCodecs } from "@game-infra/common-data-model";
import { myGameCodecs } from "./codecs.js";

const registry = createCodecRegistry(
  [...commonPreconditionCodecs, ...myGameCodecs],
  "Precondition",
);
registry.get("HasItem"); // the common HasItem codec

Schema-config types (ItemSchemaConfig, PersonaSchemaConfig, EntityDisplaySchemaConfig, …) let a game supply a valibot schema plus UI metadata; editors render data-driven UI with compile-time key checking.

Extension points

  • Codec registries — concatenate common*Codecs with game codecs, pass to createCodecRegistry (or EventEditorConfig.codecs).
  • Schema-config objects — provide a game valibot schema + display metadata.
  • Game-specific codecs (e.g. CastSpell, UseItem) live in the game's own data-model package, not here.

Dependencies

Peer valibot. No internal @game-infra/* deps.

Consumers

@game-infra/event-schemas (re-exports EntityInfo / AvailableEntities), event-editor, and game data-model packages.