diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b9ab4b7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 + diff --git a/README.md b/README.md index 37defb1..448cef9 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,55 @@ -## @supermodeltools/sdk@0.3.8 +# 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/sdk@0.3.8 --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) diff --git a/package.json b/package.json index 5e081b0..c9a8fbf 100644 --- a/package.json +++ b/package.json @@ -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 ", + "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"