feat: add resource schemas and validation scripts

- Introduced new resource schemas for maps, scenarios, unit sets, and turn commands using Zod.
- Implemented a script to generate JSON schemas from Zod schemas.
- Added a validation script to ensure resource JSON files conform to their respective schemas.
- Updated the logic package to export new resource schemas.
- Added new dependencies for schema generation and validation.
- Created a tools-scripts package for resource management tasks.
This commit is contained in:
2026-01-18 08:04:02 +00:00
parent e3f7758187
commit 81594a25c3
20 changed files with 452 additions and 94 deletions
@@ -1,6 +1,7 @@
import { GENERAL_TURN_COMMAND_KEYS, isGeneralTurnCommandKey, type GeneralTurnCommandKey } from './general/index.js';
import { NATION_TURN_COMMAND_KEYS, isNationTurnCommandKey, type NationTurnCommandKey } from './nation/index.js';
import { asStringArray, isRecord } from '@sammo-ts/common';
import { asStringArray } from '@sammo-ts/common';
import { TurnCommandProfileInputSchema } from '../../resources/turnCommandSchema.js';
export interface TurnCommandProfile {
general: GeneralTurnCommandKey[];
@@ -44,18 +45,20 @@ export const parseTurnCommandProfile = (
raw: unknown,
fallback: TurnCommandProfile = DEFAULT_TURN_COMMAND_PROFILE
): TurnCommandProfile => {
if (!isRecord(raw)) {
const parsed = TurnCommandProfileInputSchema.safeParse(raw);
if (!parsed.success) {
return fallback;
}
const data = parsed.data;
return {
general: parseKeyList({
raw: raw.general,
raw: data.general,
defaults: fallback.general,
isKey: isGeneralTurnCommandKey,
label: 'general',
}),
nation: parseKeyList({
raw: raw.nation,
raw: data.nation,
defaults: fallback.nation,
isKey: isNationTurnCommandKey,
label: 'nation',