Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 4b95a7f4 authored by Ludovic Le Frioux's avatar Ludovic Le Frioux
Browse files

Merge branch '36-update-to-c-crdtlib-v1-0-0-2' into 37-updateobject-should-handle-crdt-conflict

parents 03c35c7d 3de9ad81
No related branches found
No related tags found
2 merge requests!48Release v1.1.4,!34Resolve "updateObject should handle CRDT conflict"
Pipeline #197847 passed
......@@ -2559,9 +2559,9 @@
}
},
"@concordant/c-crdtlib": {
"version": "0.0.7-1",
"resolved": "https://gitlab.inria.fr/api/v4/projects/18591/packages/npm/@concordant/c-crdtlib/-/@concordant/c-crdtlib-0.0.7-1.tgz",
"integrity": "sha1-lkVUeMFQAuVhS5pP4gjGdN4vaUs=",
"version": "1.0.0",
"resolved": "https://gitlab.inria.fr/api/v4/projects/18591/packages/npm/@concordant/c-crdtlib/-/@concordant/c-crdtlib-1.0.0.tgz",
"integrity": "sha1-rHTb+O9v9S4A24rhdoFC182Kbjo=",
"requires": {
"kotlin": "1.4.10",
"kotlinx-serialization-kotlinx-serialization-core-jsLegacy": "1.0.0",
......
......@@ -44,7 +44,7 @@
"typescript": "^3.9.7"
},
"dependencies": {
"@concordant/c-crdtlib": "0.0.7-1",
"@concordant/c-crdtlib": "1.0.0",
"@types/uuid": "^3.4.9",
"apollo-server-express": "^2.19.0",
"body-parser": "^1.19.0",
......
......@@ -28,8 +28,11 @@ export default class CRDTWrapper {
return new CRDTWrapper(crdt.toJson());
}
public static unwrap(wrapper: CRDTWrapper): any {
return crdtlib.crdt.DeltaCRDT.Companion.fromJson(wrapper.crdtJson);
public static unwrap(
wrapper: CRDTWrapper,
env?: crdtlib.utils.Environment
): any {
return crdtlib.crdt.DeltaCRDT.Companion.fromJson(wrapper.crdtJson, env);
}
constructor(public crdtJson: string) {
......
......@@ -150,6 +150,10 @@ app.use(
basePath: "/api",
});
},
method: {
"Query.getObjects": "POST",
"Query.getObject": "POST",
},
})
);
......
......@@ -97,8 +97,8 @@ describe("Basic usage", () => {
.get<CRDTWrapper>(TEST_KEY, () => defaultObject)
.then(() => connection2.get<CRDTWrapper>(TEST_KEY))
.then((obj: Document<CRDTWrapper>) => {
const newCRDT = CRDTWrapper.unwrap(obj.current());
newCRDT.increment(42, environment1.tick());
const newCRDT = CRDTWrapper.unwrap(obj.current(), environment1);
newCRDT.increment(42);
return obj.update(CRDTWrapper.wrap(newCRDT)).save();
})
.then(() => connection2.get<CRDTWrapper>(TEST_KEY))
......@@ -113,7 +113,10 @@ describe("Basic usage", () => {
it("Conflict handler triggered on get", (done) => {
TEST_KEY = uuid();
const client1DefaultObject = new crdtlib.crdt.PNCounter();
const client1DefaultObject = crdtlib.crdt.DeltaCRDTFactory.Companion.createDeltaCRDT(
"PNCounter",
environment1
);
// default object is created by client2
const client2DefaultObjectWrapped = CRDTWrapper.wrap(
new crdtlib.crdt.PNCounter()
......@@ -150,13 +153,13 @@ describe("Basic usage", () => {
change: (key, newObj) => {
connection1.cancel(sub);
onlyAfter = true;
const crdt = CRDTWrapper.unwrap(newObj.current());
crdt.increment(40, environment2.tick());
const crdt = CRDTWrapper.unwrap(newObj.current(), environment2);
crdt.increment(40);
newObj
.update(CRDTWrapper.wrap(crdt))
.save()
.then(() => {
client1DefaultObject.increment(2, environment1.tick());
client1DefaultObject.increment(2);
return remoteObj
.update(CRDTWrapper.wrap(client1DefaultObject))
.save()
......@@ -241,7 +244,10 @@ describe("Test offline support with CRDTs", () => {
it("Go offline and receive pending updates on reconnect", (done) => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
const client1DefaultObject = new crdtlib.crdt.PNCounter();
const client1DefaultObject = crdtlib.crdt.DeltaCRDTFactory.Companion.createDeltaCRDT(
"PNCounter",
environment1
);
const client2DefaultObjectWrapped = CRDTWrapper.wrap(
new crdtlib.crdt.PNCounter()
);
......@@ -274,13 +280,13 @@ describe("Test offline support with CRDTs", () => {
change: (key, newObj) => {
connection1.cancel(sub);
onlyAfter = true;
const crdt = CRDTWrapper.unwrap(newObj.current());
crdt.increment(40, environment2.tick());
const crdt = CRDTWrapper.unwrap(newObj.current(), environment2);
crdt.increment(40);
newObj
.update(CRDTWrapper.wrap(crdt))
.save()
.then(() => {
client1DefaultObject.increment(2, environment1.tick());
client1DefaultObject.increment(2);
return remoteObj
.update(CRDTWrapper.wrap(client1DefaultObject))
.save()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment