@golemcloud/golem-ts-typegen 1.0.0-dev.4 → 1.0.0-dev.6
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.mjs → golem-typegen.cjs} +8693 -277
- package/package.json +12 -38
- package/dist/bin/golem-typegen.js +0 -43
- package/dist/bin/path-normalization.js +0 -13
- package/dist/index.d.mts +0 -29
- package/dist/index.js +0 -830
- package/dist/index.mjs.map +0 -1
- package/dist/src/bin/golem-typegen.d.ts +0 -2
- package/dist/src/bin/path-normalization.d.ts +0 -2
- package/dist/src/index.d.ts +0 -25
- package/dist/tests/importedTypes.d.ts +0 -3
- package/dist/tests/metadata.test.d.ts +0 -1
- package/dist/tests/path-normalization.test.d.ts +0 -1
- package/dist/tests/setup.d.ts +0 -1
- package/dist/tests/testData.d.ts +0 -118
- package/dist/tests/util.d.ts +0 -31
package/package.json
CHANGED
|
@@ -1,41 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemcloud/golem-ts-typegen",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-dev.
|
|
4
|
+
"version": "1.0.0-dev.6",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
|
-
"types",
|
|
10
9
|
"dist"
|
|
11
10
|
],
|
|
12
|
-
"main": "dist/index.mjs",
|
|
13
|
-
"exports": {
|
|
14
|
-
".": {
|
|
15
|
-
"import": "./dist/index.mjs",
|
|
16
|
-
"types": "./dist/index.d.mts"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"typesVersions": {
|
|
20
|
-
"*": {
|
|
21
|
-
"agentic-guest": [
|
|
22
|
-
"types/exports.d.ts"
|
|
23
|
-
],
|
|
24
|
-
"golem:agent/common": [
|
|
25
|
-
"types/golem_agent_common.d.ts"
|
|
26
|
-
],
|
|
27
|
-
"golem:agent/host": [
|
|
28
|
-
"types/golem_agent_host.d.ts"
|
|
29
|
-
]
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
11
|
"bin": {
|
|
33
|
-
"golem-typegen": "./dist/
|
|
12
|
+
"golem-typegen": "./dist/golem-typegen.cjs"
|
|
34
13
|
},
|
|
35
14
|
"keywords": [],
|
|
36
|
-
"sideEffects": [
|
|
37
|
-
"src/index.ts"
|
|
38
|
-
],
|
|
39
15
|
"author": "",
|
|
40
16
|
"license": "SEE LICENSE IN LICENSE",
|
|
41
17
|
"description": "",
|
|
@@ -46,33 +22,31 @@
|
|
|
46
22
|
"@types/node": "^24.3.0",
|
|
47
23
|
"@typescript-eslint/eslint-plugin": "^8.39.0",
|
|
48
24
|
"@typescript-eslint/parser": "^8.39.0",
|
|
25
|
+
"commander": "^14.0.0",
|
|
49
26
|
"eslint": "^9.33.0",
|
|
50
27
|
"fast-check": "^4.2.0",
|
|
28
|
+
"log-symbols": "^7.0.1",
|
|
29
|
+
"picocolors": "^1.1.1",
|
|
51
30
|
"prettier": "^3.6.2",
|
|
52
31
|
"reflect-metadata": "^0.1.14",
|
|
53
32
|
"rollup": "^4.46.2",
|
|
54
33
|
"rollup-plugin-dts": "^6.2.1",
|
|
55
34
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
35
|
+
"ts-morph": "^26.0.0",
|
|
56
36
|
"typescript": "^5.8.3",
|
|
57
37
|
"typescript-eslint": "^8.39.0",
|
|
58
|
-
"vitest": "^3.2.4"
|
|
38
|
+
"vitest": "^3.2.4",
|
|
39
|
+
"@golemcloud/golem-ts-types-core": "1.0.0-dev.6"
|
|
59
40
|
},
|
|
60
41
|
"private": false,
|
|
61
|
-
"dependencies": {
|
|
62
|
-
"picocolors": "^1.1.1",
|
|
63
|
-
"commander": "^14.0.0",
|
|
64
|
-
"log-symbols": "^7.0.1",
|
|
65
|
-
"ts-morph": "^26.0.0",
|
|
66
|
-
"@golemcloud/golem-ts-types-core": "1.0.0-dev.4"
|
|
67
|
-
},
|
|
68
42
|
"repository": "https://github.com/golemcloud/golem",
|
|
69
43
|
"scripts": {
|
|
70
44
|
"lint": "eslint . --ext .ts,.tsx",
|
|
71
45
|
"lint:fix": "eslint . --ext .ts,.tsx --fix",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
46
|
+
"build": "rollup --failAfterWarnings -c",
|
|
47
|
+
"clean-test-data": "node ../../scripts/clean-test-data.mjs",
|
|
48
|
+
"generate-agent-metadata": "node ./dist/golem-typegen.cjs ./tsconfig.json --files 'tests/testData.ts' --golem-ts-sdk-import './tests/sdkPlaceholder.ts'",
|
|
49
|
+
"test": "pnpm run clean-test-data && pnpm run generate-agent-metadata && vitest run",
|
|
76
50
|
"dev": "rollup -c -w"
|
|
77
51
|
}
|
|
78
52
|
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
import { Project } from 'ts-morph';
|
|
4
|
-
import pc from 'picocolors';
|
|
5
|
-
import logSymbols from 'log-symbols';
|
|
6
|
-
import { saveAndClearInMemoryMetadata, updateMetadataFromSourceFiles } from '../index.js';
|
|
7
|
-
import { TypeMetadata } from '@golemcloud/golem-ts-types-core';
|
|
8
|
-
import { normalizeCliPath, normalizeFilePatterns } from './path-normalization.js';
|
|
9
|
-
const program = new Command();
|
|
10
|
-
program
|
|
11
|
-
.name('golem-typegen')
|
|
12
|
-
.description('Generate type metadata from TypeScript sources')
|
|
13
|
-
.argument('<tsconfig>', 'Path to tsconfig.json')
|
|
14
|
-
.option('-f, --files <patterns...>', 'File globs to include', ['src/**/*'])
|
|
15
|
-
.option('--include-class-decorators <names...>', 'Only include classes decorated with these decorators (space separated)', [])
|
|
16
|
-
.option('--include-only-public-scope', 'Include only public scope methods and constructors', true)
|
|
17
|
-
.option('--exclude-overridden-methods', 'Exclude methods that override parent class methods', true)
|
|
18
|
-
.action((tsconfig, options) => {
|
|
19
|
-
console.log(logSymbols.info, pc.cyan('Starting type metadata generation…'));
|
|
20
|
-
const normalizedTsconfig = normalizeCliPath(tsconfig);
|
|
21
|
-
const normalizedFilePatterns = normalizeFilePatterns(options.files);
|
|
22
|
-
const project = new Project({ tsConfigFilePath: normalizedTsconfig });
|
|
23
|
-
const sourceFiles = project.getSourceFiles(normalizedFilePatterns);
|
|
24
|
-
console.log(logSymbols.info, pc.blue(`Processing ${sourceFiles.length} source files…`));
|
|
25
|
-
const genConfig = {
|
|
26
|
-
sourceFiles: sourceFiles,
|
|
27
|
-
classDecorators: options.includeClassDecorators,
|
|
28
|
-
includeOnlyPublicScope: options.includeOnlyPublicScope,
|
|
29
|
-
excludeOverriddenMethods: options.excludeOverriddenMethods,
|
|
30
|
-
};
|
|
31
|
-
updateMetadataFromSourceFiles(genConfig);
|
|
32
|
-
const result = TypeMetadata.getAll();
|
|
33
|
-
if (result.size === 0) {
|
|
34
|
-
console.warn(logSymbols.warning, pc.yellow('No agent classes extracted; metadata is empty.'));
|
|
35
|
-
console.warn(logSymbols.info, pc.gray(`tsconfig: ${normalizedTsconfig}`));
|
|
36
|
-
console.warn(logSymbols.info, pc.gray(`file patterns: ${normalizedFilePatterns.join(', ')}`));
|
|
37
|
-
}
|
|
38
|
-
console.log(logSymbols.success, pc.green(`Metadata tracked for: ${Array.from(result.keys()).join(', ')}`));
|
|
39
|
-
console.log(logSymbols.info, pc.yellow('Saving metadata…'));
|
|
40
|
-
const filePath = saveAndClearInMemoryMetadata();
|
|
41
|
-
console.log(logSymbols.success, pc.green(`Metadata saved successfully in ${filePath}!`));
|
|
42
|
-
});
|
|
43
|
-
program.parse();
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
export function normalizeCliPath(inputPath, cwd = process.cwd()) {
|
|
3
|
-
if (path.isAbsolute(inputPath)) {
|
|
4
|
-
return path.normalize(inputPath);
|
|
5
|
-
}
|
|
6
|
-
return path.normalize(path.resolve(cwd, inputPath));
|
|
7
|
-
}
|
|
8
|
-
function toForwardSlashPath(inputPath) {
|
|
9
|
-
return inputPath.split(path.sep).join('/');
|
|
10
|
-
}
|
|
11
|
-
export function normalizeFilePatterns(patterns, cwd = process.cwd()) {
|
|
12
|
-
return patterns.map((pattern) => toForwardSlashPath(normalizeCliPath(pattern, cwd)));
|
|
13
|
-
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Type, Node, SourceFile } from 'ts-morph';
|
|
2
|
-
import { Type as Type$1 } from '@golemcloud/golem-ts-types-core';
|
|
3
|
-
|
|
4
|
-
declare function getTypeFromTsMorph(tsMorphType: Type, isOptional: boolean, sourceTypeNode?: Node): Type$1.Type;
|
|
5
|
-
declare function getRawTypeName(type: Type): string | undefined;
|
|
6
|
-
declare function getAliasTypeName(type: Type): string | undefined;
|
|
7
|
-
declare function getTypeOwner(type: Type, sourceTypeNode?: Node): string | undefined;
|
|
8
|
-
declare function unwrapAlias(type: Type): Type;
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* Configuration for generating class metadata.
|
|
12
|
-
* - sourceFiles: Array of ts-morph SourceFile objects to extract metadata from.
|
|
13
|
-
* - classDecorators: Array of decorator names to filter classes. If empty, all classes are included.
|
|
14
|
-
* - includeOnlyPublicScope: If true, only public constructors and methods are included
|
|
15
|
-
*/
|
|
16
|
-
type ClassMetadataGenConfig = {
|
|
17
|
-
sourceFiles: SourceFile[];
|
|
18
|
-
classDecorators: string[];
|
|
19
|
-
includeOnlyPublicScope: boolean;
|
|
20
|
-
excludeOverriddenMethods: boolean;
|
|
21
|
-
};
|
|
22
|
-
declare function generateClassMetadata(classMetadataGenConfig: ClassMetadataGenConfig): any;
|
|
23
|
-
declare function updateMetadataFromSourceFiles(classMetadataGenConfig: ClassMetadataGenConfig): void;
|
|
24
|
-
declare function saveAndClearInMemoryMetadata(): any;
|
|
25
|
-
declare function lazyLoadTypeMetadata(): void;
|
|
26
|
-
declare function loadTypeMetadataFromJsonFile(): void;
|
|
27
|
-
|
|
28
|
-
export { generateClassMetadata, getAliasTypeName, getRawTypeName, getTypeFromTsMorph, getTypeOwner, lazyLoadTypeMetadata, loadTypeMetadataFromJsonFile, saveAndClearInMemoryMetadata, unwrapAlias, updateMetadataFromSourceFiles };
|
|
29
|
-
export type { ClassMetadataGenConfig };
|