@pikku/inspector 0.12.94 → 0.12.96
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/CHANGELOG.md +29 -0
- package/dist/add/add-functions.js +19 -0
- package/dist/add/add-rpc-invocations.d.ts +17 -0
- package/dist/add/add-rpc-invocations.js +62 -5
- package/dist/add/collect-started-workflows.d.ts +26 -0
- package/dist/add/collect-started-workflows.js +72 -0
- package/dist/types.d.ts +1 -0
- package/dist/utils/filter-inspector-state.js +48 -0
- package/dist/utils/load-addon-functions-meta.d.ts +8 -0
- package/dist/utils/load-addon-functions-meta.js +47 -0
- package/dist/utils/post-process.d.ts +23 -23
- package/dist/utils/post-process.js +133 -155
- package/dist/utils/schema-generator.js +30 -3
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@ import * as ts from 'typescript';
|
|
|
2
2
|
import { createHash } from 'crypto';
|
|
3
3
|
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync, } from 'fs';
|
|
4
4
|
import { dirname, join, resolve } from 'path';
|
|
5
|
-
import {
|
|
5
|
+
import { createFormatter, createParser, DEFAULT_CONFIG, RootlessError, SchemaGenerator, } from 'ts-json-schema-generator';
|
|
6
6
|
import { register } from 'tsx/esm/api';
|
|
7
7
|
import * as z from 'zod';
|
|
8
8
|
import { findZodTransform } from './find-zod-transform.js';
|
|
@@ -184,6 +184,34 @@ export function writeDiskTSSchemas(logger, cacheDir, key, schemas, deps) {
|
|
|
184
184
|
logger.debug(`Failed to persist TS-schema cache: ${e.message}`);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
+
// The base class walks every source file again for each type it looks up by
|
|
188
|
+
// name, which was nearly all of schema generation (8.7s for 677 types on e2e).
|
|
189
|
+
class IndexedSchemaGenerator extends SchemaGenerator {
|
|
190
|
+
projectTypes;
|
|
191
|
+
allTypes;
|
|
192
|
+
findNamedNode(fullName) {
|
|
193
|
+
const typeChecker = this.program.getTypeChecker();
|
|
194
|
+
if (!this.projectTypes) {
|
|
195
|
+
this.projectTypes = new Map();
|
|
196
|
+
this.appendTypes(this.partitionFiles().projectFiles, typeChecker, this.projectTypes);
|
|
197
|
+
}
|
|
198
|
+
const projectType = this.projectTypes.get(fullName);
|
|
199
|
+
if (projectType)
|
|
200
|
+
return projectType;
|
|
201
|
+
if (!this.allTypes) {
|
|
202
|
+
this.allTypes = new Map(this.projectTypes);
|
|
203
|
+
this.appendTypes(this.partitionFiles().externalFiles, typeChecker, this.allTypes);
|
|
204
|
+
}
|
|
205
|
+
const type = this.allTypes.get(fullName);
|
|
206
|
+
if (type)
|
|
207
|
+
return type;
|
|
208
|
+
throw new RootlessError(fullName);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const createIndexedGenerator = (program, config) => {
|
|
212
|
+
const completedConfig = { ...DEFAULT_CONFIG, ...config };
|
|
213
|
+
return new IndexedSchemaGenerator(program, createParser(program, completedConfig), createFormatter(completedConfig), completedConfig);
|
|
214
|
+
};
|
|
187
215
|
function createProgramWithVirtualFile(logger, tsconfig, virtualFilePath, virtualFileContent) {
|
|
188
216
|
const configPath = resolve(tsconfig);
|
|
189
217
|
// Cache the parsed tsconfig — it doesn't change between runs
|
|
@@ -271,8 +299,7 @@ function generateTSSchemas(logger, tsconfig, customTypesContent, typesMap, funct
|
|
|
271
299
|
logger.debug(`generateTSSchemas needed for ${uncoveredSchemas.length} types: ${uncoveredSchemas.slice(0, 3).join(', ')}${uncoveredSchemas.length > 3 ? '...' : ''}`);
|
|
272
300
|
const virtualFilePath = join(dirname(resolve(tsconfig)), '__pikku_virtual_types__.ts');
|
|
273
301
|
const program = createProgramWithVirtualFile(logger, tsconfig, virtualFilePath, customTypesContent);
|
|
274
|
-
const generator =
|
|
275
|
-
tsProgram: program,
|
|
302
|
+
const generator = createIndexedGenerator(program, {
|
|
276
303
|
skipTypeCheck: true,
|
|
277
304
|
topRef: false,
|
|
278
305
|
discriminatorType: 'open-api',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/inspector",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.96",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/pikkujs/pikku.git",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"zod": "^4.4.3"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@pikku/core": "^0.12.
|
|
57
|
+
"@pikku/core": "^0.12.130"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@pikku/core": "^0.12.
|
|
60
|
+
"@pikku/core": "^0.12.130",
|
|
61
61
|
"@types/node": "^24.13.3"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|