@atomm-developer/generator-sdk
v1.0.25
Published
Atomm Generator 开放平台 SDK,为第三方生成器开发者提供登录、云保存、历史记录、积分等平台能力
Readme
@atomm-developer/generator-sdk
The Atomm Generator Open Platform SDK provides core capabilities for third-party generator developers, including authentication, cloud storage, history, credits, billing, export, and template protocols.
For a standardized host layout with built-in login, template actions, and floating export entry, use the companion package @atomm-developer/generator-workbench.
Installation
# Via npm/pnpm/yarn
pnpm add @atomm-developer/generator-sdk
pnpm add @atomm-developer/generator-workbench
# Via CDN (for plain HTML)
# <script src="https://static-res.atomm.com/scripts/js/generator-sdk/index.umd.js"></script>
# <script src="https://static-res.atomm.com/scripts/js/generator-sdk/generator-workbench/index.umd.js"></script>Package Roles
@atomm-developer/generator-sdk: platform capability layer such as auth, export, template, billing, and history.@atomm-developer/generator-workbench: official host shell that provides the top bar, login/template/export entries, and mounts the runtime either into a free workspace host or the classic split canvas/panel layout.
Quick Start
Initialization
import { GeneratorSDK } from '@atomm-developer/generator-sdk';
const sdk = GeneratorSDK.init({
appKey: 'your_app_key', // Get from developer console
env: 'prod', // 'dev' | 'test' | 'pre' | 'prod'
});
console.log(sdk.getAppKey());
console.log(GeneratorSDK.getAppKey());Core Modules
Auth - Authentication
// Login
const userInfo = await sdk.auth.login();
console.log(userInfo.roleList);
console.log(userInfo.isCommunityAdmin);
// Get current status
const { isLogin, userInfo } = sdk.auth.getStatus();
if (isLogin) {
console.log(userInfo.roleList);
console.log(userInfo.isCommunityAdmin);
}
// Logout
await sdk.auth.logout();Cloud & History - Storage
// Save to cloud
await sdk.cloud.save({
title: 'My Design',
snapshot: { /* your state object */ },
cover: canvasElement,
});
// Get history list
const list = await sdk.history.getList({ page: 1, pageSize: 20 });Billing & Credits - Monetization
// Check usage (free quota + credits)
const usage = await sdk.billing.getUsage();
// Consume with billing (recommended)
import { withBilling } from '@atomm-developer/generator-sdk';
await withBilling(sdk.billing, async () => {
// Your paid action (e.g., download or AI generate)
await sdk.export.download();
});Export - Output
// Register provider first
sdk.export.register({
getExportCanvas: (purpose) => document.getElementById('myCanvas'),
});
// Download or Open in Studio
await sdk.export.download();
await sdk.export.openInStudio();Documentation
For detailed API references and integration guides, please visit our Documentation Portal.
Repository Build
This repository now builds both the SDK bundle and the generator-workbench UMD asset through the root build chain:
pnpm build
pnpm type-check
pnpm test:workbenchpnpm deploy:cdn uploads the generator-sdk bundle, the generator-workbench UMD asset, the generator-workbench/upgrade-manifest.json, and the generator-workbench runtime dependencies under atomm-pro/dist-browser to static-res.atomm.com.
If you need to publish both packages from the repository root, use:
pnpm deploy
pnpm deploy:workbench
# or
pnpm deploy:allLicense
MIT
