|
1 | | -## @supermodeltools/sdk@0.3.8 |
| 1 | +# Supermodel TypeScript SDK |
2 | 2 |
|
3 | | -This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments: |
| 3 | +[](https://www.npmjs.com/package/@supermodeltools/sdk) |
| 4 | +[](https://www.typescriptlang.org/) |
4 | 5 |
|
5 | | -Environment |
6 | | -* Node.js |
7 | | -* Webpack |
8 | | -* Browserify |
| 6 | +TypeScript client for the [Supermodel API](https://docs.supermodeltools.com) - code graph generation and static analysis. |
9 | 7 |
|
10 | | -Language level |
11 | | -* ES5 - you must have a Promises/A+ library installed |
12 | | -* ES6 |
| 8 | +## Install |
13 | 9 |
|
14 | | -Module system |
15 | | -* CommonJS |
16 | | -* ES6 module system |
| 10 | +```bash |
| 11 | +npm install @supermodeltools/sdk |
| 12 | +``` |
17 | 13 |
|
18 | | -It can be used in both TypeScript and JavaScript. In TypeScript, the definition will be automatically resolved via `package.json`. ([Reference](https://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html)) |
| 14 | +## Quick Start |
19 | 15 |
|
20 | | -### Building |
| 16 | +Get your API key from the [Supermodel Dashboard](https://supermodeltools.com/dashboard) and set it as `SUPERMODEL_API_KEY`. |
21 | 17 |
|
22 | | -To build and compile the typescript sources to javascript use: |
23 | | -``` |
24 | | -npm install |
25 | | -npm run build |
26 | | -``` |
| 18 | +```typescript |
| 19 | +import { Configuration, DefaultApi } from '@supermodeltools/sdk'; |
| 20 | +import { readFile } from 'node:fs/promises'; |
27 | 21 |
|
28 | | -### Publishing |
| 22 | +const config = new Configuration({ |
| 23 | + basePath: 'https://api.supermodeltools.com', |
| 24 | + apiKey: process.env.SUPERMODEL_API_KEY, |
| 25 | +}); |
29 | 26 |
|
30 | | -First build the package then run `npm publish` |
| 27 | +const api = new DefaultApi(config); |
31 | 28 |
|
32 | | -### Consuming |
| 29 | +// Create a ZIP of your repo: git archive -o /tmp/repo.zip HEAD |
| 30 | +const file = new Blob([await readFile('/tmp/repo.zip')], { type: 'application/zip' }); |
33 | 31 |
|
34 | | -navigate to the folder of your consuming project and run one of the following commands. |
| 32 | +const result = await api.generateSupermodelGraph({ |
| 33 | + idempotencyKey: 'my-repo:supermodel:abc123', |
| 34 | + file, |
| 35 | +}); |
35 | 36 |
|
36 | | -_published:_ |
37 | | - |
38 | | -``` |
39 | | -npm install @supermodeltools/[email protected] --save |
| 37 | +console.log(result.graph.nodes.length, 'nodes'); |
40 | 38 | ``` |
41 | 39 |
|
42 | | -_unPublished (not recommended):_ |
| 40 | +## Methods |
43 | 41 |
|
44 | | -``` |
45 | | -npm install PATH_TO_GENERATED_PACKAGE --save |
46 | | -``` |
| 42 | +| Method | Description | |
| 43 | +|--------|-------------| |
| 44 | +| `generateDependencyGraph` | File-level dependency graph | |
| 45 | +| `generateCallGraph` | Function-level call graph | |
| 46 | +| `generateDomainGraph` | Domain model classification | |
| 47 | +| `generateParseGraph` | AST parse tree relationships | |
| 48 | +| `generateSupermodelGraph` | Full Supermodel IR bundle | |
| 49 | + |
| 50 | +All methods require `idempotencyKey` (string) and `file` (Blob) parameters. |
| 51 | + |
| 52 | +## Links |
| 53 | + |
| 54 | +- [API Documentation](https://docs.supermodeltools.com) |
| 55 | +- [OpenAPI Spec](https://www.npmjs.com/package/@supermodeltools/openapi-spec) |
0 commit comments