Snapshots
Overview
Intrasheets provide easy version management, allowing users to quickly create snapshots or recover from previous versions. This feature is available to spreadsheet owners, who can create and restore snapshots as needed. Developers can also automate snapshot creation at any desired frequency, as snapshots are triggered with a simple API call.
Requirements
It requires the Intrasheets Server API Extension and AWS S3
Frontend
Spreadsheet owners can use the interface to create new versions or restore from existing versions, giving them control over version management.
Server
Setup
All snapshots are compressed and stored in your S3 bucket.
const server = require('@jspreadsheet/server');
const adapter = require('@jspreadsheet/server-mongodb');
const api = require('@jspreadsheet/server-api');
// Load from ENV
require('dotenv').config();
// Jspreadsheet license
const license = {
clientId: process.env.JSS_CLIENT,
licenseKey: process.env.JSS_LICENSE
};
// Connect API to S3
api({
s3: {
key: process.env.AWS_S3_KEY,
secret: process.env.AWS_S3_SECRET,
bucket: process.env.AWS_BUCKET,
region: process.env.AWS_S3_REGION,
url: process.env.AWS_S3_URL,
},
adapter: adapter
});
History API
Using the API developers can also create rules for creating snapshots automatically.
Example
Get a list of all spreadsheet snapshots using the Client API.
import { Client } from "@intrasheets/client";
// Create a new client
const client = new Client({
// API Server
baseUrl: "http://localhost:8009/api",
// Your authentication token
token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});
// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Request data
spreadsheet.getHistory().then((data) => {
console.log(data);
});
More information
For more information about the History API.