The @snapback-oss/sdk package has been deprecated. Please visit vreko.dev for information about the Vreko platform.
This package is no longer maintained. If you were using this package, please update your dependencies accordingly.
- This npm package has been deprecated
- No further updates will be made to this codebase
- This repository is kept for historical reference
This repository remains available under the Apache-2.0 license for reference purposes.
import { SnapBackSDK } from '@snapback-oss/sdk';
// Initialize SDK
const snapback = new SnapBackSDK({
apiKey: process.env.SNAPBACK_API_KEY,
apiUrl: 'https://api.snapback.dev',
});
// Create a snapshot
const snapshot = await snapback.snapshots.create({
files: ['src/**/*.ts'],
message: 'Before refactoring',
});
// List snapshots
const snapshots = await snapback.snapshots.list();
// Restore from snapshot
await snapback.snapshots.restore(snapshot.id);- 📸 Snapshot Management - Create, list, restore snapshots
- 🗂️ File Protection - Mark files as protected
- 🔍 Search & Filter - Find snapshots by criteria
- ⚡ Async/Await - Promise-based API
- 🔒 Type-Safe - Full TypeScript support
- 🧪 Well-Tested - Comprehensive test coverage
// Create snapshot
const snapshot = await sdk.snapshots.create({
files: string[]; // File patterns (glob supported)
message?: string; // Optional description
tags?: string[]; // Optional tags
});
// List snapshots
const snapshots = await sdk.snapshots.list({
limit?: number;
offset?: number;
tags?: string[];
});
// Get snapshot details
const snapshot = await sdk.snapshots.get(snapshotId);
// Restore snapshot
await sdk.snapshots.restore(snapshotId, {
target?: string; // Optional restore location
force?: boolean; // Overwrite existing files
});
// Delete snapshot
await sdk.snapshots.delete(snapshotId);// Protect files
await sdk.protection.add({
patterns: ['*.config.js', 'src/critical/**'],
level: 'high',
});
// List protected files
const protected = await sdk.protection.list();
// Remove protection
await sdk.protection.remove({
patterns: ['*.config.js'],
});// Get storage usage
const usage = await sdk.storage.usage();
// Clean up old snapshots
await sdk.storage.cleanup({
olderThan: '30d',
keepMinimum: 10,
});const sdk = new SnapBackSDK({
// Required
apiKey: string;
// Optional
apiUrl?: string; // Default: https://api.snapback.dev
timeout?: number; // Default: 30000
retries?: number; // Default: 3
logger?: Logger; // Custom logger
});SNAPBACK_API_KEY=your_api_key
SNAPBACK_API_URL=https://api.snapback.devimport { SnapBackError } from '@snapback-oss/sdk';
try {
await sdk.snapshots.create({ files: [] });
} catch (error) {
if (error instanceof SnapBackError) {
console.error('SnapBack error:', error.code, error.message);
}
}import { SnapBackSDK } from '@snapback-oss/sdk';
import { CronJob } from 'cron';
const sdk = new SnapBackSDK({ apiKey: process.env.SNAPBACK_API_KEY });
// Daily backup at midnight
new CronJob('0 0 * * *', async () => {
await sdk.snapshots.create({
files: ['src/**/*'],
message: `Daily backup ${new Date().toISOString()}`,
tags: ['automated', 'daily'],
});
}).start();// .git/hooks/pre-commit
import { SnapBackSDK } from '@snapback-oss/sdk';
const sdk = new SnapBackSDK({ apiKey: process.env.SNAPBACK_API_KEY });
await sdk.snapshots.create({
files: ['src/**/*'],
message: `Pre-commit snapshot`,
tags: ['pre-commit'],
});// In your CI pipeline
import { SnapBackSDK } from '@snapback-oss/sdk';
const sdk = new SnapBackSDK({ apiKey: process.env.SNAPBACK_API_KEY });
// Snapshot before deployment
await sdk.snapshots.create({
files: ['dist/**/*'],
message: `Pre-deployment ${process.env.CI_COMMIT_SHA}`,
tags: ['deployment', process.env.CI_BRANCH],
});- ✅ Snapshot CRUD operations
- ✅ File protection
- ✅ Storage management
- ✅ HTTP client with retries
- ✅ Type definitions
- ❌ Advanced analytics
- ❌ AI-powered suggestions
- ❌ Premium storage features
See CONTRIBUTING.md
pnpm install
pnpm build
pnpm test- Documentation: docs.snapback.dev
- API Reference: docs.snapback.dev/api
- Main Repository: Marcelle-Labs/snapback.dev
Apache-2.0 © SnapBack