@power-plant/schema 0.0.32 → 0.0.34

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/index.cjs CHANGED
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_rolldown_runtime = require('./rolldown-runtime-C_NdSu1c.cjs');
3
2
  const require_constants = require('./constants-B7xonHLD.cjs');
4
3
  const require_helpers = require('./helpers-sXsSapgI.cjs');
5
4
  const require_storage = require('./storage-B8aDmNpv.cjs');
@@ -18,12 +17,8 @@ let _stryke_resolve_constants = require("@stryke/resolve/constants");
18
17
  let _stryke_resolve_load = require("@stryke/resolve/load");
19
18
  let _stryke_string_format_list = require("@stryke/string-format/list");
20
19
  let _stryke_zod = require("@stryke/zod");
21
- let _typescript_vfs = require("@typescript/vfs");
22
20
  let _valibot_to_json_schema = require("@valibot/to-json-schema");
23
- let node_path = require("node:path");
24
21
  let ts_json_schema_generator_dist_factory_generator_js = require("ts-json-schema-generator/dist/factory/generator.js");
25
- let typescript = require("typescript");
26
- typescript = require_rolldown_runtime.__toESM(typescript, 1);
27
22
 
28
23
  //#region src/compatibility.ts
29
24
  const METADATA_KEYS = /* @__PURE__ */ new Set([
@@ -130,104 +125,6 @@ function assertSchemasDoNotContradict(base, override, label = "schema") {
130
125
  //#endregion
131
126
  //#region src/extract.ts
132
127
  const SCHEMA_BUNDLE_BASE_URI = "https://power-plant.invalid/";
133
- const DEFAULT_TS_COMPILER_OPTIONS = {
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
- }
231
128
  function isWrappedSchemaConfig(input) {
232
129
  if (!(0, _stryke_type_checks_is_set_object.isSetObject)(input) || !("schema" in input)) return false;
233
130
  if ("hash" in input || "variant" in input || "source" in input) return false;
@@ -563,7 +460,6 @@ async function extractTSType(input, options = {}) {
563
460
  const exportName = fileReference.export ?? "*";
564
461
  const resolvedPath = await (0, _stryke_fs_resolve.resolveSafe)(fileReference.file, { fs: options.fs });
565
462
  const filePath = resolvedPath || fileReference.file;
566
- 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
463
  try {
568
464
  const generatorConfig = {
569
465
  path: filePath,
@@ -572,15 +468,11 @@ async function extractTSType(input, options = {}) {
572
468
  jsDoc: "extended",
573
469
  markdownDescription: true,
574
470
  fullDescription: true,
575
- skipTypeCheck: false,
576
- tsProgram: createProgramFromFileSystem(filePath, {
577
- ...options,
578
- tsconfig
579
- }),
471
+ skipTypeCheck: true,
580
472
  ...options,
581
- tsconfig
473
+ 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")
582
474
  };
583
- options.logger?.debug?.(`Generating JSON schema for "${filePath}" using the type "${exportName}" with the following configuration: ${JSON.stringify(generatorConfig, null, 2)}`);
475
+ console.log(`Generating JSON schema for "${filePath}" using the type "${exportName}" with the following configuration: ${JSON.stringify(generatorConfig, null, 2)}`);
584
476
  return (0, ts_json_schema_generator_dist_factory_generator_js.createGenerator)(generatorConfig).createSchema(exportName);
585
477
  } catch (error) {
586
478
  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 +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;;;;;;;;;iBCwOc,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6FW,wBAAwB,aAC5C,OAAO,cACP,UAAS,2BAA2B,SACnC,QAA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ACzB,iBACC,SAAS,iBAAiB;;;;;;;iBAUb,mBAAmB,iBAAiB,SAAS;;;;;;;iBAiB7C,eACd,iBACC,SAAS,eAAe"}
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;;;;;;;;;iBCmCc,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuFW,wBAAwB,aAC5C,OAAO,cACP,UAAS,2BAA2B,SACnC,QAAQ,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0Ib,QAAQ,aAC5B,OAAO,aAAa,QACpB,UAAS,2BAA2B,SACnC,QAAQ,iBAAiB;;;KCt2BhB,oBAAoB;EAC9B;EACA;EACA;;;;;;;;;;;;iBAac,cAAc,OAAO,iBAAiB,aAAa;;;;;;;;;;;iBAmBnD,oBACd,OAAO,iBAAiB,aACvB;;;;;;;;;;iBAkBa,cACd,KAAK,iBAAiB,mBACrB,eAAe;;;;;;;;;;iBA6BF,kBAAkB,KAAK,iBAAiB,mBAAgB;;;;;;;;;;iBAaxD,YAAY,gBAAgB,kBAC1C,KAAK,eAAe,WAAW,SAC/B,YAAY,iCACX;;;;;;;;;;;;iBAg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iB,SAAS;;;;;;;iBA2C7C,mBAAmB,iBAAiB,SAAS;;;;;;;iBA4B7C,gBAAgB,iBAAiB,SAAS;;;;;;;iBA8B1C,mBAAmB,iBAAiB,SAAS;;;;;;;iBAyB7C,kBAAkB,iBAAiB,SAAS;;;;;;;iBA8B5C,sBACd,iBACC,SAAS;;;;;;;iBAoBI,2BACd,iBACC,SAAS;;;;;;;iBAsEI,kBAAkB,iBAAiB,SAAS;;;;;;;iBAmB5C,oBACd,iBACC,SAAS;;;;;;;iBAUI,kBAAkB,iBAAiB,SAAS;;;;;;;iBAkB5C,gBAAgB,iBAAiB,SAAS;;;;;;;iBAgB1C,iBAAiB,iBAAiB,SAAS;;;;;;;iBAqB3C,gBACd,iBACC,SAAS;;;;;;;;;;iBA0BI,aAAa,iBAAiB,SAAS;;;;;;;;;;iBAsCvC,qBAAqB,iBAAiB,SAAS;;;;;;;;;;iBAa/C,gBAAgB,iBAAiB,SAAS;;;;;;;;;;;iBAyD1C,sBAAsB,iBAAiB,SAAS;;;;;;;;;;iBAahD,gBAAgB,iBAAiB,SAAS;;;;;;;;;;;iBA0B1C,sBACd,iBACC,SAAS;;;;;;;iBAuBI,SAAS,iBAAiB,SAAS;;;;;;;iBAkBnC,WAAW,OACzB,iBACC,SAAS,iBAAiB;;;;;;;iBAUb,mBAAmB,iBAAiB,SAAS;;;;;;;iBAiB7C,eACd,iBACC,SAAS,eAAe"}
package/dist/index.mjs CHANGED
@@ -10,17 +10,14 @@ 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, findFilePath } from "@stryke/path/find";
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 { createFSBackedSystem, createVirtualCompilerHost } from "@typescript/vfs";
20
19
  import { toJsonSchema } from "@valibot/to-json-schema";
21
- import { dirname } from "node:path";
22
20
  import { createGenerator } from "ts-json-schema-generator/dist/factory/generator.js";
23
- import ts from "typescript";
24
21
 
25
22
  //#region src/compatibility.ts
26
23
  const METADATA_KEYS = /* @__PURE__ */ new Set([
@@ -127,104 +124,6 @@ function assertSchemasDoNotContradict(base, override, label = "schema") {
127
124
  //#endregion
128
125
  //#region src/extract.ts
129
126
  const SCHEMA_BUNDLE_BASE_URI = "https://power-plant.invalid/";
130
- const DEFAULT_TS_COMPILER_OPTIONS = {
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
- }
228
127
  function isWrappedSchemaConfig(input) {
229
128
  if (!isSetObject(input) || !("schema" in input)) return false;
230
129
  if ("hash" in input || "variant" in input || "source" in input) return false;
@@ -560,7 +459,6 @@ async function extractTSType(input, options = {}) {
560
459
  const exportName = fileReference.export ?? "*";
561
460
  const resolvedPath = await resolveSafe(fileReference.file, { fs: options.fs });
562
461
  const filePath = resolvedPath || fileReference.file;
563
- const tsconfig = options.tsconfig ? appendPath(options.tsconfig, options.cwd || process.cwd()) : joinPaths(options.cwd || process.cwd(), "tsconfig.json");
564
462
  try {
565
463
  const generatorConfig = {
566
464
  path: filePath,
@@ -569,15 +467,11 @@ async function extractTSType(input, options = {}) {
569
467
  jsDoc: "extended",
570
468
  markdownDescription: true,
571
469
  fullDescription: true,
572
- skipTypeCheck: false,
573
- tsProgram: createProgramFromFileSystem(filePath, {
574
- ...options,
575
- tsconfig
576
- }),
470
+ skipTypeCheck: true,
577
471
  ...options,
578
- tsconfig
472
+ tsconfig: options.tsconfig ? appendPath(options.tsconfig, options.cwd || process.cwd()) : joinPaths(options.cwd || process.cwd(), "tsconfig.json")
579
473
  };
580
- options.logger?.debug?.(`Generating JSON schema for "${filePath}" using the type "${exportName}" with the following configuration: ${JSON.stringify(generatorConfig, null, 2)}`);
474
+ console.log(`Generating JSON schema for "${filePath}" using the type "${exportName}" with the following configuration: ${JSON.stringify(generatorConfig, null, 2)}`);
581
475
  return createGenerator(generatorConfig).createSchema(exportName);
582
476
  } catch (error) {
583
477
  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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@power-plant/schema",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "private": false,
5
5
  "description": "A Power Plant utility package to help managing schemas.",
6
6
  "keywords": [
@@ -121,11 +121,11 @@
121
121
  "@standard-schema/spec": "^1.1.0",
122
122
  "@stryke/convert": "^0.7.27",
123
123
  "@stryke/date": "^0.0.8",
124
+ "@stryke/fs": "^0.33.97",
124
125
  "@stryke/hash": "^0.13.50",
125
126
  "@stryke/helpers": "^0.10.36",
126
127
  "@stryke/json": "^0.15.20",
127
128
  "@stryke/path": "^0.29.23",
128
- "@stryke/fs": "^0.33.97",
129
129
  "@stryke/resolve": "^0.0.12",
130
130
  "@stryke/string-format": "^0.17.38",
131
131
  "@stryke/type-checks": "^0.6.29",
@@ -133,7 +133,6 @@
133
133
  "@stryke/unique-id": "^0.3.108",
134
134
  "@stryke/url": "^0.4.47",
135
135
  "@stryke/zod": "^0.3.42",
136
- "@typescript/vfs": "^1.6.4",
137
136
  "@valibot/to-json-schema": "^1.7.1",
138
137
  "defu": "^6.1.7",
139
138
  "ts-json-schema-generator": "^2.9.0",
@@ -142,9 +141,9 @@
142
141
  "untyped": "^1.5.2"
143
142
  },
144
143
  "devDependencies": {
145
- "@powerlines/plugin-tsdown": "^0.1.555",
144
+ "@powerlines/plugin-tsdown": "^0.1.558",
146
145
  "@types/node": "^25.9.5",
147
- "powerlines": "^0.47.154",
146
+ "powerlines": "^0.47.157",
148
147
  "valibot": "^1.4.2",
149
148
  "zod": "^4.4.3"
150
149
  },
@@ -157,5 +156,5 @@
157
156
  "zod": { "optional": true }
158
157
  },
159
158
  "publishConfig": { "access": "public" },
160
- "gitHead": "d252bc460d285a6e2276ba5f08410ec9e37fb8fc"
159
+ "gitHead": "248ee4fb68fedca6d36ae55e0a23bdc1240d113f"
161
160
  }