@sf-kmods/kdataforgejs-cli 2026.4.19 → 2026.4.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -2
- package/dist/cli.js +3 -1
- package/dist/commands/gameData.js +4 -3
- package/dist/commands/sync.js +2 -0
- package/dist/types/configTypes.js +74 -0
- package/dist/types/contentTypes.js +152 -0
- package/dist/types/organize.js +4 -2
- package/package.json +4 -2
- package/schemas/actor-selector.schema.yml +39 -0
- package/schemas/asset.schema.yml +27 -0
- package/schemas/building.schema.yml +16 -0
- package/schemas/category_reorder.schema.yml +41 -0
- package/schemas/cdo.schema.yml +92 -0
- package/schemas/class.schema.yml +27 -0
- package/schemas/common.schema.yml +543 -0
- package/schemas/config.schema.yml +208 -0
- package/schemas/curve.schema.yml +59 -0
- package/schemas/dataasset.schema.yml +33 -0
- package/schemas/eventrule.schema.yml +47 -0
- package/schemas/gametag.schema.yml +24 -0
- package/schemas/item.schema.yml +16 -0
- package/schemas/localization.schema.yml +27 -0
- package/schemas/mam.schema.yml +5 -0
- package/schemas/pack.schema.yml +60 -0
- package/schemas/recipe.schema.yml +26 -0
- package/schemas/research.schema.yml +76 -0
- package/schemas/resource.schema.yml +16 -0
- package/schemas/resourcenode.schema.yml +117 -0
- package/schemas/schematic.schema.yml +75 -0
- package/schemas/sinkpoints.schema.yml +29 -0
- package/schemas/sound.schema.yml +45 -0
- package/schemas/sublevel.schema.yml +16 -0
- package/schemas/unlock.schema.yml +21 -0
package/README.md
CHANGED
|
@@ -18,9 +18,9 @@ npm run verify
|
|
|
18
18
|
| `kdf format [dir]` | Formats JavaScript and TypeScript files below `DataForge/scripts/` with bundled Biome. |
|
|
19
19
|
| `kdf lint [dir]` | Lints JavaScript and TypeScript files below `DataForge/scripts/` with bundled Biome recommended rules. |
|
|
20
20
|
| `kdf validate [dir]` | Checks `pack.yml`, the entry file, the static import graph and the digests of declared imports. |
|
|
21
|
-
| `kdf sync [dir]` | Generates sorted `imports`, SHA-256 digests
|
|
21
|
+
| `kdf sync [dir]` | Generates sorted `imports`, SHA-256 digests, `reflectionClasses`, and pack-local config key/value types. |
|
|
22
22
|
| `kdf hash [dir]` | Rewrites stale `sha256` values of declared imports and leaves your comments alone. |
|
|
23
|
-
| `kdf game-data [dir]` | Runs manifest sync, finds a modded Satisfactory installation, starts a full reflection export, closes the game and imports the archive plus generated TypeScript declarations. Use `--game-path <root-or-executable>` to select an installation explicitly. |
|
|
23
|
+
| `kdf game-data [dir]` | Runs manifest sync, finds a modded Satisfactory installation, starts a full reflection export, closes the game and imports the archive plus generated TypeScript declarations. Use `--game-path <root-or-executable>` to select an installation explicitly; add `--content-types` for schema-derived content document types. |
|
|
24
24
|
|
|
25
25
|
Exit code `0` means all good, `1` means findings, `2` means the command was used wrong.
|
|
26
26
|
|
|
@@ -60,3 +60,16 @@ archive can be large. Declarations are split into `runtime.d.ts`, `globals.d.ts`
|
|
|
60
60
|
and Unreal-path `paths/` groups behind `index.d.ts`. Biome formats generated TypeScript and JSON through its JavaScript
|
|
61
61
|
API. Projects created by `kdf init` also ignore `DataForge/typescript/kdataforgejs/`; regenerate it for the local game
|
|
62
62
|
and mod set. Temporary export and staging directories are removed after the game exits.
|
|
63
|
+
|
|
64
|
+
`kdf game-data --content-types` opts into schema-derived document entries for `applyDocument`, including schematics,
|
|
65
|
+
research, unlocks, buildings and DataAssets. Field names and structural types are checked locally; runtime validation
|
|
66
|
+
still enforces ranges, conditional rules, reflection, capabilities and lifecycle. Export without the flag to restore
|
|
67
|
+
generic content types. The schemas ship in the CLI package; generation does not fetch schema URLs.
|
|
68
|
+
|
|
69
|
+
`kdf sync` writes `DataForge/typescript/kdataforgejs-config.d.ts` from authored `*.config.yml`/`*.config.yaml` fields.
|
|
70
|
+
These keys type `ctx.config.get` and `onChange`; runtime access still requires `kdf.config.read`. Regenerate the file
|
|
71
|
+
after changing config definitions. Keep generated files outside your source edits.
|
|
72
|
+
|
|
73
|
+
For CLI maintenance, `pnpm run sync:schemas` refreshes the checked-in `schemas/` snapshot from the workspace's
|
|
74
|
+
`kdataforge-editor/crates/kdf-validation/schemas/`. Normal builds and installed packages use the bundled snapshot and
|
|
75
|
+
do not require a separate editor checkout.
|
package/dist/cli.js
CHANGED
|
@@ -18,7 +18,7 @@ Usage:
|
|
|
18
18
|
kdf validate [dir] Check pack.yml, entry, static imports and import digests
|
|
19
19
|
kdf sync [dir] Generate imports, hashes and reflection classes from source
|
|
20
20
|
kdf hash [dir] Update sha256 of declared script imports in pack.yml
|
|
21
|
-
kdf game-data [dir] [--game-path <path>]
|
|
21
|
+
kdf game-data [dir] [--game-path <path>] [--content-types] Export game data; optionally generate schema-derived content types
|
|
22
22
|
kdf --help | --version
|
|
23
23
|
`;
|
|
24
24
|
const DEFAULT_DEPENDENCIES = { importGameData };
|
|
@@ -36,6 +36,7 @@ async function runCli(request, dependencies) {
|
|
|
36
36
|
name: { type: "string" },
|
|
37
37
|
"game-path": { type: "string" },
|
|
38
38
|
timeout: { type: "string" },
|
|
39
|
+
"content-types": { type: "boolean", default: false },
|
|
39
40
|
force: { type: "boolean", default: false },
|
|
40
41
|
help: { type: "boolean", short: "h", default: false },
|
|
41
42
|
version: { type: "boolean", short: "v", default: false },
|
|
@@ -86,6 +87,7 @@ async function runCli(request, dependencies) {
|
|
|
86
87
|
destination: directory,
|
|
87
88
|
...(values["game-path"] ? { gamePath: values["game-path"] } : {}),
|
|
88
89
|
...(timeoutMilliseconds === undefined ? {} : { timeoutMilliseconds }),
|
|
90
|
+
...(values["content-types"] ? { contentTypes: true } : {}),
|
|
89
91
|
});
|
|
90
92
|
io.out(`Imported game data from ${result.installation.root}`);
|
|
91
93
|
io.out(`Archive: ${result.archivePath}`);
|
|
@@ -19,7 +19,7 @@ export async function importGameData(options, dependencies = {}) {
|
|
|
19
19
|
const plan = createLaunchPlan(installation, platform, exportDirectory, savePath);
|
|
20
20
|
const launchedGame = await (dependencies.launch ?? launchGame)(plan);
|
|
21
21
|
const artifacts = await waitForExport(exportDirectory, timeoutMilliseconds, dependencies.sleep ?? delay, launchedGame?.exited);
|
|
22
|
-
const result = installExport(destination, installation, artifacts);
|
|
22
|
+
const result = installExport({ ...options, destination }, installation, artifacts);
|
|
23
23
|
if (launchedGame !== undefined)
|
|
24
24
|
await waitForCleanGameExit(launchedGame.exited);
|
|
25
25
|
return result;
|
|
@@ -180,7 +180,8 @@ function findCompletedExport(exportDirectory) {
|
|
|
180
180
|
}
|
|
181
181
|
return { archive, typesDirectory };
|
|
182
182
|
}
|
|
183
|
-
function installExport(
|
|
183
|
+
function installExport(options, installation, artifacts) {
|
|
184
|
+
const destination = options.destination;
|
|
184
185
|
mkdirSync(destination, { recursive: true });
|
|
185
186
|
const archiveDirectory = join(destination, ".kdataforge");
|
|
186
187
|
mkdirSync(archiveDirectory, { recursive: true });
|
|
@@ -190,7 +191,7 @@ function installExport(destination, installation, artifacts) {
|
|
|
190
191
|
rmSync(typesDirectory, { recursive: true, force: true });
|
|
191
192
|
mkdirSync(typesDirectory, { recursive: true });
|
|
192
193
|
cpSync(artifacts.typesDirectory, typesDirectory, { recursive: true });
|
|
193
|
-
const declarationPath = organizeGeneratedDeclarations(typesDirectory);
|
|
194
|
+
const declarationPath = organizeGeneratedDeclarations(typesDirectory, { contentTypes: options.contentTypes });
|
|
194
195
|
const tsconfigPath = join(destination, "tsconfig.kdf.json");
|
|
195
196
|
writeFileSync(tsconfigPath, formatGeneratedContent(JSON.stringify({
|
|
196
197
|
extends: "./DataForge/typescript/kdataforgejs/tsconfig.json",
|
package/dist/commands/sync.js
CHANGED
|
@@ -4,6 +4,7 @@ import { isMap, isSeq, parseDocument, YAMLMap, YAMLSeq } from "yaml";
|
|
|
4
4
|
import { findPackRoots } from "../pack/discover.js";
|
|
5
5
|
import { sha256Of } from "../pack/imports.js";
|
|
6
6
|
import { discoverPackUsage } from "../pack/usage.js";
|
|
7
|
+
import { syncConfigTypes } from "../types/configTypes.js";
|
|
7
8
|
/** Generates manifest imports, digests, and reflection class authority from source usage. */
|
|
8
9
|
export function syncProject(projectRoot) {
|
|
9
10
|
if (!existsSync(projectRoot))
|
|
@@ -18,6 +19,7 @@ function syncPack(packRoot) {
|
|
|
18
19
|
const scripts = document.get("scripts", true);
|
|
19
20
|
if (!isSeq(scripts))
|
|
20
21
|
return false;
|
|
22
|
+
syncConfigTypes(packRoot);
|
|
21
23
|
for (const script of scripts.items) {
|
|
22
24
|
if (!isMap(script))
|
|
23
25
|
continue;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { parse } from "yaml";
|
|
4
|
+
import { formatGeneratedContent } from "./format.js";
|
|
5
|
+
const CONFIG_ID = /^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*$/u;
|
|
6
|
+
const MAX_CONFIG_FILES = 256;
|
|
7
|
+
const MAX_FIELDS = 1024;
|
|
8
|
+
const MAX_DIRECTORY_DEPTH = 16;
|
|
9
|
+
/** Emits pack-local keys only; a generated map never grants config access to a script. */
|
|
10
|
+
export function syncConfigTypes(packRoot) {
|
|
11
|
+
const fields = new Map();
|
|
12
|
+
for (const path of configFiles(packRoot)) {
|
|
13
|
+
const document = parse(readFileSync(path, "utf8"));
|
|
14
|
+
const entries = asRecord(document)?.fields;
|
|
15
|
+
if (!Array.isArray(entries))
|
|
16
|
+
continue;
|
|
17
|
+
for (const entry of entries) {
|
|
18
|
+
const field = asRecord(entry);
|
|
19
|
+
if (field === undefined || typeof field.id !== "string" || !CONFIG_ID.test(field.id))
|
|
20
|
+
throw new Error(`Invalid config id in ${path}.`);
|
|
21
|
+
if (fields.has(field.id))
|
|
22
|
+
throw new Error(`Duplicate config id '${field.id}'.`);
|
|
23
|
+
if (fields.size >= MAX_FIELDS)
|
|
24
|
+
throw new Error("Config type generation exceeds field limit.");
|
|
25
|
+
fields.set(field.id, fieldType(field));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const path = join(packRoot, "typescript/kdataforgejs-config.d.ts");
|
|
29
|
+
const entries = [...fields].sort(([left], [right]) => left.localeCompare(right))
|
|
30
|
+
.map(([id, type]) => `readonly ${JSON.stringify(id)}: ${type};`).join("\n");
|
|
31
|
+
const content = formatGeneratedContent(`// Generated by kdf sync. Do not edit.\ndeclare module "@sf-kmods/kdataforgejs" { export interface ConfigValueMap {\n${entries}\n} }\n`, path);
|
|
32
|
+
if (!existsSync(path) || readFileSync(path, "utf8") !== content) {
|
|
33
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
34
|
+
writeFileSync(path, content);
|
|
35
|
+
}
|
|
36
|
+
return path;
|
|
37
|
+
}
|
|
38
|
+
function configFiles(root) {
|
|
39
|
+
const result = [];
|
|
40
|
+
const visit = (directory, depth) => {
|
|
41
|
+
if (depth > MAX_DIRECTORY_DEPTH)
|
|
42
|
+
throw new Error("Config type generation exceeds directory depth limit.");
|
|
43
|
+
for (const entry of readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
44
|
+
if (entry.isSymbolicLink() || entry.name === "typescript" || entry.name.startsWith("."))
|
|
45
|
+
continue;
|
|
46
|
+
const path = join(directory, entry.name);
|
|
47
|
+
if (entry.isDirectory())
|
|
48
|
+
visit(path, depth + 1);
|
|
49
|
+
else if (entry.isFile() && /\.config\.ya?ml$/iu.test(entry.name)) {
|
|
50
|
+
if (result.length >= MAX_CONFIG_FILES)
|
|
51
|
+
throw new Error("Config type generation exceeds file limit.");
|
|
52
|
+
result.push(path);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
visit(root, 0);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
function fieldType(field) {
|
|
60
|
+
let scalar;
|
|
61
|
+
const valueType = String(field.valueType ?? "").trim().toLowerCase();
|
|
62
|
+
if (field.type === "boolean" || valueType === "bool")
|
|
63
|
+
scalar = "boolean";
|
|
64
|
+
else if (field.type === "number" || ["int8", "int16", "int32", "int64", "uint8", "float", "double"].includes(valueType))
|
|
65
|
+
scalar = valueType === "int64" ? "number | bigint" : "number";
|
|
66
|
+
else if (field.type === "text" || field.type === "select")
|
|
67
|
+
scalar = "string";
|
|
68
|
+
else
|
|
69
|
+
throw new Error(`Unsupported config field type '${String(field.type)}'.`);
|
|
70
|
+
return field.multiple === true ? `readonly (${scalar})[]` : scalar;
|
|
71
|
+
}
|
|
72
|
+
function asRecord(value) {
|
|
73
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
|
|
74
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { basename, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import ts from "typescript";
|
|
5
|
+
import { parse } from "yaml";
|
|
6
|
+
const DOCUMENTS = {
|
|
7
|
+
AssetDocument: "asset", CategoryReorderDocument: "category_reorder", CdoDocument: "cdo",
|
|
8
|
+
CurveDocument: "curve", DataAssetDocument: "dataasset", EventRuleDocument: "eventrule",
|
|
9
|
+
GameTagDocument: "gametag", ItemDocument: "item", ResourceDocument: "resource", BuildingDocument: "building",
|
|
10
|
+
UnlockDocument: "unlock", RecipeDocument: "recipe", SchematicDocument: "schematic", ResearchDocument: "research",
|
|
11
|
+
ResourceNodeDocument: "resourcenode", SinkPointsDocument: "sinkpoints", SoundDocument: "sound", SublevelDocument: "sublevel",
|
|
12
|
+
};
|
|
13
|
+
/** Uses the same bundled schemas as KDF validation; never resolves schema URLs over the network. */
|
|
14
|
+
export function strictContentDeclarations(source) {
|
|
15
|
+
const generator = new ContentTypes();
|
|
16
|
+
const file = ts.createSourceFile("runtime.d.ts", source, ts.ScriptTarget.Latest, true);
|
|
17
|
+
const replacements = [];
|
|
18
|
+
const visit = (node) => {
|
|
19
|
+
if (ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) {
|
|
20
|
+
const schema = DOCUMENTS[node.name.text];
|
|
21
|
+
if (schema !== undefined)
|
|
22
|
+
replacements.push({ start: node.getStart(file), end: node.end,
|
|
23
|
+
text: `export type ${node.name.text} = ${generator.reference(`${schema}.schema.yml`, "")};` });
|
|
24
|
+
}
|
|
25
|
+
ts.forEachChild(node, visit);
|
|
26
|
+
};
|
|
27
|
+
visit(file);
|
|
28
|
+
let result = source;
|
|
29
|
+
for (const replacement of replacements.sort((left, right) => right.start - left.start)) {
|
|
30
|
+
result = result.slice(0, replacement.start) + replacement.text + result.slice(replacement.end);
|
|
31
|
+
}
|
|
32
|
+
if (replacements.length === 0)
|
|
33
|
+
return source;
|
|
34
|
+
return `${result}\ndeclare module "@sf-kmods/kdataforgejs" {\n${generator.declarations()}\n}\n`;
|
|
35
|
+
}
|
|
36
|
+
class ContentTypes {
|
|
37
|
+
schemas = new Map();
|
|
38
|
+
aliases = new Map();
|
|
39
|
+
directory = schemaDirectory();
|
|
40
|
+
reference(file, pointer) {
|
|
41
|
+
if (!/^[a-z_\-]+\.schema\.yml$/u.test(file) || (pointer !== "" && !pointer.startsWith("/"))) {
|
|
42
|
+
throw new Error(`Unsupported local schema reference: ${file}#${pointer}`);
|
|
43
|
+
}
|
|
44
|
+
const key = `${file}#${pointer}`;
|
|
45
|
+
const name = aliasName(key);
|
|
46
|
+
if (!this.aliases.has(key)) {
|
|
47
|
+
let node = this.load(file);
|
|
48
|
+
for (const part of pointer.split("/").slice(1)) {
|
|
49
|
+
node = record(node)?.[part.replaceAll("~1", "/").replaceAll("~0", "~")];
|
|
50
|
+
}
|
|
51
|
+
const schema = record(node);
|
|
52
|
+
if (schema === undefined)
|
|
53
|
+
throw new Error(`Missing bundled schema definition: ${key}`);
|
|
54
|
+
this.aliases.set(key, { file, pointer, schema });
|
|
55
|
+
}
|
|
56
|
+
return name;
|
|
57
|
+
}
|
|
58
|
+
declarations() {
|
|
59
|
+
const declarations = [];
|
|
60
|
+
for (const [key, located] of this.aliases) {
|
|
61
|
+
declarations.push(`type ${aliasName(key)} = ${this.render(located.schema, located.file)};`);
|
|
62
|
+
}
|
|
63
|
+
return declarations.join("\n");
|
|
64
|
+
}
|
|
65
|
+
load(file) {
|
|
66
|
+
const cached = this.schemas.get(file);
|
|
67
|
+
if (cached !== undefined)
|
|
68
|
+
return cached;
|
|
69
|
+
const schema = record(parse(readFileSync(join(this.directory, file), "utf8")));
|
|
70
|
+
if (schema === undefined)
|
|
71
|
+
throw new Error(`Invalid bundled schema: ${file}`);
|
|
72
|
+
this.schemas.set(file, schema);
|
|
73
|
+
return schema;
|
|
74
|
+
}
|
|
75
|
+
render(schema, file) {
|
|
76
|
+
const parts = [];
|
|
77
|
+
if (typeof schema.$ref === "string") {
|
|
78
|
+
const [path = "", pointer = ""] = schema.$ref.split("#");
|
|
79
|
+
parts.push(this.reference(path === "" ? file : basename(path), pointer));
|
|
80
|
+
}
|
|
81
|
+
if ("const" in schema)
|
|
82
|
+
parts.push(literal(schema.const));
|
|
83
|
+
else if (Array.isArray(schema.enum))
|
|
84
|
+
parts.push(schema.enum.map(literal).join(" | "));
|
|
85
|
+
else {
|
|
86
|
+
const type = this.valueType(schema, file);
|
|
87
|
+
if (type !== undefined)
|
|
88
|
+
parts.push(type);
|
|
89
|
+
}
|
|
90
|
+
for (const key of ["allOf", "anyOf", "oneOf"]) {
|
|
91
|
+
const entries = schema[key];
|
|
92
|
+
if (!Array.isArray(entries))
|
|
93
|
+
continue;
|
|
94
|
+
const types = entries.map((entry) => this.render(record(entry) ?? {}, file));
|
|
95
|
+
if (types.length > 0)
|
|
96
|
+
parts.push(`(${types.join(key === "allOf" ? " & " : " | ")})`);
|
|
97
|
+
}
|
|
98
|
+
return parts.length === 0 ? "unknown" : parts.map((part) => `(${part})`).join(" & ");
|
|
99
|
+
}
|
|
100
|
+
valueType(schema, file) {
|
|
101
|
+
if (Array.isArray(schema.type)) {
|
|
102
|
+
return schema.type.map((type) => this.valueType({ ...schema, type }, file) ?? "unknown").join(" | ");
|
|
103
|
+
}
|
|
104
|
+
if (schema.type === "string")
|
|
105
|
+
return "string";
|
|
106
|
+
if (schema.type === "number" || schema.type === "integer")
|
|
107
|
+
return "number";
|
|
108
|
+
if (schema.type === "boolean")
|
|
109
|
+
return "boolean";
|
|
110
|
+
if (schema.type === "null")
|
|
111
|
+
return "null";
|
|
112
|
+
if (schema.type === "array")
|
|
113
|
+
return `ReadonlyArray<${this.render(record(schema.items) ?? {}, file)}>`;
|
|
114
|
+
if (schema.type === "object" || schema.properties !== undefined || schema.required !== undefined)
|
|
115
|
+
return this.objectType(schema, file);
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
objectType(schema, file) {
|
|
119
|
+
const properties = record(schema.properties) ?? {};
|
|
120
|
+
const required = new Set(Array.isArray(schema.required) ? schema.required.filter((value) => typeof value === "string") : []);
|
|
121
|
+
const names = [...new Set([...Object.keys(properties), ...required])].sort();
|
|
122
|
+
const fields = names.map((name) => `readonly ${JSON.stringify(name)}${required.has(name) ? "" : "?"}: ${this.render(record(properties[name]) ?? {}, file)};`);
|
|
123
|
+
const excluded = record(schema.not)?.required;
|
|
124
|
+
if (Array.isArray(excluded) && excluded.length === 1 && typeof excluded[0] === "string") {
|
|
125
|
+
fields.push(`readonly ${JSON.stringify(excluded[0])}?: never;`);
|
|
126
|
+
}
|
|
127
|
+
const additional = record(schema.additionalProperties);
|
|
128
|
+
if (additional !== undefined)
|
|
129
|
+
fields.push(`readonly [key: string]: ${this.render(additional, file)};`);
|
|
130
|
+
if (fields.length === 0 && schema.additionalProperties !== false)
|
|
131
|
+
return "Readonly<Record<string, unknown>>";
|
|
132
|
+
return `{ ${fields.join(" ")} }`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function record(value) {
|
|
136
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
|
|
137
|
+
}
|
|
138
|
+
function literal(value) {
|
|
139
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean")
|
|
140
|
+
return JSON.stringify(value);
|
|
141
|
+
throw new Error("Content schema contains a non-scalar enum or const.");
|
|
142
|
+
}
|
|
143
|
+
function aliasName(key) {
|
|
144
|
+
return `KDFSchema_${key.replace(/\.schema\.yml/gu, "").replace(/[^a-zA-Z0-9]/gu, "_")}`;
|
|
145
|
+
}
|
|
146
|
+
function schemaDirectory() {
|
|
147
|
+
const directories = [new URL("../../schemas/", import.meta.url), new URL("../../../schemas/", import.meta.url)];
|
|
148
|
+
const directory = directories.find((candidate) => existsSync(new URL("common.schema.yml", candidate)));
|
|
149
|
+
if (directory === undefined)
|
|
150
|
+
throw new Error("Bundled content schemas missing; rebuild the CLI package.");
|
|
151
|
+
return fileURLToPath(directory);
|
|
152
|
+
}
|
package/dist/types/organize.js
CHANGED
|
@@ -2,13 +2,15 @@ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node
|
|
|
2
2
|
import { dirname, join, sep } from "node:path";
|
|
3
3
|
import ts from "typescript";
|
|
4
4
|
import { formatGeneratedContent } from "./format.js";
|
|
5
|
+
import { strictContentDeclarations } from "./contentTypes.js";
|
|
5
6
|
const RUNTIME_MODULE = "@sf-kmods/kdataforgejs";
|
|
6
7
|
const SATISFACTORY_MODULE = "satisfactory";
|
|
7
8
|
const GENERATED_FILE = "kdataforge.generated.d.ts";
|
|
8
9
|
/** Splits exported ambient declarations into deterministic, navigable files and returns the entry declaration. */
|
|
9
|
-
export function organizeGeneratedDeclarations(typesDirectory) {
|
|
10
|
+
export function organizeGeneratedDeclarations(typesDirectory, options = {}) {
|
|
10
11
|
const generatedPath = join(typesDirectory, GENERATED_FILE);
|
|
11
|
-
const
|
|
12
|
+
const original = readFileSync(generatedPath, "utf8");
|
|
13
|
+
const source = ts.createSourceFile(generatedPath, options.contentTypes ? strictContentDeclarations(original) : original, ts.ScriptTarget.ES2020, true, ts.ScriptKind.TS);
|
|
12
14
|
removePreviousOrganization(typesDirectory);
|
|
13
15
|
const references = [];
|
|
14
16
|
const runtimeDeclarations = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sf-kmods/kdataforgejs-cli",
|
|
3
|
-
"version": "2026.4.
|
|
3
|
+
"version": "2026.4.20",
|
|
4
4
|
"description": "kdf - create, type-check and validate KDataForge projects with KDataForgeJS (TypeScript) scripts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Kyri123/Kyrium",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"files": [
|
|
29
29
|
"dist",
|
|
30
30
|
"templates",
|
|
31
|
+
"schemas",
|
|
31
32
|
"README.md"
|
|
32
33
|
],
|
|
33
34
|
"engines": {
|
|
@@ -38,12 +39,13 @@
|
|
|
38
39
|
"@biomejs/wasm-nodejs": "2.6.3",
|
|
39
40
|
"typescript": ">=5.7.3 <6",
|
|
40
41
|
"yaml": "^2.6.1",
|
|
41
|
-
"@sf-kmods/kdataforgejs": "^2026.4.
|
|
42
|
+
"@sf-kmods/kdataforgejs": "^2026.4.20"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@types/node": "^22.10.0"
|
|
45
46
|
},
|
|
46
47
|
"scripts": {
|
|
48
|
+
"sync:schemas": "node scripts/sync-content-schemas.mjs",
|
|
47
49
|
"build": "tsc -p tsconfig.build.json",
|
|
48
50
|
"test": "tsc -p tsconfig.test.json && node --test \"dist-test/test/*.test.js\""
|
|
49
51
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
$schema: https://json-schema.org/draft/2020-12/schema
|
|
2
|
+
$id: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/actor-selector.schema.yml
|
|
3
|
+
title: KDataForge actor instance selector
|
|
4
|
+
type: object
|
|
5
|
+
additionalProperties: false
|
|
6
|
+
minProperties: 1
|
|
7
|
+
properties:
|
|
8
|
+
tags:
|
|
9
|
+
oneOf:
|
|
10
|
+
- { type: string, minLength: 1, pattern: '\S' }
|
|
11
|
+
- type: array
|
|
12
|
+
minItems: 1
|
|
13
|
+
items: { type: string, minLength: 1, pattern: '\S' }
|
|
14
|
+
sphere:
|
|
15
|
+
type: object
|
|
16
|
+
additionalProperties: false
|
|
17
|
+
required: [center, radius]
|
|
18
|
+
properties:
|
|
19
|
+
center: { $ref: '#/$defs/vector' }
|
|
20
|
+
radius: { type: number, exclusiveMinimum: 0 }
|
|
21
|
+
box:
|
|
22
|
+
type: object
|
|
23
|
+
additionalProperties: false
|
|
24
|
+
required: [min, max]
|
|
25
|
+
properties:
|
|
26
|
+
min: { $ref: '#/$defs/vector' }
|
|
27
|
+
max: { $ref: '#/$defs/vector' }
|
|
28
|
+
currentRecipe:
|
|
29
|
+
oneOf:
|
|
30
|
+
- { type: string, minLength: 1, pattern: '\S' }
|
|
31
|
+
- type: array
|
|
32
|
+
minItems: 1
|
|
33
|
+
items: { type: string, minLength: 1, pattern: '\S' }
|
|
34
|
+
$defs:
|
|
35
|
+
vector:
|
|
36
|
+
type: array
|
|
37
|
+
minItems: 3
|
|
38
|
+
maxItems: 3
|
|
39
|
+
items: { type: number }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
$schema: https://json-schema.org/draft/2020-12/schema
|
|
2
|
+
$id: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/asset.schema.yml
|
|
3
|
+
x-kdf-type: asset
|
|
4
|
+
title: KDataForge image assets
|
|
5
|
+
allOf:
|
|
6
|
+
- $ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/documentBase
|
|
7
|
+
- type: object
|
|
8
|
+
required: [assets]
|
|
9
|
+
properties:
|
|
10
|
+
type: { const: asset }
|
|
11
|
+
assets:
|
|
12
|
+
type: array
|
|
13
|
+
minItems: 1
|
|
14
|
+
items:
|
|
15
|
+
type: object
|
|
16
|
+
additionalProperties: false
|
|
17
|
+
required: [id, file]
|
|
18
|
+
properties:
|
|
19
|
+
id:
|
|
20
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/token
|
|
21
|
+
file:
|
|
22
|
+
type: string
|
|
23
|
+
minLength: 1
|
|
24
|
+
pattern: '\.(?:[Pp][Nn][Gg]|[Jj][Pp][Ee]?[Gg]|[Tt][Gg][Aa]|[Bb][Mm][Pp])$'
|
|
25
|
+
properties:
|
|
26
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/properties
|
|
27
|
+
unevaluatedProperties: false
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
$schema: https://json-schema.org/draft/2020-12/schema
|
|
2
|
+
$id: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/building.schema.yml
|
|
3
|
+
x-kdf-type: building
|
|
4
|
+
title: KDataForge buildings
|
|
5
|
+
allOf:
|
|
6
|
+
- $ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/documentBase
|
|
7
|
+
- type: object
|
|
8
|
+
required: [buildings]
|
|
9
|
+
properties:
|
|
10
|
+
type: { const: building }
|
|
11
|
+
buildings:
|
|
12
|
+
type: array
|
|
13
|
+
minItems: 1
|
|
14
|
+
items:
|
|
15
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/generatedEntry
|
|
16
|
+
unevaluatedProperties: false
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
$schema: https://json-schema.org/draft/2020-12/schema
|
|
2
|
+
$id: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/category_reorder.schema.yml
|
|
3
|
+
x-kdf-type: category_reorder
|
|
4
|
+
title: KDataForge category ordering
|
|
5
|
+
allOf:
|
|
6
|
+
- $ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/documentBase
|
|
7
|
+
- type: object
|
|
8
|
+
required: [subType, category, order]
|
|
9
|
+
properties:
|
|
10
|
+
type: { const: category_reorder }
|
|
11
|
+
subType:
|
|
12
|
+
type: string
|
|
13
|
+
enum: [items, recipe, schematic, settings]
|
|
14
|
+
category:
|
|
15
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/nonEmptyString
|
|
16
|
+
subCategory:
|
|
17
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/nonEmptyString
|
|
18
|
+
categoryPriority: { type: number }
|
|
19
|
+
subCategoryPriority: { type: number }
|
|
20
|
+
order:
|
|
21
|
+
type: array
|
|
22
|
+
minItems: 1
|
|
23
|
+
uniqueItems: true
|
|
24
|
+
items:
|
|
25
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/nonEmptyString
|
|
26
|
+
allOf:
|
|
27
|
+
- if:
|
|
28
|
+
required: [subCategoryPriority]
|
|
29
|
+
then:
|
|
30
|
+
required: [subCategory]
|
|
31
|
+
- if:
|
|
32
|
+
properties:
|
|
33
|
+
subType: { const: recipe }
|
|
34
|
+
required: [subType]
|
|
35
|
+
then:
|
|
36
|
+
not:
|
|
37
|
+
anyOf:
|
|
38
|
+
- required: [subCategory]
|
|
39
|
+
- required: [subCategoryPriority]
|
|
40
|
+
unevaluatedProperties: false
|
|
41
|
+
unevaluatedProperties: false
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
$schema: https://json-schema.org/draft/2020-12/schema
|
|
2
|
+
$id: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/cdo.schema.yml
|
|
3
|
+
x-kdf-type: cdo
|
|
4
|
+
title: KDataForge CDO patches
|
|
5
|
+
allOf:
|
|
6
|
+
- $ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/documentBase
|
|
7
|
+
- type: object
|
|
8
|
+
required: [patches]
|
|
9
|
+
properties:
|
|
10
|
+
type: { const: cdo }
|
|
11
|
+
patches:
|
|
12
|
+
type: array
|
|
13
|
+
minItems: 1
|
|
14
|
+
items:
|
|
15
|
+
type: object
|
|
16
|
+
oneOf:
|
|
17
|
+
- required: [properties]
|
|
18
|
+
not:
|
|
19
|
+
anyOf:
|
|
20
|
+
- required: [actorAction]
|
|
21
|
+
- required: [inventoryRemap]
|
|
22
|
+
- required: [actorAction]
|
|
23
|
+
not:
|
|
24
|
+
anyOf:
|
|
25
|
+
- required: [properties]
|
|
26
|
+
- required: [inventoryRemap]
|
|
27
|
+
- required: [inventoryRemap]
|
|
28
|
+
not:
|
|
29
|
+
anyOf:
|
|
30
|
+
- required: [properties]
|
|
31
|
+
- required: [actorAction]
|
|
32
|
+
allOf:
|
|
33
|
+
- $ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/scopeFilters
|
|
34
|
+
- $ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/scopeNeedsOfClass
|
|
35
|
+
properties:
|
|
36
|
+
target:
|
|
37
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/stringOrList
|
|
38
|
+
allAssetsOfClass:
|
|
39
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/nonEmptyString
|
|
40
|
+
applyToSubclasses: { type: boolean, default: false }
|
|
41
|
+
applyToSpawnedActors: { type: boolean, default: false }
|
|
42
|
+
actorAction:
|
|
43
|
+
type: string
|
|
44
|
+
enum: [destroy, dismantle]
|
|
45
|
+
inventoryRemap:
|
|
46
|
+
type: array
|
|
47
|
+
minItems: 1
|
|
48
|
+
maxItems: 256
|
|
49
|
+
items:
|
|
50
|
+
type: object
|
|
51
|
+
required: [from, to]
|
|
52
|
+
properties:
|
|
53
|
+
from:
|
|
54
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/nonEmptyString
|
|
55
|
+
to:
|
|
56
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/nonEmptyString
|
|
57
|
+
multiplier: { type: integer, minimum: 1, maximum: 2147483647, default: 1 }
|
|
58
|
+
additionalProperties: false
|
|
59
|
+
actorSelector:
|
|
60
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/actor-selector.schema.yml
|
|
61
|
+
deferOneGameTick: { type: boolean, default: false }
|
|
62
|
+
properties:
|
|
63
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/properties
|
|
64
|
+
if:
|
|
65
|
+
anyOf:
|
|
66
|
+
- required: [actorSelector]
|
|
67
|
+
- required: [actorAction]
|
|
68
|
+
- required: [inventoryRemap]
|
|
69
|
+
then:
|
|
70
|
+
required: [target, applyToSpawnedActors]
|
|
71
|
+
properties:
|
|
72
|
+
applyToSpawnedActors: { const: true }
|
|
73
|
+
not:
|
|
74
|
+
anyOf:
|
|
75
|
+
- required: [allAssetsOfClass]
|
|
76
|
+
- required: [ofClass]
|
|
77
|
+
- required: [matchTag]
|
|
78
|
+
- required: [matchName]
|
|
79
|
+
- required: [classType]
|
|
80
|
+
- required: [excludeClasses]
|
|
81
|
+
- required: [where]
|
|
82
|
+
- required: [producedIn]
|
|
83
|
+
- required: [ingredient]
|
|
84
|
+
- required: [product]
|
|
85
|
+
- required: [tagProperty]
|
|
86
|
+
- required: [matchAssets]
|
|
87
|
+
anyOf:
|
|
88
|
+
- required: [target]
|
|
89
|
+
- required: [allAssetsOfClass]
|
|
90
|
+
- $ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/hasScopeFilter
|
|
91
|
+
unevaluatedProperties: false
|
|
92
|
+
unevaluatedProperties: false
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
$schema: https://json-schema.org/draft/2020-12/schema
|
|
2
|
+
$id: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/class.schema.yml
|
|
3
|
+
x-kdf-type: class
|
|
4
|
+
title: KDataForge generic classes
|
|
5
|
+
allOf:
|
|
6
|
+
- $ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/documentBase
|
|
7
|
+
- type: object
|
|
8
|
+
required: [classes]
|
|
9
|
+
properties:
|
|
10
|
+
type: { const: class }
|
|
11
|
+
classes:
|
|
12
|
+
type: array
|
|
13
|
+
minItems: 1
|
|
14
|
+
items:
|
|
15
|
+
type: object
|
|
16
|
+
additionalProperties: false
|
|
17
|
+
required: [id, parent]
|
|
18
|
+
properties:
|
|
19
|
+
id:
|
|
20
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/token
|
|
21
|
+
parent:
|
|
22
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/nonEmptyString
|
|
23
|
+
registerAs:
|
|
24
|
+
enum: [recipe, schematic, research]
|
|
25
|
+
properties:
|
|
26
|
+
$ref: https://raw.githubusercontent.com/Satisfactory-KMods/KDataForge-Linter/main/src/kdataforge_linter/schemas/common.schema.yml#/$defs/properties
|
|
27
|
+
unevaluatedProperties: false
|