@openpkg-ts/sdk 0.1.0 → 0.30.0
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/README.md +106 -81
- package/dist/index.d.ts +1378 -43
- package/dist/index.js +5686 -1793
- package/package.json +22 -22
package/README.md
CHANGED
|
@@ -1,125 +1,150 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @openpkg-ts/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Programmatic SDK for TypeScript API extraction and documentation generation.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
5
|
+
## Install
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
|
-
# npm
|
|
11
8
|
npm install @openpkg-ts/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
```typescript
|
|
14
|
+
import { listExports, getExport, extractSpec, createDocs, toMarkdown } from '@openpkg-ts/sdk';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// List all exports
|
|
17
|
+
const { exports } = await listExports({ entryFile: './src/index.ts' });
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
// Get single export details
|
|
20
|
+
const { export: spec } = await getExport({ entryFile: './src/index.ts', exportName: 'myFunc' });
|
|
21
|
+
|
|
22
|
+
// Extract full spec
|
|
23
|
+
const { spec } = await extractSpec({ entryFile: './src/index.ts' });
|
|
24
|
+
|
|
25
|
+
// Generate docs
|
|
26
|
+
const docs = createDocs(spec);
|
|
27
|
+
const markdown = docs.toMarkdown();
|
|
21
28
|
```
|
|
22
29
|
|
|
23
|
-
##
|
|
30
|
+
## Primitives
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
import { OpenPkg } from '@openpkg-ts/sdk';
|
|
32
|
+
Agent-native primitives for composable workflows:
|
|
27
33
|
|
|
28
|
-
|
|
29
|
-
resolveExternalTypes: true,
|
|
30
|
-
});
|
|
34
|
+
### listExports
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
filters: {
|
|
34
|
-
include: ['createUser', 'deleteUser'],
|
|
35
|
-
},
|
|
36
|
-
});
|
|
36
|
+
List exports from entry point with metadata.
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
```
|
|
38
|
+
```typescript
|
|
39
|
+
const { exports, errors } = await listExports({ entryFile: './src/index.ts' });
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
// Returns: { name, kind, file, line, description }[]
|
|
42
|
+
```
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
### getExport
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
import { analyzeFile } from '@openpkg-ts/sdk';
|
|
46
|
+
Get detailed spec for a single export.
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
},
|
|
48
|
+
```typescript
|
|
49
|
+
const { export: spec, types, errors } = await getExport({
|
|
50
|
+
entryFile: './src/index.ts',
|
|
51
|
+
exportName: 'createClient'
|
|
54
52
|
});
|
|
55
53
|
```
|
|
56
54
|
|
|
57
|
-
|
|
55
|
+
### extractSpec
|
|
58
56
|
|
|
59
|
-
|
|
57
|
+
Generate full OpenPkg spec (all exports + types).
|
|
60
58
|
|
|
61
|
-
|
|
59
|
+
```typescript
|
|
60
|
+
const { spec, diagnostics, verification } = await extractSpec({
|
|
61
|
+
entryFile: './src/index.ts',
|
|
62
|
+
maxTypeDepth: 4,
|
|
63
|
+
resolveExternalTypes: true,
|
|
64
|
+
only: ['use*'], // filter by pattern
|
|
65
|
+
ignore: ['*Internal'], // exclude by pattern
|
|
66
|
+
});
|
|
67
|
+
```
|
|
62
68
|
|
|
63
|
-
|
|
64
|
-
import { OpenPkg } from '@openpkg-ts/sdk';
|
|
69
|
+
### diffSpecs
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
const { spec, diagnostics } = await openpkg.analyzeFileWithDiagnostics('./src/index.ts');
|
|
71
|
+
Compare two specs for breaking changes.
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
});
|
|
73
|
+
```typescript
|
|
74
|
+
import { diffSpecs } from '@openpkg-ts/sdk';
|
|
75
|
+
|
|
76
|
+
const diff = diffSpecs(oldSpec, newSpec);
|
|
77
|
+
console.log(`Breaking: ${diff.breaking.length}`);
|
|
75
78
|
```
|
|
76
79
|
|
|
77
|
-
|
|
80
|
+
## Documentation Generation
|
|
78
81
|
|
|
79
|
-
|
|
82
|
+
### createDocs / loadSpec
|
|
80
83
|
|
|
81
|
-
|
|
84
|
+
```typescript
|
|
85
|
+
import { createDocs, loadSpec } from '@openpkg-ts/sdk';
|
|
82
86
|
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
// From file path
|
|
88
|
+
const docs = createDocs('./openpkg.json');
|
|
85
89
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
{ filters: { include: ['sum'] } },
|
|
89
|
-
);
|
|
90
|
+
// From spec object
|
|
91
|
+
const docs = loadSpec(spec);
|
|
90
92
|
```
|
|
91
93
|
|
|
92
|
-
###
|
|
94
|
+
### Render Functions
|
|
93
95
|
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
```typescript
|
|
97
|
+
// Full API reference
|
|
98
|
+
const markdown = docs.toMarkdown({ frontmatter: true, codeSignatures: true });
|
|
99
|
+
const html = docs.toHTML({ fullDocument: true, includeStyles: true });
|
|
100
|
+
const json = docs.toJSON();
|
|
97
101
|
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
const specs = await Promise.all(files.map((file) => openpkg.analyzeFile(file)));
|
|
102
|
+
// Single export
|
|
103
|
+
const markdown = docs.toMarkdown({ exportId: 'createClient' });
|
|
101
104
|
```
|
|
102
105
|
|
|
103
|
-
|
|
106
|
+
### Navigation
|
|
104
107
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
- `analyzeFile(filePath, options?)`
|
|
108
|
-
- `analyzeWithDiagnostics(code, fileName?, options?)`
|
|
109
|
-
- `analyzeFileWithDiagnostics(filePath, options?)`
|
|
110
|
-
- `analyze(code, options?)` – convenience wrapper
|
|
111
|
-
- `analyzeFile(filePath, options?)` – convenience wrapper
|
|
112
|
-
- `extractPackageSpec(entry, packageDir, source, options)` – lower-level extractor
|
|
113
|
-
- Types: `OpenPkgSpec`, `FilterOptions`, `AnalyzeOptions`, `AnalysisResult`, `Diagnostic`
|
|
108
|
+
```typescript
|
|
109
|
+
import { toFumadocsMetaJSON, toDocusaurusSidebarJS } from '@openpkg-ts/sdk';
|
|
114
110
|
|
|
115
|
-
|
|
111
|
+
const fumadocsMeta = toFumadocsMetaJSON(spec, { basePath: '/api' });
|
|
112
|
+
const docusaurusSidebar = toDocusaurusSidebarJS(spec);
|
|
113
|
+
```
|
|
116
114
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
### Search Index
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { toSearchIndex, toAlgoliaRecords } from '@openpkg-ts/sdk';
|
|
119
|
+
|
|
120
|
+
const searchIndex = toSearchIndex(spec);
|
|
121
|
+
const algoliaRecords = toAlgoliaRecords(spec, { indexName: 'api_docs' });
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Query Utilities
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import {
|
|
128
|
+
buildSignatureString,
|
|
129
|
+
formatParameters,
|
|
130
|
+
formatReturnType,
|
|
131
|
+
getProperties,
|
|
132
|
+
getMethods,
|
|
133
|
+
resolveTypeRef,
|
|
134
|
+
} from '@openpkg-ts/sdk';
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Types
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
import type {
|
|
141
|
+
OpenPkg,
|
|
142
|
+
SpecExport,
|
|
143
|
+
ExtractOptions,
|
|
144
|
+
ExtractResult,
|
|
145
|
+
DocsInstance,
|
|
146
|
+
SimplifiedSpec,
|
|
147
|
+
} from '@openpkg-ts/sdk';
|
|
123
148
|
```
|
|
124
149
|
|
|
125
150
|
## License
|