Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci

- name: Typecheck
run: npm run typecheck

- name: Build
run: npm run build

71 changes: 40 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
## @supermodeltools/[email protected]
# Supermodel TypeScript SDK

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:
[![npm](https://img.shields.io/npm/v/@supermodeltools/sdk)](https://www.npmjs.com/package/@supermodeltools/sdk)
[![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue)](https://www.typescriptlang.org/)

Environment
* Node.js
* Webpack
* Browserify
TypeScript client for the [Supermodel API](https://docs.supermodeltools.com) - code graph generation and static analysis.

Language level
* ES5 - you must have a Promises/A+ library installed
* ES6
## Install

Module system
* CommonJS
* ES6 module system
```bash
npm install @supermodeltools/sdk
```

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))
## Quick Start

### Building
Get your API key from the [Supermodel Dashboard](https://supermodeltools.com/dashboard) and set it as `SUPERMODEL_API_KEY`.

To build and compile the typescript sources to javascript use:
```
npm install
npm run build
```
```typescript
import { Configuration, DefaultApi } from '@supermodeltools/sdk';
import { readFile } from 'node:fs/promises';

### Publishing
const config = new Configuration({
basePath: 'https://api.supermodeltools.com',
apiKey: process.env.SUPERMODEL_API_KEY,
});

First build the package then run `npm publish`
const api = new DefaultApi(config);

### Consuming
// Create a ZIP of your repo: git archive -o /tmp/repo.zip HEAD
const file = new Blob([await readFile('/tmp/repo.zip')], { type: 'application/zip' });

navigate to the folder of your consuming project and run one of the following commands.
const result = await api.generateSupermodelGraph({
idempotencyKey: 'my-repo:supermodel:abc123',
file,
});

_published:_

```
npm install @supermodeltools/[email protected] --save
console.log(result.graph.nodes.length, 'nodes');
```

_unPublished (not recommended):_
## Methods

```
npm install PATH_TO_GENERATED_PACKAGE --save
```
| Method | Description |
|--------|-------------|
| `generateDependencyGraph` | File-level dependency graph |
| `generateCallGraph` | Function-level call graph |
| `generateDomainGraph` | Domain model classification |
| `generateParseGraph` | AST parse tree relationships |
| `generateSupermodelGraph` | Full Supermodel IR bundle |

All methods require `idempotencyKey` (string) and `file` (Blob) parameters.

## Links

- [API Documentation](https://docs.supermodeltools.com)
- [OpenAPI Spec](https://www.npmjs.com/package/@supermodeltools/openapi-spec)
25 changes: 21 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
{
"name": "@supermodeltools/sdk",
"version": "0.3.8",
"description": "OpenAPI client for @supermodeltools/sdk",
"author": "OpenAPI-Generator",
"description": "TypeScript SDK for the Supermodel API - code graph generation and analysis",
"author": "Supermodel <[email protected]>",
"license": "UNLICENSED",
"repository": {
"type": "git",
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
"url": "git+https://github.com/supermodeltools/typescript-sdk.git"
},
"homepage": "https://docs.supermodeltools.com",
"bugs": {
"url": "https://github.com/supermodeltools/typescript-sdk/issues"
},
"keywords": [
"supermodel",
"sdk",
"api-client",
"code-graph",
"static-analysis",
"typescript"
],
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"module": "./dist/esm/index.js",
"files": [
"dist"
],
"sideEffects": false,
"scripts": {
"build": "tsc && tsc -p tsconfig.esm.json",
"prepare": "npm run build"
"prepare": "npm run build",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"typescript": "^4.0 || ^5.0"
Expand Down