@power-plant/schema 0.0.32 → 0.0.33
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/codegen.d.mts +1 -1
- package/dist/index.cjs +5 -106
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +6 -107
- package/dist/{types-CjF4wIDK.d.mts → types-CyvYSCHO.d.mts} +2 -2
- package/dist/types-CyvYSCHO.d.mts.map +1 -0
- package/dist/valibot.d.mts +1 -1
- package/dist/zod.d.mts +1 -1
- package/package.json +4 -4
- package/dist/types-CjF4wIDK.d.mts.map +0 -1
package/dist/codegen.d.mts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -18,10 +18,10 @@ let _stryke_resolve_constants = require("@stryke/resolve/constants");
|
|
|
18
18
|
let _stryke_resolve_load = require("@stryke/resolve/load");
|
|
19
19
|
let _stryke_string_format_list = require("@stryke/string-format/list");
|
|
20
20
|
let _stryke_zod = require("@stryke/zod");
|
|
21
|
-
|
|
21
|
+
require("@typescript/vfs");
|
|
22
22
|
let _valibot_to_json_schema = require("@valibot/to-json-schema");
|
|
23
|
-
let node_path = require("node:path");
|
|
24
23
|
let ts_json_schema_generator_dist_factory_generator_js = require("ts-json-schema-generator/dist/factory/generator.js");
|
|
24
|
+
let ts_json_schema_generator_dist_src_Config_js = require("ts-json-schema-generator/dist/src/Config.js");
|
|
25
25
|
let typescript = require("typescript");
|
|
26
26
|
typescript = require_rolldown_runtime.__toESM(typescript, 1);
|
|
27
27
|
|
|
@@ -130,104 +130,7 @@ function assertSchemasDoNotContradict(base, override, label = "schema") {
|
|
|
130
130
|
//#endregion
|
|
131
131
|
//#region src/extract.ts
|
|
132
132
|
const SCHEMA_BUNDLE_BASE_URI = "https://power-plant.invalid/";
|
|
133
|
-
|
|
134
|
-
noEmit: true,
|
|
135
|
-
emitDecoratorMetadata: true,
|
|
136
|
-
experimentalDecorators: true,
|
|
137
|
-
target: typescript.default.ScriptTarget.ES2022,
|
|
138
|
-
module: typescript.default.ModuleKind.ESNext,
|
|
139
|
-
strictNullChecks: false,
|
|
140
|
-
skipLibCheck: true,
|
|
141
|
-
skipDefaultLibCheck: true,
|
|
142
|
-
esModuleInterop: true
|
|
143
|
-
};
|
|
144
|
-
function readFileAsString(fs, fileName) {
|
|
145
|
-
if (!fs.readFileSync) return;
|
|
146
|
-
try {
|
|
147
|
-
const content = fs.readFileSync(fileName, "utf8");
|
|
148
|
-
return typeof content === "string" ? content : void 0;
|
|
149
|
-
} catch {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
function fileExistsOnFs(fs, fileName) {
|
|
154
|
-
if (fs.existsSync) try {
|
|
155
|
-
return fs.existsSync(fileName);
|
|
156
|
-
} catch {
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
if (fs.statSync) try {
|
|
160
|
-
fs.statSync(fileName);
|
|
161
|
-
return true;
|
|
162
|
-
} catch {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
return readFileAsString(fs, fileName) !== void 0;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Prefers `options.fs` for System I/O so virtual storage-backed files resolve
|
|
169
|
-
* through createFSBackedSystem instead of only the real disk.
|
|
170
|
-
*/
|
|
171
|
-
function bindFileSystemToSystem(system, fs) {
|
|
172
|
-
const baseFileExists = system.fileExists.bind(system);
|
|
173
|
-
const baseReadFile = system.readFile.bind(system);
|
|
174
|
-
const baseDirectoryExists = system.directoryExists.bind(system);
|
|
175
|
-
const baseRealpath = system.realpath?.bind(system);
|
|
176
|
-
system.fileExists = (fileName) => fileExistsOnFs(fs, fileName) || baseFileExists(fileName);
|
|
177
|
-
system.readFile = (fileName) => {
|
|
178
|
-
if (fileExistsOnFs(fs, fileName)) {
|
|
179
|
-
const content = readFileAsString(fs, fileName);
|
|
180
|
-
if (content !== void 0) return content;
|
|
181
|
-
}
|
|
182
|
-
return baseReadFile(fileName);
|
|
183
|
-
};
|
|
184
|
-
system.directoryExists = (directory) => {
|
|
185
|
-
try {
|
|
186
|
-
if (fs.statSync) {
|
|
187
|
-
if (fs.statSync(directory)?.isDirectory?.()) return true;
|
|
188
|
-
} else if (fs.existsSync?.(directory)) return true;
|
|
189
|
-
} catch {}
|
|
190
|
-
return baseDirectoryExists(directory);
|
|
191
|
-
};
|
|
192
|
-
if (system.realpath && fs.realpathSync) system.realpath = (path) => {
|
|
193
|
-
try {
|
|
194
|
-
return String(fs.realpathSync(path));
|
|
195
|
-
} catch {
|
|
196
|
-
return baseRealpath?.(path) ?? path;
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
function resolveCompilerOptions(system, tsconfig, fs) {
|
|
201
|
-
if (!tsconfig) return { ...DEFAULT_TS_COMPILER_OPTIONS };
|
|
202
|
-
const raw = (fs ? readFileAsString(fs, tsconfig) : void 0) ?? typescript.default.sys.readFile(tsconfig);
|
|
203
|
-
if (!raw) return { ...DEFAULT_TS_COMPILER_OPTIONS };
|
|
204
|
-
const parsed = typescript.default.parseConfigFileTextToJson(tsconfig, raw);
|
|
205
|
-
if (!parsed.config) return { ...DEFAULT_TS_COMPILER_OPTIONS };
|
|
206
|
-
const options = {
|
|
207
|
-
...typescript.default.parseJsonConfigFileContent(parsed.config, system, (0, node_path.dirname)(tsconfig), {}, tsconfig).options,
|
|
208
|
-
noEmit: true
|
|
209
|
-
};
|
|
210
|
-
delete options.out;
|
|
211
|
-
delete options.outDir;
|
|
212
|
-
delete options.outFile;
|
|
213
|
-
delete options.declaration;
|
|
214
|
-
delete options.declarationDir;
|
|
215
|
-
delete options.declarationMap;
|
|
216
|
-
return options;
|
|
217
|
-
}
|
|
218
|
-
function createProgramFromFileSystem(file, options) {
|
|
219
|
-
const projectRoot = options.tsconfig ? (0, _stryke_path_find.findFilePath)(options.tsconfig) : options.cwd ? options.cwd : (0, _stryke_path_find.findFilePath)(file);
|
|
220
|
-
const createHost = _typescript_vfs.createVirtualCompilerHost;
|
|
221
|
-
const system = (0, _typescript_vfs.createFSBackedSystem)(/* @__PURE__ */ new Map(), projectRoot, typescript.default);
|
|
222
|
-
if (options.fs) bindFileSystemToSystem(system, options.fs);
|
|
223
|
-
const compilerOptions = resolveCompilerOptions(system, options.tsconfig, options.fs);
|
|
224
|
-
const { compilerHost } = createHost(system, compilerOptions, typescript.default);
|
|
225
|
-
return typescript.default.createProgram({
|
|
226
|
-
rootNames: [file],
|
|
227
|
-
options: compilerOptions,
|
|
228
|
-
host: compilerHost
|
|
229
|
-
});
|
|
230
|
-
}
|
|
133
|
+
typescript.default.ScriptTarget.ES2022, typescript.default.ModuleKind.ESNext;
|
|
231
134
|
function isWrappedSchemaConfig(input) {
|
|
232
135
|
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(input) || !("schema" in input)) return false;
|
|
233
136
|
if ("hash" in input || "variant" in input || "source" in input) return false;
|
|
@@ -566,21 +469,17 @@ async function extractTSType(input, options = {}) {
|
|
|
566
469
|
const tsconfig = options.tsconfig ? (0, _stryke_path_append.appendPath)(options.tsconfig, options.cwd || process.cwd()) : (0, _stryke_path_join.joinPaths)(options.cwd || process.cwd(), "tsconfig.json");
|
|
567
470
|
try {
|
|
568
471
|
const generatorConfig = {
|
|
472
|
+
...ts_json_schema_generator_dist_src_Config_js.DEFAULT_CONFIG,
|
|
569
473
|
path: filePath,
|
|
570
474
|
type: exportName,
|
|
571
475
|
expose: "all",
|
|
572
476
|
jsDoc: "extended",
|
|
573
477
|
markdownDescription: true,
|
|
574
478
|
fullDescription: true,
|
|
575
|
-
skipTypeCheck: false,
|
|
576
|
-
tsProgram: createProgramFromFileSystem(filePath, {
|
|
577
|
-
...options,
|
|
578
|
-
tsconfig
|
|
579
|
-
}),
|
|
580
479
|
...options,
|
|
581
480
|
tsconfig
|
|
582
481
|
};
|
|
583
|
-
|
|
482
|
+
console.log(`Generating JSON schema for "${filePath}" using the type "${exportName}" with the following configuration: ${JSON.stringify(generatorConfig, null, 2)}`);
|
|
584
483
|
return (0, ts_json_schema_generator_dist_factory_generator_js.createGenerator)(generatorConfig).createSchema(exportName);
|
|
585
484
|
} catch (error) {
|
|
586
485
|
throw new Error(`Failed to generate a JSON schema for "${fileReference.file}"${resolvedPath && resolvedPath !== fileReference.file ? ` (resolved: ${resolvedPath})` : ""} using the type "${exportName}". Error: ${error.message}`);
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/compatibility.ts","../src/extract.ts","../src/helpers.ts","../src/metadata.ts","../src/type-checks.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;iBAwGgB,yBACd,MAAM,YACN,UAAU,YACV;;;;;;;;;iBAqHc,6BACd,MAAM,YACN,UAAU,YACV;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/compatibility.ts","../src/extract.ts","../src/helpers.ts","../src/metadata.ts","../src/type-checks.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;iBAwGgB,yBACd,MAAM,YACN,UAAU,YACV;;;;;;;;;iBAqHc,6BACd,MAAM,YACN,UAAU,YACV;;;;;;;;;iBCyOc,iBAAiB,QAAQ,aAAa;;;;iBAgMtC,YACd,SAAS,qBACT,OAAO;;;;;;;iBAgDO,kBAAkB,kBAAkB;;;;;;;;iBAoCpC,uBACd,OAAO,qBACN;;;;;;;iBA0Ba,eAAe,OAAO,eAAe;;;;;;;;;iBAsB/B,cACpB,OAAO,oBACP,UAAU,sBACT,QAAQ;;;;;;;;;iBAmCK,cACd,SAAS,qBACT,OAAO,qBACN;;;;;;;;iBA6CmB,cACpB,OAAO,oBACP,UAAS,wBAAwB,SAAS,qBACzC,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8FW,wBAAwB,aAC5C,OAAO,cACP,UAAS,2BAA2B,SACnC,QAAQ,wBAAwB;;;;;;;;;;;;;;;;;;;;;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Ub,mBAAmB,iBAAiB,SAAS;;;;;;;iBAiB7C,eACd,iBACC,SAAS,eAAe"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as SchemaSourceVariant, A as JsonSchemaNumberFormat, B as JsonSchemaString, C as JsonSchemaMap, D as JsonSchemaNull, E as JsonSchemaNever, F as JsonSchemaRecord, G as JsonSchemaUnion, H as JsonSchemaTuple, I as JsonSchemaRecordPropertyNames, J as SchemaConfigVariant, K as JsonSchemaUnknown, L as JsonSchemaRef, M as JsonSchemaOf, N as JsonSchemaPrimitiveType, O as JsonSchemaNullable, P as JsonSchemaPrimitiveUnion, Q as SchemaSourceConfig, R as JsonSchemaSchemaSource, S as JsonSchemaLogicKeywords, T as JsonSchemaNativeEnum, U as JsonSchemaType, V as JsonSchemaStringFormat, W as JsonSchemaUndefined, X as SchemaEnvelopeOf, Y as SchemaEnvelope, Z as SchemaSource, _ as JsonSchemaInteger, a as JsonSchema, at as ValibotSchema, b as JsonSchemaLike, c as JsonSchemaAnyOf, ct as JSON_SCHEMA_METADATA_KEYS, d as JsonSchemaBoolean, dt as JsonSchemaTypeNames, et as SpecOf, f as JsonSchemaConditionalKeywords, ft as SCHEMA_ARRAY_CONCAT_KEYWORDS, g as JsonSchemaEnum, h as JsonSchemaDecimalFormat, i as InferExtractOptions, it as UntypedSchemaSource, j as JsonSchemaObject, k as JsonSchemaNumber, l as JsonSchemaArray, lt as JSON_SCHEMA_PRIMITIVE_TYPES, m as JsonSchemaDecimal, mt as SCHEMA_SINGLE_KEYWORDS, n as BaseSchemaSource, nt as UntypedConfigObject, o as JsonSchemaAllOf, ot as ValibotSchemaSource, p as JsonSchemaDate, pt as SCHEMA_RECORD_KEYWORDS, q as SchemaConfig, r as ExtractedSchemaEnvelope, rt as UntypedSchema, s as JsonSchemaAny, st as Zod3SchemaSource, t as BaseExtractOptions, tt as StandardSchemaSchemaSource, u as JsonSchemaBigint, ut as JSON_SCHEMA_TYPES, v as JsonSchemaIntegerFormat, w as JsonSchemaMetadataKeywords, x as JsonSchemaLiteral, y as JsonSchemaKeywords, z as JsonSchemaSet } from "./types-
|
|
1
|
+
import { $ as SchemaSourceVariant, A as JsonSchemaNumberFormat, B as JsonSchemaString, C as JsonSchemaMap, D as JsonSchemaNull, E as JsonSchemaNever, F as JsonSchemaRecord, G as JsonSchemaUnion, H as JsonSchemaTuple, I as JsonSchemaRecordPropertyNames, J as SchemaConfigVariant, K as JsonSchemaUnknown, L as JsonSchemaRef, M as JsonSchemaOf, N as JsonSchemaPrimitiveType, O as JsonSchemaNullable, P as JsonSchemaPrimitiveUnion, Q as SchemaSourceConfig, R as JsonSchemaSchemaSource, S as JsonSchemaLogicKeywords, T as JsonSchemaNativeEnum, U as JsonSchemaType, V as JsonSchemaStringFormat, W as JsonSchemaUndefined, X as SchemaEnvelopeOf, Y as SchemaEnvelope, Z as SchemaSource, _ as JsonSchemaInteger, a as JsonSchema, at as ValibotSchema, b as JsonSchemaLike, c as JsonSchemaAnyOf, ct as JSON_SCHEMA_METADATA_KEYS, d as JsonSchemaBoolean, dt as JsonSchemaTypeNames, et as SpecOf, f as JsonSchemaConditionalKeywords, ft as SCHEMA_ARRAY_CONCAT_KEYWORDS, g as JsonSchemaEnum, h as JsonSchemaDecimalFormat, i as InferExtractOptions, it as UntypedSchemaSource, j as JsonSchemaObject, k as JsonSchemaNumber, l as JsonSchemaArray, lt as JSON_SCHEMA_PRIMITIVE_TYPES, m as JsonSchemaDecimal, mt as SCHEMA_SINGLE_KEYWORDS, n as BaseSchemaSource, nt as UntypedConfigObject, o as JsonSchemaAllOf, ot as ValibotSchemaSource, p as JsonSchemaDate, pt as SCHEMA_RECORD_KEYWORDS, q as SchemaConfig, r as ExtractedSchemaEnvelope, rt as UntypedSchema, s as JsonSchemaAny, st as Zod3SchemaSource, t as BaseExtractOptions, tt as StandardSchemaSchemaSource, u as JsonSchemaBigint, ut as JSON_SCHEMA_TYPES, v as JsonSchemaIntegerFormat, w as JsonSchemaMetadataKeywords, x as JsonSchemaLiteral, y as JsonSchemaKeywords, z as JsonSchemaSet } from "./types-CyvYSCHO.mjs";
|
|
2
2
|
import { n as createStoragePromises, r as normalizeKey, t as mapStorageToFileSystem } from "./index-C7q4X7Bo.mjs";
|
|
3
3
|
import { BaseSchema } from "valibot";
|
|
4
4
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
package/dist/index.mjs
CHANGED
|
@@ -10,16 +10,16 @@ import { murmurhash } from "@stryke/hash";
|
|
|
10
10
|
import { deepClone } from "@stryke/helpers/deep-clone";
|
|
11
11
|
import { isStandardJsonSchema } from "@stryke/json";
|
|
12
12
|
import { appendPath } from "@stryke/path/append";
|
|
13
|
-
import { findFileExtensionSafe
|
|
13
|
+
import { findFileExtensionSafe } from "@stryke/path/find";
|
|
14
14
|
import { joinPaths } from "@stryke/path/join";
|
|
15
15
|
import { VALID_OBJECT_SOURCE_EXTENSIONS } from "@stryke/resolve/constants";
|
|
16
16
|
import { loadSafe } from "@stryke/resolve/load";
|
|
17
17
|
import { list } from "@stryke/string-format/list";
|
|
18
18
|
import { extractJsonSchema as extractJsonSchema$1, isZod3Type } from "@stryke/zod";
|
|
19
|
-
import
|
|
19
|
+
import "@typescript/vfs";
|
|
20
20
|
import { toJsonSchema } from "@valibot/to-json-schema";
|
|
21
|
-
import { dirname } from "node:path";
|
|
22
21
|
import { createGenerator } from "ts-json-schema-generator/dist/factory/generator.js";
|
|
22
|
+
import { DEFAULT_CONFIG } from "ts-json-schema-generator/dist/src/Config.js";
|
|
23
23
|
import ts from "typescript";
|
|
24
24
|
|
|
25
25
|
//#region src/compatibility.ts
|
|
@@ -127,104 +127,7 @@ function assertSchemasDoNotContradict(base, override, label = "schema") {
|
|
|
127
127
|
//#endregion
|
|
128
128
|
//#region src/extract.ts
|
|
129
129
|
const SCHEMA_BUNDLE_BASE_URI = "https://power-plant.invalid/";
|
|
130
|
-
|
|
131
|
-
noEmit: true,
|
|
132
|
-
emitDecoratorMetadata: true,
|
|
133
|
-
experimentalDecorators: true,
|
|
134
|
-
target: ts.ScriptTarget.ES2022,
|
|
135
|
-
module: ts.ModuleKind.ESNext,
|
|
136
|
-
strictNullChecks: false,
|
|
137
|
-
skipLibCheck: true,
|
|
138
|
-
skipDefaultLibCheck: true,
|
|
139
|
-
esModuleInterop: true
|
|
140
|
-
};
|
|
141
|
-
function readFileAsString(fs, fileName) {
|
|
142
|
-
if (!fs.readFileSync) return;
|
|
143
|
-
try {
|
|
144
|
-
const content = fs.readFileSync(fileName, "utf8");
|
|
145
|
-
return typeof content === "string" ? content : void 0;
|
|
146
|
-
} catch {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function fileExistsOnFs(fs, fileName) {
|
|
151
|
-
if (fs.existsSync) try {
|
|
152
|
-
return fs.existsSync(fileName);
|
|
153
|
-
} catch {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
if (fs.statSync) try {
|
|
157
|
-
fs.statSync(fileName);
|
|
158
|
-
return true;
|
|
159
|
-
} catch {
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
return readFileAsString(fs, fileName) !== void 0;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Prefers `options.fs` for System I/O so virtual storage-backed files resolve
|
|
166
|
-
* through createFSBackedSystem instead of only the real disk.
|
|
167
|
-
*/
|
|
168
|
-
function bindFileSystemToSystem(system, fs) {
|
|
169
|
-
const baseFileExists = system.fileExists.bind(system);
|
|
170
|
-
const baseReadFile = system.readFile.bind(system);
|
|
171
|
-
const baseDirectoryExists = system.directoryExists.bind(system);
|
|
172
|
-
const baseRealpath = system.realpath?.bind(system);
|
|
173
|
-
system.fileExists = (fileName) => fileExistsOnFs(fs, fileName) || baseFileExists(fileName);
|
|
174
|
-
system.readFile = (fileName) => {
|
|
175
|
-
if (fileExistsOnFs(fs, fileName)) {
|
|
176
|
-
const content = readFileAsString(fs, fileName);
|
|
177
|
-
if (content !== void 0) return content;
|
|
178
|
-
}
|
|
179
|
-
return baseReadFile(fileName);
|
|
180
|
-
};
|
|
181
|
-
system.directoryExists = (directory) => {
|
|
182
|
-
try {
|
|
183
|
-
if (fs.statSync) {
|
|
184
|
-
if (fs.statSync(directory)?.isDirectory?.()) return true;
|
|
185
|
-
} else if (fs.existsSync?.(directory)) return true;
|
|
186
|
-
} catch {}
|
|
187
|
-
return baseDirectoryExists(directory);
|
|
188
|
-
};
|
|
189
|
-
if (system.realpath && fs.realpathSync) system.realpath = (path) => {
|
|
190
|
-
try {
|
|
191
|
-
return String(fs.realpathSync(path));
|
|
192
|
-
} catch {
|
|
193
|
-
return baseRealpath?.(path) ?? path;
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
function resolveCompilerOptions(system, tsconfig, fs) {
|
|
198
|
-
if (!tsconfig) return { ...DEFAULT_TS_COMPILER_OPTIONS };
|
|
199
|
-
const raw = (fs ? readFileAsString(fs, tsconfig) : void 0) ?? ts.sys.readFile(tsconfig);
|
|
200
|
-
if (!raw) return { ...DEFAULT_TS_COMPILER_OPTIONS };
|
|
201
|
-
const parsed = ts.parseConfigFileTextToJson(tsconfig, raw);
|
|
202
|
-
if (!parsed.config) return { ...DEFAULT_TS_COMPILER_OPTIONS };
|
|
203
|
-
const options = {
|
|
204
|
-
...ts.parseJsonConfigFileContent(parsed.config, system, dirname(tsconfig), {}, tsconfig).options,
|
|
205
|
-
noEmit: true
|
|
206
|
-
};
|
|
207
|
-
delete options.out;
|
|
208
|
-
delete options.outDir;
|
|
209
|
-
delete options.outFile;
|
|
210
|
-
delete options.declaration;
|
|
211
|
-
delete options.declarationDir;
|
|
212
|
-
delete options.declarationMap;
|
|
213
|
-
return options;
|
|
214
|
-
}
|
|
215
|
-
function createProgramFromFileSystem(file, options) {
|
|
216
|
-
const projectRoot = options.tsconfig ? findFilePath(options.tsconfig) : options.cwd ? options.cwd : findFilePath(file);
|
|
217
|
-
const createHost = createVirtualCompilerHost;
|
|
218
|
-
const system = createFSBackedSystem(/* @__PURE__ */ new Map(), projectRoot, ts);
|
|
219
|
-
if (options.fs) bindFileSystemToSystem(system, options.fs);
|
|
220
|
-
const compilerOptions = resolveCompilerOptions(system, options.tsconfig, options.fs);
|
|
221
|
-
const { compilerHost } = createHost(system, compilerOptions, ts);
|
|
222
|
-
return ts.createProgram({
|
|
223
|
-
rootNames: [file],
|
|
224
|
-
options: compilerOptions,
|
|
225
|
-
host: compilerHost
|
|
226
|
-
});
|
|
227
|
-
}
|
|
130
|
+
ts.ScriptTarget.ES2022, ts.ModuleKind.ESNext;
|
|
228
131
|
function isWrappedSchemaConfig(input) {
|
|
229
132
|
if (!isSetObject(input) || !("schema" in input)) return false;
|
|
230
133
|
if ("hash" in input || "variant" in input || "source" in input) return false;
|
|
@@ -563,21 +466,17 @@ async function extractTSType(input, options = {}) {
|
|
|
563
466
|
const tsconfig = options.tsconfig ? appendPath(options.tsconfig, options.cwd || process.cwd()) : joinPaths(options.cwd || process.cwd(), "tsconfig.json");
|
|
564
467
|
try {
|
|
565
468
|
const generatorConfig = {
|
|
469
|
+
...DEFAULT_CONFIG,
|
|
566
470
|
path: filePath,
|
|
567
471
|
type: exportName,
|
|
568
472
|
expose: "all",
|
|
569
473
|
jsDoc: "extended",
|
|
570
474
|
markdownDescription: true,
|
|
571
475
|
fullDescription: true,
|
|
572
|
-
skipTypeCheck: false,
|
|
573
|
-
tsProgram: createProgramFromFileSystem(filePath, {
|
|
574
|
-
...options,
|
|
575
|
-
tsconfig
|
|
576
|
-
}),
|
|
577
476
|
...options,
|
|
578
477
|
tsconfig
|
|
579
478
|
};
|
|
580
|
-
|
|
479
|
+
console.log(`Generating JSON schema for "${filePath}" using the type "${exportName}" with the following configuration: ${JSON.stringify(generatorConfig, null, 2)}`);
|
|
581
480
|
return createGenerator(generatorConfig).createSchema(exportName);
|
|
582
481
|
} catch (error) {
|
|
583
482
|
throw new Error(`Failed to generate a JSON schema for "${fileReference.file}"${resolvedPath && resolvedPath !== fileReference.file ? ` (resolved: ${resolvedPath})` : ""} using the type "${exportName}". Error: ${error.message}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Config } from "ts-json-schema-generator/dist/src/Config.js";
|
|
1
2
|
import { BaseIssue, BaseSchema } from "valibot";
|
|
2
3
|
import { StandardJSONSchemaV1 } from "@standard-schema/spec";
|
|
3
4
|
import { InferLoadOptions, LoadReference } from "@stryke/resolve/types";
|
|
4
|
-
import { Config } from "ts-json-schema-generator/dist/src/Config.js";
|
|
5
5
|
import { Storage } from "unstorage";
|
|
6
6
|
import { InputObject, Schema } from "untyped";
|
|
7
7
|
import * as z3 from "zod/v3";
|
|
@@ -1347,4 +1347,4 @@ declare module "zod" {
|
|
|
1347
1347
|
}
|
|
1348
1348
|
//#endregion
|
|
1349
1349
|
export { SchemaSourceVariant as $, JsonSchemaNumberFormat as A, JsonSchemaString as B, JsonSchemaMap as C, JsonSchemaNull as D, JsonSchemaNever as E, JsonSchemaRecord as F, JsonSchemaUnion as G, JsonSchemaTuple as H, JsonSchemaRecordPropertyNames as I, SchemaConfigVariant as J, JsonSchemaUnknown as K, JsonSchemaRef as L, JsonSchemaOf as M, JsonSchemaPrimitiveType as N, JsonSchemaNullable as O, JsonSchemaPrimitiveUnion as P, SchemaSourceConfig as Q, JsonSchemaSchemaSource as R, JsonSchemaLogicKeywords as S, JsonSchemaNativeEnum as T, JsonSchemaType as U, JsonSchemaStringFormat as V, JsonSchemaUndefined as W, SchemaEnvelopeOf as X, SchemaEnvelope as Y, SchemaSource as Z, JsonSchemaInteger as _, JsonSchema as a, ValibotSchema as at, JsonSchemaLike as b, JsonSchemaAnyOf as c, JSON_SCHEMA_METADATA_KEYS as ct, JsonSchemaBoolean as d, JsonSchemaTypeNames as dt, SpecOf as et, JsonSchemaConditionalKeywords as f, SCHEMA_ARRAY_CONCAT_KEYWORDS as ft, JsonSchemaEnum as g, JsonSchemaDecimalFormat as h, InferExtractOptions as i, UntypedSchemaSource as it, JsonSchemaObject as j, JsonSchemaNumber as k, JsonSchemaArray as l, JSON_SCHEMA_PRIMITIVE_TYPES as lt, JsonSchemaDecimal as m, SCHEMA_SINGLE_KEYWORDS as mt, BaseSchemaSource as n, UntypedConfigObject as nt, JsonSchemaAllOf as o, ValibotSchemaSource as ot, JsonSchemaDate as p, SCHEMA_RECORD_KEYWORDS as pt, SchemaConfig as q, ExtractedSchemaEnvelope as r, UntypedSchema as rt, JsonSchemaAny as s, Zod3SchemaSource as st, BaseExtractOptions as t, StandardSchemaSchemaSource as tt, JsonSchemaBigint as u, JSON_SCHEMA_TYPES as ut, JsonSchemaIntegerFormat as v, JsonSchemaMetadataKeywords as w, JsonSchemaLiteral as x, JsonSchemaKeywords as y, JsonSchemaSet as z };
|
|
1350
|
-
//# sourceMappingURL=types-
|
|
1350
|
+
//# sourceMappingURL=types-CyvYSCHO.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CyvYSCHO.d.mts","names":[],"sources":["../src/constants.ts","../src/types.ts"],"mappings":""}
|
package/dist/valibot.d.mts
CHANGED
package/dist/zod.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@power-plant/schema",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.33",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A Power Plant utility package to help managing schemas.",
|
|
6
6
|
"keywords": [
|
|
@@ -142,9 +142,9 @@
|
|
|
142
142
|
"untyped": "^1.5.2"
|
|
143
143
|
},
|
|
144
144
|
"devDependencies": {
|
|
145
|
-
"@powerlines/plugin-tsdown": "^0.1.
|
|
145
|
+
"@powerlines/plugin-tsdown": "^0.1.558",
|
|
146
146
|
"@types/node": "^25.9.5",
|
|
147
|
-
"powerlines": "^0.47.
|
|
147
|
+
"powerlines": "^0.47.157",
|
|
148
148
|
"valibot": "^1.4.2",
|
|
149
149
|
"zod": "^4.4.3"
|
|
150
150
|
},
|
|
@@ -157,5 +157,5 @@
|
|
|
157
157
|
"zod": { "optional": true }
|
|
158
158
|
},
|
|
159
159
|
"publishConfig": { "access": "public" },
|
|
160
|
-
"gitHead": "
|
|
160
|
+
"gitHead": "f4be99d1455bd72e5ae31a9dc55341a637b6cb43"
|
|
161
161
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-CjF4wIDK.d.mts","names":[],"sources":["../src/constants.ts","../src/types.ts"],"mappings":""}
|