@cocreate/crdt 1.11.1 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/package.json +4 -4
- package/src/index.js +22 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
# [1.13.0](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.12.0...v1.13.0) (2022-07-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* crud.getObjectValueByPath to return value using name containing a dotNotation string ([fd8bebf](https://github.com/CoCreate-app/CoCreate-crdt/commit/fd8bebf17722396a71d55affb297ec2718fb46a8))
|
|
7
|
+
|
|
8
|
+
# [1.12.0](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.11.2...v1.12.0) (2022-07-03)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* viewVersion function to return string of a specified version ([e652663](https://github.com/CoCreate-app/CoCreate-crdt/commit/e65266331c25baef10698e6234686a82b77ca4a6))
|
|
14
|
+
|
|
15
|
+
## [1.11.2](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.11.1...v1.11.2) (2022-06-18)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* bump dependencies ([605226f](https://github.com/CoCreate-app/CoCreate-crdt/commit/605226ff12c77430e89d453c978e245feadedd28))
|
|
21
|
+
|
|
1
22
|
## [1.11.1](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.11.0...v1.11.1) (2022-06-12)
|
|
2
23
|
|
|
3
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/crdt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "CoCreate crdt",
|
|
5
5
|
"author": "CoCreate LLC",
|
|
6
6
|
"license": "SEE LICENSE",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"webpack-log": "^3.0.1"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@cocreate/crud-client": "^1.7.
|
|
47
|
-
"@cocreate/message-client": "^1.1.
|
|
48
|
-
"@cocreate/utils": "^1.7.
|
|
46
|
+
"@cocreate/crud-client": "^1.7.1",
|
|
47
|
+
"@cocreate/message-client": "^1.1.71",
|
|
48
|
+
"@cocreate/utils": "^1.7.3"
|
|
49
49
|
}
|
|
50
50
|
}
|
package/src/index.js
CHANGED
|
@@ -19,6 +19,8 @@ function init(info){
|
|
|
19
19
|
|
|
20
20
|
async function getDoc(info) {
|
|
21
21
|
try {
|
|
22
|
+
if (['_id', 'organization_id'].includes(info.name))
|
|
23
|
+
return
|
|
22
24
|
let docName = generateDocName(info);
|
|
23
25
|
let typeName = info.name;
|
|
24
26
|
let doc = docs.get(docName);
|
|
@@ -104,7 +106,7 @@ async function checkDb(info, flag) {
|
|
|
104
106
|
if (checkedDb.get(`${collection}${document_id}${name}`)) return;
|
|
105
107
|
checkedDb.set(`${collection}${document_id}${name}`, true);
|
|
106
108
|
let response = await crud.readDocument({ collection, document_id, name });
|
|
107
|
-
let string = response.data
|
|
109
|
+
let string = crud.getObjectValueByPath(response.data, name);
|
|
108
110
|
if (string && flag != false) {
|
|
109
111
|
info.value = string;
|
|
110
112
|
info.start = 0;
|
|
@@ -396,6 +398,24 @@ function redoText(info){
|
|
|
396
398
|
}
|
|
397
399
|
}
|
|
398
400
|
|
|
401
|
+
async function viewVersion(data) {
|
|
402
|
+
try {
|
|
403
|
+
let name = docs.get(`${data.collection}${data.document_id}`).get(data.name);
|
|
404
|
+
let string = '';
|
|
405
|
+
let changeLog = name.get('changeLog');
|
|
406
|
+
let log = changeLog.slice(0, data.version)
|
|
407
|
+
for (let change of log) {
|
|
408
|
+
if (change || change !== null ) {
|
|
409
|
+
string = string.customSplice(change.start, change.length, change.value);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return { ...data, ...string }
|
|
413
|
+
}
|
|
414
|
+
catch (e) {
|
|
415
|
+
console.error(e);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
399
419
|
|
|
400
420
|
|
|
401
421
|
// function deleteDoc(docName) {
|
|
@@ -415,4 +435,4 @@ function generateDocName(info) {
|
|
|
415
435
|
// return btoa(JSON.stringify(docName));
|
|
416
436
|
}
|
|
417
437
|
|
|
418
|
-
export default { init, getText, updateText, replaceText, undoText, redoText };
|
|
438
|
+
export default { init, getText, updateText, replaceText, undoText, redoText, viewVersion };
|