CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/project/http-api/get-syncdoc-history.ts
Views: 687
1
/*
2
3
EXAMPLE:
4
5
~$ curl -u `cat .smc/secret_token`: -d path=a.md http://127.0.0.1:`cat .smc/api-server.port`/api/v1/get-syncdoc-history -d patches | python -m json.tool
6
7
If you get an error about no hubs connected, then edit a file in the project
8
in a browser to cause a connection to happen. Also, a.md need to be a file that
9
you have edited.
10
*/
11
12
import { meta_file } from "@cocalc/util/misc";
13
import { client_db } from "@cocalc/util/db-schema";
14
import { client } from "./server";
15
16
export default async function getSyncdocHistory({
17
path,
18
patches,
19
}): Promise<any> {
20
const dbg = client.dbg("get-syncdoc-history");
21
dbg(`path="${path}"`);
22
if (typeof path != "string") {
23
throw Error("provide the path as a string");
24
}
25
26
// transform jupyter path -- TODO: this should
27
// be more centralized... since this is brittle.
28
if (path.endsWith(".ipynb")) {
29
path = meta_file(path, "jupyter2");
30
}
31
32
// compute the string_id
33
const string_id = client_db.sha1(client.project_id, path);
34
return await client.get_syncdoc_history(string_id, !!patches);
35
}
36
37