gamma-upgrade-migration

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gamma Upgrade & Migration

Gamma SDK升级与版本迁移

Overview

概述

Guide for upgrading Gamma SDK versions and migrating between API versions safely.
安全升级Gamma SDK版本及在不同API版本间迁移的指南。

Prerequisites

前置条件

  • Existing Gamma integration
  • Version control (git)
  • Test environment available
  • 已完成Gamma集成
  • 版本控制工具(git)
  • 可用的测试环境

Instructions

操作步骤

Step 1: Check Current Version

步骤1:检查当前版本

bash
undefined
bash
undefined

Node.js

Node.js

npm list @gamma/sdk
npm list @gamma/sdk

Python

Python

pip show gamma-sdk
pip show gamma-sdk

Check for available updates

检查可用更新

npm outdated @gamma/sdk
undefined
npm outdated @gamma/sdk
undefined

Step 2: Review Changelog

步骤2:查看更新日志

bash
undefined
bash
undefined

View changelog

查看更新日志

npm info @gamma/sdk changelog
npm info @gamma/sdk changelog

Or visit

或访问以下链接

undefined
undefined

Step 3: Upgrade SDK

步骤3:升级SDK

bash
undefined
bash
undefined

Create upgrade branch

创建升级分支

git checkout -b feat/gamma-sdk-upgrade
git checkout -b feat/gamma-sdk-upgrade

Node.js - upgrade to latest

Node.js - 升级至最新版本

npm install @gamma/sdk@latest
npm install @gamma/sdk@latest

Python - upgrade to latest

Python - 升级至最新版本

pip install --upgrade gamma-sdk
pip install --upgrade gamma-sdk

Or specific version

或指定版本升级

npm install @gamma/sdk@2.0.0
undefined
npm install @gamma/sdk@2.0.0
undefined

Step 4: Handle Breaking Changes

步骤4:处理破坏性变更

Common Migration Patterns:
typescript
// v1.x -> v2.x: Client initialization change
// Before (v1)
import Gamma from '@gamma/sdk';
const gamma = new Gamma(apiKey);

// After (v2)
import { GammaClient } from '@gamma/sdk';
const gamma = new GammaClient({ apiKey });
typescript
// v1.x -> v2.x: Response format change
// Before (v1)
const result = await gamma.createPresentation({ title: 'Test' });
console.log(result.id);

// After (v2)
const result = await gamma.presentations.create({ title: 'Test' });
console.log(result.data.id);
typescript
// v1.x -> v2.x: Error handling change
// Before (v1)
try {
  await gamma.create({ ... });
} catch (e) {
  if (e.code === 'RATE_LIMIT') { ... }
}

// After (v2)
import { RateLimitError } from '@gamma/sdk';
try {
  await gamma.presentations.create({ ... });
} catch (e) {
  if (e instanceof RateLimitError) { ... }
}
常见迁移模式:
typescript
// v1.x 迁移至 v2.x:客户端初始化方式变更
// 旧版本(v1)
import Gamma from '@gamma/sdk';
const gamma = new Gamma(apiKey);

// 新版本(v2)
import { GammaClient } from '@gamma/sdk';
const gamma = new GammaClient({ apiKey });
typescript
// v1.x 迁移至 v2.x:响应格式变更
// 旧版本(v1)
const result = await gamma.createPresentation({ title: 'Test' });
console.log(result.id);

// 新版本(v2)
const result = await gamma.presentations.create({ title: 'Test' });
console.log(result.data.id);
typescript
// v1.x 迁移至 v2.x:错误处理方式变更
// 旧版本(v1)
try {
  await gamma.create({ ... });
} catch (e) {
  if (e.code === 'RATE_LIMIT') { ... }
}

// 新版本(v2)
import { RateLimitError } from '@gamma/sdk';
try {
  await gamma.presentations.create({ ... });
} catch (e) {
  if (e instanceof RateLimitError) { ... }
}

Step 5: Update Type Definitions

步骤5:更新类型定义

typescript
// Check for type changes
// tsconfig.json - ensure strict mode catches issues
{
  "compilerOptions": {
    "strict": true,
    "noImplicitAny": true
  }
}

// Run type check
npx tsc --noEmit
typescript
// 检查类型变更
// tsconfig.json - 确保严格模式能检测出问题
{
  "compilerOptions": {
    "strict": true,
    "noImplicitAny": true
  }
}

// 运行类型检查
npx tsc --noEmit

Step 6: Test Thoroughly

步骤6:全面测试

bash
undefined
bash
undefined

Run unit tests

运行单元测试

npm test
npm test

Run integration tests

运行集成测试

npm run test:integration
npm run test:integration

Manual smoke test

手动冒烟测试

node -e " const { GammaClient } = require('@gamma/sdk'); const g = new GammaClient({ apiKey: process.env.GAMMA_API_KEY }); g.ping().then(() => console.log('OK')).catch(console.error); "
undefined
node -e " const { GammaClient } = require('@gamma/sdk'); const g = new GammaClient({ apiKey: process.env.GAMMA_API_KEY }); g.ping().then(() => console.log('OK')).catch(console.error); "
undefined

Step 7: Deprecation Handling

步骤7:处理弃用内容

typescript
// Enable deprecation warnings
const gamma = new GammaClient({
  apiKey: process.env.GAMMA_API_KEY,
  showDeprecationWarnings: true,
});

// Migrate deprecated methods
// Deprecated
await gamma.getPresentations();

// New
await gamma.presentations.list();
typescript
// 开启弃用警告
const gamma = new GammaClient({
  apiKey: process.env.GAMMA_API_KEY,
  showDeprecationWarnings: true,
});

// 迁移已弃用的方法
// 已弃用
await gamma.getPresentations();

// 新方法
await gamma.presentations.list();

Migration Checklist

迁移检查清单

  • Current version documented
  • Changelog reviewed
  • Breaking changes identified
  • Upgrade branch created
  • SDK upgraded
  • Type errors fixed
  • Deprecation warnings addressed
  • Unit tests passing
  • Integration tests passing
  • Staging deployment verified
  • Production deployment planned
  • 已记录当前版本
  • 已查看更新日志
  • 已识别破坏性变更
  • 已创建升级分支
  • 已完成SDK升级
  • 已修复类型错误
  • 已处理弃用警告
  • 单元测试全部通过
  • 集成测试全部通过
  • 已验证预发布环境部署
  • 已规划生产环境部署

Rollback Procedure

回滚流程

bash
undefined
bash
undefined

If issues occur after upgrade

若升级后出现问题

git checkout main npm install # Restores previous version from lock file
git checkout main npm install # 从锁文件恢复至之前版本

Or explicitly downgrade

或显式降级版本

npm install @gamma/sdk@1.x.x
undefined
npm install @gamma/sdk@1.x.x
undefined

Resources

相关资源

Next Steps

后续步骤

Proceed to
gamma-ci-integration
for CI/CD setup.
接下来可查看
gamma-ci-integration
进行CI/CD配置。