Engineering Details
Vite Build Configuration
Since UMD does not support multiple entry points, we use the BUILD_TARGET environment variable to distinguish between two builds:
bash
# ESM Build (including type declarations)
vite build
# UMD Build
BUILD_TARGET=umd vite build
# Build both formats at once
pnpm build # = vite build && BUILD_TARGET=umd vite build| Build Target | Entry | Artifact | Description |
|---|---|---|---|
| ESM | src/index.ts | dist/index.es.js + dist/index.d.ts | Terser compression enabled, drop_console |
| UMD | src/umd.ts | dist/index.umd.js | Uncompressed (for easier debugging), mounts window.GeneratorSDK |
Development Commands
bash
cd SDK
pnpm install # Install dependencies
pnpm build # Build ESM + UMD
pnpm build:esm # Build ESM only
pnpm build:umd # Build UMD only
pnpm dev # ESM watch mode
pnpm dev:umd # UMD watch mode
pnpm type-check # TypeScript type checkBackend API Mapping Table
The SDK reuses existing backend interfaces directly, with no new additions required except for the credits deduction interface.
Unified Request Format
http
POST /ai/v5/artimind/generator
uToken: {uToken}
lang: en
Content-Type: application/json
{ ... }Unified Response Format
json
{ "code": 0, "msg": "success", "data": { ... } }Interface List
| SDK Module | Method | HTTP Method | Path | Status |
|---|---|---|---|---|
| Auth | — | — | Handled internally by passport-client | Existing |
| Cloud | save (Create) | POST | /ai/v5/artimind/generator | Existing |
| Cloud | save (Update) | PUT | /ai/v5/artimind/generator | Existing |
| Cloud | restore | GET | /ai/v5/artimind/generator/:id | Existing |
| Cloud | delete | DELETE | /ai/v5/artimind/generator/:id | Existing |
| History | getList | POST | /ai/v5/artimind/generator/type | Existing |
| History | getDetail | GET | /ai/v5/artimind/generator/:id | Existing (Reuses Cloud) |
| History | delete | DELETE | /ai/v5/artimind/generator/:id | Existing (Reuses Cloud) |
| Credits | getBalance | GET | /ai/v1/credit/getBalance | Existing |
| Credits | consume | POST | /sdk/v1/credits/consume | Pending backend addition |
| Billing | getUsage | GET | /ai/v5/artimind/free_trial/count?module=generator_{appKey} | Existing |
| Billing | consume | POST | /ai/v5/artimind/free_trial | Existing |
| Export | — | — | Pure frontend operation + OSS upload | Existing |