@drincs/pixi-vn-json 1.13.15 → 1.13.16
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/dist/actions.cjs +2 -2
- package/dist/actions.d.cts +45 -2
- package/dist/actions.d.ts +45 -2
- package/dist/actions.mjs +2 -2
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +6 -3
- package/scripts/generate-entrance-transition-schemas.mjs +90 -0
- package/scripts/generate-schema.mjs +64 -0
- package/scripts/schema-generator.mjs +763 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Generates a JSON Schema from the PixiVNJson TypeScript interface.
|
|
4
|
+
* Schema is saved to schemas/<version>/schema.json
|
|
5
|
+
*
|
|
6
|
+
* Thin wrapper around `generateJsonSchema` (schema-generator.mjs) — see that file for the actual
|
|
7
|
+
* AST-traversal/type-checker engine. `PixiVNJson` and everything under `src/schema` is treated as
|
|
8
|
+
* "local" (expanded fully, no depth cap); external types (from `@drincs/pixi-vn`, `pixi.js`, ...)
|
|
9
|
+
* are capped at `maxDepth: 3`, which reproduces this generator's historical depth exactly (its
|
|
10
|
+
* root call used to start at depth 0 with a cap of 2 — three total object levels before
|
|
11
|
+
* collapsing; `generateJsonSchema` starts the root call at depth 1, so the equivalent cap is 3).
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
15
|
+
import { dirname, join, resolve } from "path";
|
|
16
|
+
import { fileURLToPath } from "url";
|
|
17
|
+
import { generateJsonSchema } from "./schema-generator.mjs";
|
|
18
|
+
|
|
19
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
20
|
+
const rootDir = resolve(__dirname, "..");
|
|
21
|
+
|
|
22
|
+
const pkg = JSON.parse(readFileSync(join(rootDir, "package.json"), "utf8"));
|
|
23
|
+
const version = pkg.version;
|
|
24
|
+
|
|
25
|
+
const interfaceDir = join(rootDir, "src", "schema");
|
|
26
|
+
const tsconfigPath = join(rootDir, "tsconfig.schema.json");
|
|
27
|
+
|
|
28
|
+
const { schemas, definitions } = generateJsonSchema({
|
|
29
|
+
rootFiles: [],
|
|
30
|
+
tsconfigPath,
|
|
31
|
+
interfaceDir,
|
|
32
|
+
rootTypeNames: ["PixiVNJson"],
|
|
33
|
+
maxDepth: 3,
|
|
34
|
+
includeAllLocalDeclarations: true,
|
|
35
|
+
// `StorageElementType`/`StorageObjectType` come from `@drincs/pixi-vn`, so they're external
|
|
36
|
+
// references with no local declaration to inspect — they'd otherwise fall through to the
|
|
37
|
+
// generic "external type" resolution. That's a problem specifically when they appear inside a
|
|
38
|
+
// union (e.g. `leftValue: StorageElementType | PixiVNJsonValueGet | ...`): `mergeUnion` filters
|
|
39
|
+
// out any branch with zero keys, so an empty-schema branch would silently vanish and the field
|
|
40
|
+
// would end up looking object-only instead of "primitive or object". Giving them real keys
|
|
41
|
+
// here keeps them in the union, same as the historical special-case.
|
|
42
|
+
typeNameOverrides: {
|
|
43
|
+
StorageElementType: { type: ["string", "number", "boolean", "null", "array", "object"] },
|
|
44
|
+
StorageObjectType: { type: "object" },
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const rootSchema = definitions[schemas.PixiVNJson.$ref.replace("#/definitions/", "")];
|
|
49
|
+
|
|
50
|
+
// ─── Output ───────────────────────────────────────────────────────────────────
|
|
51
|
+
|
|
52
|
+
const schema = {
|
|
53
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
54
|
+
...rootSchema,
|
|
55
|
+
definitions,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const outDir = join(rootDir, "schemas", version);
|
|
59
|
+
mkdirSync(outDir, { recursive: true });
|
|
60
|
+
const outPath = join(outDir, "schema.json");
|
|
61
|
+
writeFileSync(outPath, JSON.stringify(schema, null, 2) + "\n");
|
|
62
|
+
|
|
63
|
+
console.log(`Schema generated: ${outPath}`);
|
|
64
|
+
console.log(`Definitions: ${Object.keys(definitions).length}`);
|