document-model 6.0.0-dev.11 → 6.0.0-dev.110
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/dist/index.d.ts +81 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +216 -0
- package/dist/index.js.map +1 -0
- package/dist/node.d.mts +62 -0
- package/dist/node.d.mts.map +1 -0
- package/dist/node.mjs +151 -0
- package/dist/node.mjs.map +1 -0
- package/package.json +15 -24
- package/dist/src/core/actions.d.ts +0 -87
- package/dist/src/core/actions.d.ts.map +0 -1
- package/dist/src/core/actions.js +0 -187
- package/dist/src/core/actions.js.map +0 -1
- package/dist/src/core/crypto.d.ts +0 -8
- package/dist/src/core/crypto.d.ts.map +0 -1
- package/dist/src/core/crypto.js +0 -68
- package/dist/src/core/crypto.js.map +0 -1
- package/dist/src/core/documents.d.ts +0 -146
- package/dist/src/core/documents.d.ts.map +0 -1
- package/dist/src/core/documents.js +0 -814
- package/dist/src/core/documents.js.map +0 -1
- package/dist/src/core/errors.d.ts +0 -21
- package/dist/src/core/errors.d.ts.map +0 -1
- package/dist/src/core/errors.js +0 -46
- package/dist/src/core/errors.js.map +0 -1
- package/dist/src/core/files.d.ts +0 -14
- package/dist/src/core/files.d.ts.map +0 -1
- package/dist/src/core/files.js +0 -65
- package/dist/src/core/files.js.map +0 -1
- package/dist/src/core/header.d.ts +0 -63
- package/dist/src/core/header.d.ts.map +0 -1
- package/dist/src/core/header.js +0 -178
- package/dist/src/core/header.js.map +0 -1
- package/dist/src/core/index.d.ts +0 -13
- package/dist/src/core/index.d.ts.map +0 -1
- package/dist/src/core/index.js +0 -13
- package/dist/src/core/index.js.map +0 -1
- package/dist/src/core/node.d.ts +0 -53
- package/dist/src/core/node.d.ts.map +0 -1
- package/dist/src/core/node.js +0 -139
- package/dist/src/core/node.js.map +0 -1
- package/dist/src/core/operations.d.ts +0 -48
- package/dist/src/core/operations.d.ts.map +0 -1
- package/dist/src/core/operations.js +0 -122
- package/dist/src/core/operations.js.map +0 -1
- package/dist/src/core/ph-types.d.ts +0 -315
- package/dist/src/core/ph-types.d.ts.map +0 -1
- package/dist/src/core/ph-types.js +0 -15
- package/dist/src/core/ph-types.js.map +0 -1
- package/dist/src/core/reducer.d.ts +0 -63
- package/dist/src/core/reducer.d.ts.map +0 -1
- package/dist/src/core/reducer.js +0 -455
- package/dist/src/core/reducer.js.map +0 -1
- package/dist/src/core/schemas.d.ts +0 -69
- package/dist/src/core/schemas.d.ts.map +0 -1
- package/dist/src/core/schemas.js +0 -110
- package/dist/src/core/schemas.js.map +0 -1
- package/dist/src/core/state.d.ts +0 -26
- package/dist/src/core/state.d.ts.map +0 -1
- package/dist/src/core/state.js +0 -56
- package/dist/src/core/state.js.map +0 -1
- package/dist/src/core/types.d.ts +0 -536
- package/dist/src/core/types.d.ts.map +0 -1
- package/dist/src/core/types.js +0 -2
- package/dist/src/core/types.js.map +0 -1
- package/dist/src/core/utils.d.ts +0 -6
- package/dist/src/core/utils.d.ts.map +0 -1
- package/dist/src/core/utils.js +0 -15
- package/dist/src/core/utils.js.map +0 -1
- package/dist/src/core/validation.d.ts +0 -4
- package/dist/src/core/validation.d.ts.map +0 -1
- package/dist/src/core/validation.js +0 -27
- package/dist/src/core/validation.js.map +0 -1
- package/dist/src/document-model/actions.d.ts +0 -158
- package/dist/src/document-model/actions.d.ts.map +0 -1
- package/dist/src/document-model/actions.js +0 -111
- package/dist/src/document-model/actions.js.map +0 -1
- package/dist/src/document-model/constants.d.ts +0 -6
- package/dist/src/document-model/constants.d.ts.map +0 -1
- package/dist/src/document-model/constants.js +0 -573
- package/dist/src/document-model/constants.js.map +0 -1
- package/dist/src/document-model/document-schema.d.ts +0 -69
- package/dist/src/document-model/document-schema.d.ts.map +0 -1
- package/dist/src/document-model/document-schema.js +0 -43
- package/dist/src/document-model/document-schema.js.map +0 -1
- package/dist/src/document-model/document-type.d.ts +0 -2
- package/dist/src/document-model/document-type.d.ts.map +0 -1
- package/dist/src/document-model/document-type.js +0 -2
- package/dist/src/document-model/document-type.js.map +0 -1
- package/dist/src/document-model/files.d.ts +0 -5
- package/dist/src/document-model/files.d.ts.map +0 -1
- package/dist/src/document-model/files.js +0 -9
- package/dist/src/document-model/files.js.map +0 -1
- package/dist/src/document-model/index.d.ts +0 -11
- package/dist/src/document-model/index.d.ts.map +0 -1
- package/dist/src/document-model/index.js +0 -11
- package/dist/src/document-model/index.js.map +0 -1
- package/dist/src/document-model/module.d.ts +0 -3
- package/dist/src/document-model/module.d.ts.map +0 -1
- package/dist/src/document-model/module.js +0 -24
- package/dist/src/document-model/module.js.map +0 -1
- package/dist/src/document-model/reducers.d.ts +0 -11
- package/dist/src/document-model/reducers.d.ts.map +0 -1
- package/dist/src/document-model/reducers.js +0 -618
- package/dist/src/document-model/reducers.js.map +0 -1
- package/dist/src/document-model/schemas.d.ts +0 -189
- package/dist/src/document-model/schemas.d.ts.map +0 -1
- package/dist/src/document-model/schemas.js +0 -388
- package/dist/src/document-model/schemas.js.map +0 -1
- package/dist/src/document-model/state.d.ts +0 -15
- package/dist/src/document-model/state.d.ts.map +0 -1
- package/dist/src/document-model/state.js +0 -75
- package/dist/src/document-model/state.js.map +0 -1
- package/dist/src/document-model/types.d.ts +0 -679
- package/dist/src/document-model/types.d.ts.map +0 -1
- package/dist/src/document-model/types.js +0 -2
- package/dist/src/document-model/types.js.map +0 -1
- package/dist/src/document-model/validation.d.ts +0 -32
- package/dist/src/document-model/validation.d.ts.map +0 -1
- package/dist/src/document-model/validation.js +0 -166
- package/dist/src/document-model/validation.js.map +0 -1
- package/dist/src/index.d.ts +0 -6
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -3
- package/dist/src/index.js.map +0 -1
- package/dist/test/document/crypto.test.d.ts +0 -2
- package/dist/test/document/crypto.test.d.ts.map +0 -1
- package/dist/test/document/crypto.test.js +0 -195
- package/dist/test/document/crypto.test.js.map +0 -1
- package/dist/test/document/event-vs-command.test.d.ts +0 -2
- package/dist/test/document/event-vs-command.test.d.ts.map +0 -1
- package/dist/test/document/event-vs-command.test.js +0 -202
- package/dist/test/document/event-vs-command.test.js.map +0 -1
- package/dist/test/document/local.test.d.ts +0 -2
- package/dist/test/document/local.test.d.ts.map +0 -1
- package/dist/test/document/local.test.js +0 -229
- package/dist/test/document/local.test.js.map +0 -1
- package/dist/test/document/operation-id.test.d.ts +0 -2
- package/dist/test/document/operation-id.test.d.ts.map +0 -1
- package/dist/test/document/operation-id.test.js +0 -118
- package/dist/test/document/operation-id.test.js.map +0 -1
- package/dist/test/document/prune.test.d.ts +0 -2
- package/dist/test/document/prune.test.d.ts.map +0 -1
- package/dist/test/document/prune.test.js +0 -159
- package/dist/test/document/prune.test.js.map +0 -1
- package/dist/test/document/reducer.test.d.ts +0 -2
- package/dist/test/document/reducer.test.d.ts.map +0 -1
- package/dist/test/document/reducer.test.js +0 -284
- package/dist/test/document/reducer.test.js.map +0 -1
- package/dist/test/document/skip-operations.test.d.ts +0 -2
- package/dist/test/document/skip-operations.test.d.ts.map +0 -1
- package/dist/test/document/skip-operations.test.js +0 -412
- package/dist/test/document/skip-operations.test.js.map +0 -1
- package/dist/test/document/undo-redo-v2.test.d.ts +0 -2
- package/dist/test/document/undo-redo-v2.test.d.ts.map +0 -1
- package/dist/test/document/undo-redo-v2.test.js +0 -207
- package/dist/test/document/undo-redo-v2.test.js.map +0 -1
- package/dist/test/document/undo-redo.test.d.ts +0 -2
- package/dist/test/document/undo-redo.test.d.ts.map +0 -1
- package/dist/test/document/undo-redo.test.js +0 -413
- package/dist/test/document/undo-redo.test.js.map +0 -1
- package/dist/test/document/utils.test.d.ts +0 -2
- package/dist/test/document/utils.test.d.ts.map +0 -1
- package/dist/test/document/utils.test.js +0 -172
- package/dist/test/document/utils.test.js.map +0 -1
- package/dist/test/document-helpers/addUndo.test.d.ts +0 -2
- package/dist/test/document-helpers/addUndo.test.d.ts.map +0 -1
- package/dist/test/document-helpers/addUndo.test.js +0 -120
- package/dist/test/document-helpers/addUndo.test.js.map +0 -1
- package/dist/test/document-helpers/attachBranch.test.d.ts +0 -2
- package/dist/test/document-helpers/attachBranch.test.d.ts.map +0 -1
- package/dist/test/document-helpers/attachBranch.test.js +0 -364
- package/dist/test/document-helpers/attachBranch.test.js.map +0 -1
- package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts +0 -2
- package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts.map +0 -1
- package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.js +0 -252
- package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.js.map +0 -1
- package/dist/test/document-helpers/conflictResolution.test.d.ts +0 -2
- package/dist/test/document-helpers/conflictResolution.test.d.ts.map +0 -1
- package/dist/test/document-helpers/conflictResolution.test.js +0 -109
- package/dist/test/document-helpers/conflictResolution.test.js.map +0 -1
- package/dist/test/document-helpers/filterDuplicatedOperations.test.d.ts +0 -2
- package/dist/test/document-helpers/filterDuplicatedOperations.test.d.ts.map +0 -1
- package/dist/test/document-helpers/filterDuplicatedOperations.test.js +0 -126
- package/dist/test/document-helpers/filterDuplicatedOperations.test.js.map +0 -1
- package/dist/test/document-helpers/garbageCollect.test.d.ts +0 -2
- package/dist/test/document-helpers/garbageCollect.test.d.ts.map +0 -1
- package/dist/test/document-helpers/garbageCollect.test.js +0 -136
- package/dist/test/document-helpers/garbageCollect.test.js.map +0 -1
- package/dist/test/document-helpers/groupOperationsByScope.test.d.ts +0 -2
- package/dist/test/document-helpers/groupOperationsByScope.test.d.ts.map +0 -1
- package/dist/test/document-helpers/groupOperationsByScope.test.js +0 -102
- package/dist/test/document-helpers/groupOperationsByScope.test.js.map +0 -1
- package/dist/test/document-helpers/merge.test.d.ts +0 -2
- package/dist/test/document-helpers/merge.test.d.ts.map +0 -1
- package/dist/test/document-helpers/merge.test.js +0 -906
- package/dist/test/document-helpers/merge.test.js.map +0 -1
- package/dist/test/document-helpers/nextSkipNumber.test.d.ts +0 -2
- package/dist/test/document-helpers/nextSkipNumber.test.d.ts.map +0 -1
- package/dist/test/document-helpers/nextSkipNumber.test.js +0 -135
- package/dist/test/document-helpers/nextSkipNumber.test.js.map +0 -1
- package/dist/test/document-helpers/prepareOperations.test.d.ts +0 -2
- package/dist/test/document-helpers/prepareOperations.test.d.ts.map +0 -1
- package/dist/test/document-helpers/prepareOperations.test.js +0 -304
- package/dist/test/document-helpers/prepareOperations.test.js.map +0 -1
- package/dist/test/document-helpers/removeExistingOperations.test.d.ts +0 -2
- package/dist/test/document-helpers/removeExistingOperations.test.d.ts.map +0 -1
- package/dist/test/document-helpers/removeExistingOperations.test.js +0 -177
- package/dist/test/document-helpers/removeExistingOperations.test.js.map +0 -1
- package/dist/test/document-helpers/reshuffleByTimestamp.test.d.ts +0 -2
- package/dist/test/document-helpers/reshuffleByTimestamp.test.d.ts.map +0 -1
- package/dist/test/document-helpers/reshuffleByTimestamp.test.js +0 -148
- package/dist/test/document-helpers/reshuffleByTimestamp.test.js.map +0 -1
- package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts +0 -2
- package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts.map +0 -1
- package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.js +0 -200
- package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.js.map +0 -1
- package/dist/test/document-helpers/skipHeaderOperations.test.d.ts +0 -2
- package/dist/test/document-helpers/skipHeaderOperations.test.d.ts.map +0 -1
- package/dist/test/document-helpers/skipHeaderOperations.test.js +0 -72
- package/dist/test/document-helpers/skipHeaderOperations.test.js.map +0 -1
- package/dist/test/document-helpers/sortOperations.test.d.ts +0 -2
- package/dist/test/document-helpers/sortOperations.test.d.ts.map +0 -1
- package/dist/test/document-helpers/sortOperations.test.js +0 -101
- package/dist/test/document-helpers/sortOperations.test.js.map +0 -1
- package/dist/test/document-helpers/split.test.d.ts +0 -2
- package/dist/test/document-helpers/split.test.d.ts.map +0 -1
- package/dist/test/document-helpers/split.test.js +0 -121
- package/dist/test/document-helpers/split.test.js.map +0 -1
- package/dist/test/document-helpers/utils.d.ts +0 -15
- package/dist/test/document-helpers/utils.d.ts.map +0 -1
- package/dist/test/document-helpers/utils.js +0 -61
- package/dist/test/document-helpers/utils.js.map +0 -1
- package/dist/test/document-model/replay.test.d.ts +0 -2
- package/dist/test/document-model/replay.test.d.ts.map +0 -1
- package/dist/test/document-model/replay.test.js +0 -139
- package/dist/test/document-model/replay.test.js.map +0 -1
- package/dist/test/document-model/skip-operations.test.d.ts +0 -2
- package/dist/test/document-model/skip-operations.test.d.ts.map +0 -1
- package/dist/test/document-model/skip-operations.test.js +0 -214
- package/dist/test/document-model/skip-operations.test.js.map +0 -1
- package/dist/test/document-model/validation.test.d.ts +0 -2
- package/dist/test/document-model/validation.test.d.ts.map +0 -1
- package/dist/test/document-model/validation.test.js +0 -451
- package/dist/test/document-model/validation.test.js.map +0 -1
- package/dist/test/document-model/versioning.test.d.ts +0 -2
- package/dist/test/document-model/versioning.test.d.ts.map +0 -1
- package/dist/test/document-model/versioning.test.js +0 -93
- package/dist/test/document-model/versioning.test.js.map +0 -1
- package/dist/test/document-model/zip.test.d.ts +0 -2
- package/dist/test/document-model/zip.test.d.ts.map +0 -1
- package/dist/test/document-model/zip.test.js +0 -79
- package/dist/test/document-model/zip.test.js.map +0 -1
- package/dist/test/helpers.d.ts +0 -77
- package/dist/test/helpers.d.ts.map +0 -1
- package/dist/test/helpers.js +0 -118
- package/dist/test/helpers.js.map +0 -1
- package/dist/test/index.d.ts +0 -4
- package/dist/test/index.d.ts.map +0 -1
- package/dist/test/index.js +0 -3
- package/dist/test/index.js.map +0 -1
- package/dist/test/types.d.ts +0 -6
- package/dist/test/types.d.ts.map +0 -1
- package/dist/test/types.js +0 -2
- package/dist/test/types.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
- package/dist/vitest.config.js +0 -7
- package/dist/vitest.config.js.map +0 -1
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { deriveOperationId, removeExistingOperations, } from "document-model/core";
|
|
3
|
-
import { buildOperations, fakeAction } from "document-model/test";
|
|
4
|
-
const TEST_DOC_ID = "test-doc-id";
|
|
5
|
-
const TEST_BRANCH = "main";
|
|
6
|
-
const TEST_SCOPE = "global";
|
|
7
|
-
describe("removeExistingOperations", () => {
|
|
8
|
-
const scenarios = [
|
|
9
|
-
{
|
|
10
|
-
title: "case 1: all new operations should be applied",
|
|
11
|
-
operationsHistory: [
|
|
12
|
-
{ index: 0, skip: 0, type: "OP_0", hash: "hash_0" },
|
|
13
|
-
{ index: 1, skip: 0, type: "OP_1", hash: "hash_1" },
|
|
14
|
-
{ index: 2, skip: 0, type: "OP_2", hash: "hash_2" },
|
|
15
|
-
],
|
|
16
|
-
newOperations: [
|
|
17
|
-
{ index: 4, skip: 0, type: "OP_4", hash: "hash_4" },
|
|
18
|
-
{ index: 5, skip: 0, type: "OP_5", hash: "hash_5" },
|
|
19
|
-
{ index: 6, skip: 0, type: "OP_6", hash: "hash_6" },
|
|
20
|
-
],
|
|
21
|
-
expected: [
|
|
22
|
-
{ index: 4, skip: 0, type: "OP_4", hash: "hash_4" },
|
|
23
|
-
{ index: 5, skip: 0, type: "OP_5", hash: "hash_5" },
|
|
24
|
-
{ index: 6, skip: 0, type: "OP_6", hash: "hash_6" },
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
title: "case 2: return no operations, all of them already exist in the history",
|
|
29
|
-
operationsHistory: [
|
|
30
|
-
{ index: 0, skip: 0, type: "OP_0", hash: "hash_0" },
|
|
31
|
-
{ index: 1, skip: 0, type: "OP_1", hash: "hash_1" },
|
|
32
|
-
{ index: 2, skip: 0, type: "OP_2", hash: "hash_2" },
|
|
33
|
-
],
|
|
34
|
-
newOperations: [
|
|
35
|
-
{ index: 0, skip: 0, type: "OP_0", hash: "hash_0" },
|
|
36
|
-
{ index: 1, skip: 0, type: "OP_1", hash: "hash_1" },
|
|
37
|
-
{ index: 2, skip: 0, type: "OP_2", hash: "hash_2" },
|
|
38
|
-
],
|
|
39
|
-
expected: [],
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
title: "case 3: return only operation that does not exist in the history",
|
|
43
|
-
operationsHistory: [
|
|
44
|
-
{ index: 0, skip: 0, type: "OP_0", hash: "hash_0" },
|
|
45
|
-
{ index: 1, skip: 0, type: "OP_1", hash: "hash_1" },
|
|
46
|
-
{ index: 2, skip: 0, type: "OP_2", hash: "hash_2" },
|
|
47
|
-
{ index: 3, skip: 0, type: "OP_3", hash: "hash_3" },
|
|
48
|
-
{ index: 4, skip: 0, type: "OP_4", hash: "hash_4" },
|
|
49
|
-
{ index: 5, skip: 0, type: "OP_5", hash: "hash_5" },
|
|
50
|
-
],
|
|
51
|
-
newOperations: [
|
|
52
|
-
{ index: 4, skip: 0, type: "OP_4", hash: "hash_4" },
|
|
53
|
-
{ index: 5, skip: 0, type: "OP_5", hash: "hash_5" },
|
|
54
|
-
{ index: 6, skip: 0, type: "OP_6", hash: "hash_6" },
|
|
55
|
-
{ index: 7, skip: 0, type: "OP_7", hash: "hash_7" },
|
|
56
|
-
],
|
|
57
|
-
expected: [
|
|
58
|
-
{ index: 6, skip: 0, type: "OP_6", hash: "hash_6" },
|
|
59
|
-
{ index: 7, skip: 0, type: "OP_7", hash: "hash_7" },
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
title: "case 4: return only operation that does not exist in the history",
|
|
64
|
-
operationsHistory: [
|
|
65
|
-
{ index: 0, skip: 0, type: "OP_0", hash: "hash_0" },
|
|
66
|
-
{ index: 2, skip: 0, type: "OP_2", hash: "hash_2" },
|
|
67
|
-
{ index: 4, skip: 0, type: "OP_4", hash: "hash_4" },
|
|
68
|
-
],
|
|
69
|
-
newOperations: [
|
|
70
|
-
{ index: 0, skip: 0, type: "OP_0", hash: "hash_0" },
|
|
71
|
-
{ index: 1, skip: 0, type: "OP_1", hash: "hash_1" },
|
|
72
|
-
{ index: 2, skip: 0, type: "OP_2", hash: "hash_2" },
|
|
73
|
-
{ index: 3, skip: 0, type: "OP_3", hash: "hash_3" },
|
|
74
|
-
{ index: 4, skip: 0, type: "OP_4", hash: "hash_4" },
|
|
75
|
-
{ index: 5, skip: 0, type: "OP_5", hash: "hash_5" },
|
|
76
|
-
],
|
|
77
|
-
expected: [
|
|
78
|
-
{ index: 1, skip: 0, type: "OP_1", hash: "hash_1" },
|
|
79
|
-
{ index: 3, skip: 0, type: "OP_3", hash: "hash_3" },
|
|
80
|
-
{ index: 5, skip: 0, type: "OP_5", hash: "hash_5" },
|
|
81
|
-
],
|
|
82
|
-
},
|
|
83
|
-
];
|
|
84
|
-
it.each(scenarios)("$title", (testInput) => {
|
|
85
|
-
const newOperations = buildOperations(testInput.newOperations);
|
|
86
|
-
const operationsHistory = buildOperations(testInput.operationsHistory);
|
|
87
|
-
const result = removeExistingOperations(newOperations, operationsHistory);
|
|
88
|
-
expect(result).toMatchObject(testInput.expected);
|
|
89
|
-
});
|
|
90
|
-
it("should not consider operations skipped", () => {
|
|
91
|
-
const action1 = fakeAction({
|
|
92
|
-
type: "NOOP",
|
|
93
|
-
input: {},
|
|
94
|
-
scope: "global",
|
|
95
|
-
});
|
|
96
|
-
const action2 = fakeAction({
|
|
97
|
-
type: "ADD_FOLDER",
|
|
98
|
-
input: { id: "1", name: "test1" },
|
|
99
|
-
scope: "global",
|
|
100
|
-
});
|
|
101
|
-
const action3 = fakeAction({
|
|
102
|
-
type: "ADD_FOLDER",
|
|
103
|
-
input: { id: "2", name: "test2" },
|
|
104
|
-
scope: "global",
|
|
105
|
-
});
|
|
106
|
-
const action4 = fakeAction({
|
|
107
|
-
type: "ADD_FOLDER",
|
|
108
|
-
input: { id: "1", name: "test1" },
|
|
109
|
-
scope: "global",
|
|
110
|
-
});
|
|
111
|
-
const action5 = fakeAction({
|
|
112
|
-
type: "ADD_FOLDER",
|
|
113
|
-
input: { id: "1", name: "test1" },
|
|
114
|
-
scope: "global",
|
|
115
|
-
});
|
|
116
|
-
const action6 = fakeAction({
|
|
117
|
-
type: "ADD_FOLDER",
|
|
118
|
-
input: { id: "2", name: "test2" },
|
|
119
|
-
scope: "global",
|
|
120
|
-
});
|
|
121
|
-
const existingOperations = [
|
|
122
|
-
{
|
|
123
|
-
id: deriveOperationId(TEST_DOC_ID, TEST_SCOPE, TEST_BRANCH, action1.id),
|
|
124
|
-
action: action1,
|
|
125
|
-
index: 0,
|
|
126
|
-
timestampUtcMs: "2024-04-22T18:33:20.624Z",
|
|
127
|
-
hash: "pLimr2HqW//d6upWCv4tGfI0W4c=",
|
|
128
|
-
skip: 0,
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
id: deriveOperationId(TEST_DOC_ID, TEST_SCOPE, TEST_BRANCH, action2.id),
|
|
132
|
-
action: action2,
|
|
133
|
-
index: 1,
|
|
134
|
-
timestampUtcMs: "2024-04-22T18:33:20.631Z",
|
|
135
|
-
hash: "P6p5OmHl7FpHRN9ftOS0k+eaU4E=",
|
|
136
|
-
skip: 1,
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
id: deriveOperationId(TEST_DOC_ID, TEST_SCOPE, TEST_BRANCH, action3.id),
|
|
140
|
-
action: action3,
|
|
141
|
-
index: 2,
|
|
142
|
-
timestampUtcMs: "2024-04-22T18:33:20.631Z",
|
|
143
|
-
hash: "5XOFEY2NKrHVyOA3c3oXDibrjwM=",
|
|
144
|
-
skip: 0,
|
|
145
|
-
},
|
|
146
|
-
];
|
|
147
|
-
const operationsHistory = [
|
|
148
|
-
{
|
|
149
|
-
id: deriveOperationId(TEST_DOC_ID, TEST_SCOPE, TEST_BRANCH, action4.id),
|
|
150
|
-
action: action4,
|
|
151
|
-
index: 0,
|
|
152
|
-
timestampUtcMs: "2024-04-22T18:33:20.628Z",
|
|
153
|
-
hash: "P6p5OmHl7FpHRN9ftOS0k+eaU4E=",
|
|
154
|
-
skip: 0,
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
id: deriveOperationId(TEST_DOC_ID, TEST_SCOPE, TEST_BRANCH, action5.id),
|
|
158
|
-
action: action5,
|
|
159
|
-
index: 1,
|
|
160
|
-
timestampUtcMs: "2024-04-22T18:33:20.630Z",
|
|
161
|
-
hash: "P6p5OmHl7FpHRN9ftOS0k+eaU4E=",
|
|
162
|
-
skip: 1,
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
id: deriveOperationId(TEST_DOC_ID, TEST_SCOPE, TEST_BRANCH, action6.id),
|
|
166
|
-
action: action6,
|
|
167
|
-
index: 2,
|
|
168
|
-
timestampUtcMs: "2024-04-22T18:33:20.630Z",
|
|
169
|
-
hash: "5XOFEY2NKrHVyOA3c3oXDibrjwM=",
|
|
170
|
-
skip: 0,
|
|
171
|
-
},
|
|
172
|
-
];
|
|
173
|
-
const result = removeExistingOperations(existingOperations, operationsHistory);
|
|
174
|
-
expect(result).toMatchObject([]);
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
//# sourceMappingURL=removeExistingOperations.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"removeExistingOperations.test.js","sourceRoot":"","sources":["../../../test/document-helpers/removeExistingOperations.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAG9C,OAAO,EACL,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAElE,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,MAAM,UAAU,GAAG,QAAQ,CAAC;AAE5B,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,M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,IAAI,EAAE,8BAA8B;gBACpC,IAAI,EAAE,CAAC;aACR;YACD;gBACE,EAAE,EAAE,iBAAiB,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,CAAC;gBACvE,MAAM,EAAE,OAAO;gBACf,KAAK,EAAE,CAAC;gBACR,cAAc,EAAE,0BAA0B;gBAC1C,IAAI,EAAE,8BAA8B;gBACpC,IAAI,EAAE,CAAC;aACR;SACF,CAAC;QAEF,MAAM,MAAM,GAAG,wBAAwB,CACrC,kBAAkB,EAClB,iBAAiB,CAClB,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reshuffleByTimestamp.test.d.ts","sourceRoot":"","sources":["../../../test/document-helpers/reshuffleByTimestamp.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { reshuffleByTimestamp } from "document-model/core";
|
|
3
|
-
import { buildOperations } from "./utils.js";
|
|
4
|
-
describe("reshuffleByTimestamp", () => {
|
|
5
|
-
const scenarios = [
|
|
6
|
-
{
|
|
7
|
-
title: "case 1",
|
|
8
|
-
startIndex: { index: 6, skip: 2 },
|
|
9
|
-
operationsA: buildOperations([
|
|
10
|
-
{
|
|
11
|
-
index: 4,
|
|
12
|
-
skip: 0,
|
|
13
|
-
type: "OP_A_4",
|
|
14
|
-
timestampUtcMs: "2021-01-01T00:00:00.000Z",
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
index: 5,
|
|
18
|
-
skip: 0,
|
|
19
|
-
type: "OP_A_5",
|
|
20
|
-
timestampUtcMs: "2021-01-04T00:00:00.000Z",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
index: 6,
|
|
24
|
-
skip: 0,
|
|
25
|
-
type: "OP_A_6",
|
|
26
|
-
timestampUtcMs: "2021-01-05T00:00:00.000Z",
|
|
27
|
-
},
|
|
28
|
-
]),
|
|
29
|
-
operationsB: buildOperations([
|
|
30
|
-
{
|
|
31
|
-
index: 4,
|
|
32
|
-
skip: 0,
|
|
33
|
-
type: "OP_B_4",
|
|
34
|
-
timestampUtcMs: "2021-01-02T00:00:00.000Z",
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
index: 5,
|
|
38
|
-
skip: 0,
|
|
39
|
-
type: "OP_B_5",
|
|
40
|
-
timestampUtcMs: "2021-01-03T00:00:00.000Z",
|
|
41
|
-
},
|
|
42
|
-
]),
|
|
43
|
-
expected: [
|
|
44
|
-
{ index: 6, skip: 2, type: "OP_A_4" },
|
|
45
|
-
{ index: 7, skip: 0, type: "OP_B_4" },
|
|
46
|
-
{ index: 8, skip: 0, type: "OP_B_5" },
|
|
47
|
-
{ index: 9, skip: 0, type: "OP_A_5" },
|
|
48
|
-
{ index: 10, skip: 0, type: "OP_A_6" },
|
|
49
|
-
],
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
title: "case 2 (remove skip from operations)",
|
|
53
|
-
startIndex: { index: 3, skip: 1 },
|
|
54
|
-
operationsA: buildOperations([
|
|
55
|
-
{
|
|
56
|
-
index: 2,
|
|
57
|
-
skip: 0,
|
|
58
|
-
type: "OP_A_2",
|
|
59
|
-
timestampUtcMs: "2021-01-01T00:00:00.000Z",
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
index: 3,
|
|
63
|
-
skip: 0,
|
|
64
|
-
type: "OP_A_3",
|
|
65
|
-
timestampUtcMs: "2021-01-03T00:00:00.000Z",
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
index: 4,
|
|
69
|
-
skip: 0,
|
|
70
|
-
type: "OP_A_4",
|
|
71
|
-
timestampUtcMs: "2021-01-04T00:00:00.000Z",
|
|
72
|
-
},
|
|
73
|
-
]),
|
|
74
|
-
operationsB: buildOperations([
|
|
75
|
-
{
|
|
76
|
-
index: 3,
|
|
77
|
-
skip: 0,
|
|
78
|
-
type: "OP_B_3",
|
|
79
|
-
timestampUtcMs: "2021-01-02T00:00:00.000Z",
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
index: 5,
|
|
83
|
-
skip: 1,
|
|
84
|
-
type: "OP_B_5",
|
|
85
|
-
timestampUtcMs: "2021-01-05T00:00:00.000Z",
|
|
86
|
-
},
|
|
87
|
-
]),
|
|
88
|
-
expected: [
|
|
89
|
-
{ index: 3, skip: 1, type: "OP_A_2" },
|
|
90
|
-
{ index: 4, skip: 0, type: "OP_B_3" },
|
|
91
|
-
{ index: 5, skip: 0, type: "OP_A_3" },
|
|
92
|
-
{ index: 6, skip: 0, type: "OP_A_4" },
|
|
93
|
-
{ index: 7, skip: 0, type: "OP_B_5" },
|
|
94
|
-
],
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
title: "case 3 (should not consider index when sorting operations)",
|
|
98
|
-
startIndex: { index: 3, skip: 1 },
|
|
99
|
-
operationsA: buildOperations([
|
|
100
|
-
{
|
|
101
|
-
index: 2,
|
|
102
|
-
skip: 0,
|
|
103
|
-
type: "OP_A_2",
|
|
104
|
-
timestampUtcMs: "2021-01-01T00:00:00.000Z",
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
index: 3,
|
|
108
|
-
skip: 0,
|
|
109
|
-
type: "OP_A_3",
|
|
110
|
-
timestampUtcMs: "2021-01-03T00:00:00.000Z",
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
index: 4,
|
|
114
|
-
skip: 0,
|
|
115
|
-
type: "OP_A_4",
|
|
116
|
-
timestampUtcMs: "2021-01-05T00:00:00.000Z",
|
|
117
|
-
},
|
|
118
|
-
]),
|
|
119
|
-
operationsB: buildOperations([
|
|
120
|
-
{
|
|
121
|
-
index: 3,
|
|
122
|
-
skip: 0,
|
|
123
|
-
type: "OP_B_3",
|
|
124
|
-
timestampUtcMs: "2021-01-02T00:00:00.000Z",
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
index: 5,
|
|
128
|
-
skip: 1,
|
|
129
|
-
type: "OP_B_5",
|
|
130
|
-
timestampUtcMs: "2021-01-04T00:00:00.000Z",
|
|
131
|
-
},
|
|
132
|
-
]),
|
|
133
|
-
expected: [
|
|
134
|
-
{ index: 3, skip: 1, type: "OP_A_2" },
|
|
135
|
-
{ index: 4, skip: 0, type: "OP_B_3" },
|
|
136
|
-
{ index: 5, skip: 0, type: "OP_A_3" },
|
|
137
|
-
{ index: 6, skip: 0, type: "OP_B_5" },
|
|
138
|
-
{ index: 7, skip: 0, type: "OP_A_4" },
|
|
139
|
-
],
|
|
140
|
-
},
|
|
141
|
-
];
|
|
142
|
-
it.each(scenarios)("should reshuffle the operations: $title", (testInput) => {
|
|
143
|
-
const result = reshuffleByTimestamp(testInput.startIndex, testInput.operationsA, testInput.operationsB);
|
|
144
|
-
expect(result.length).toBe(testInput.expected.length);
|
|
145
|
-
expect(result).toMatchObject(testInput.expected);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
//# sourceMappingURL=reshuffleByTimestamp.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reshuffleByTimestamp.test.js","sourceRoot":"","sources":["../../../test/document-helpers/reshuffleByTimestamp.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,MAAM,SAAS,GAAG;QAChB;YACE,KAAK,EAAE,QAAQ;YACf,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE;Y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AAS,CAAC,UAAU,EACpB,SAAS,CAAC,WAAW,EACrB,SAAS,CAAC,WAAW,CACtB,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtD,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reshuffleByTimestampAndIndex.test.d.ts","sourceRoot":"","sources":["../../../test/document-helpers/reshuffleByTimestampAndIndex.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { reshuffleByTimestampAndIndex } from "document-model/core";
|
|
3
|
-
import { buildOperations } from "./utils.js";
|
|
4
|
-
describe("reshuffleByTimestamp", () => {
|
|
5
|
-
const scenarios = [
|
|
6
|
-
{
|
|
7
|
-
title: "case 1",
|
|
8
|
-
startIndex: { index: 6, skip: 2 },
|
|
9
|
-
operationsA: buildOperations([
|
|
10
|
-
{
|
|
11
|
-
index: 4,
|
|
12
|
-
skip: 0,
|
|
13
|
-
type: "OP_A_4",
|
|
14
|
-
timestampUtcMs: "2021-01-01T00:00:00.000Z",
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
index: 5,
|
|
18
|
-
skip: 0,
|
|
19
|
-
type: "OP_A_5",
|
|
20
|
-
timestampUtcMs: "2021-01-04T00:00:00.000Z",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
index: 6,
|
|
24
|
-
skip: 0,
|
|
25
|
-
type: "OP_A_6",
|
|
26
|
-
timestampUtcMs: "2021-01-05T00:00:00.000Z",
|
|
27
|
-
},
|
|
28
|
-
]),
|
|
29
|
-
operationsB: buildOperations([
|
|
30
|
-
{
|
|
31
|
-
index: 4,
|
|
32
|
-
skip: 0,
|
|
33
|
-
type: "OP_B_4",
|
|
34
|
-
timestampUtcMs: "2021-01-02T00:00:00.000Z",
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
index: 5,
|
|
38
|
-
skip: 0,
|
|
39
|
-
type: "OP_B_5",
|
|
40
|
-
timestampUtcMs: "2021-01-03T00:00:00.000Z",
|
|
41
|
-
},
|
|
42
|
-
]),
|
|
43
|
-
expected: [
|
|
44
|
-
{ index: 6, skip: 2, type: "OP_A_4" },
|
|
45
|
-
{ index: 7, skip: 0, type: "OP_B_4" },
|
|
46
|
-
{ index: 8, skip: 0, type: "OP_B_5" },
|
|
47
|
-
{ index: 9, skip: 0, type: "OP_A_5" },
|
|
48
|
-
{ index: 10, skip: 0, type: "OP_A_6" },
|
|
49
|
-
],
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
title: "case 2 (remove skip from operations)",
|
|
53
|
-
startIndex: { index: 3, skip: 1 },
|
|
54
|
-
operationsA: buildOperations([
|
|
55
|
-
{
|
|
56
|
-
index: 2,
|
|
57
|
-
skip: 0,
|
|
58
|
-
type: "OP_A_2",
|
|
59
|
-
timestampUtcMs: "2021-01-01T00:00:00.000Z",
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
index: 3,
|
|
63
|
-
skip: 0,
|
|
64
|
-
type: "OP_A_3",
|
|
65
|
-
timestampUtcMs: "2021-01-03T00:00:00.000Z",
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
index: 4,
|
|
69
|
-
skip: 0,
|
|
70
|
-
type: "OP_A_4",
|
|
71
|
-
timestampUtcMs: "2021-01-04T00:00:00.000Z",
|
|
72
|
-
},
|
|
73
|
-
]),
|
|
74
|
-
operationsB: buildOperations([
|
|
75
|
-
{
|
|
76
|
-
index: 3,
|
|
77
|
-
skip: 0,
|
|
78
|
-
type: "OP_B_3",
|
|
79
|
-
timestampUtcMs: "2021-01-02T00:00:00.000Z",
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
index: 5,
|
|
83
|
-
skip: 1,
|
|
84
|
-
type: "OP_B_5",
|
|
85
|
-
timestampUtcMs: "2021-01-05T00:00:00.000Z",
|
|
86
|
-
},
|
|
87
|
-
]),
|
|
88
|
-
expected: [
|
|
89
|
-
{ index: 3, skip: 1, type: "OP_A_2" },
|
|
90
|
-
{ index: 4, skip: 0, type: "OP_B_3" },
|
|
91
|
-
{ index: 5, skip: 0, type: "OP_A_3" },
|
|
92
|
-
{ index: 6, skip: 0, type: "OP_A_4" },
|
|
93
|
-
{ index: 7, skip: 0, type: "OP_B_5" },
|
|
94
|
-
],
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
title: "case 3 (should consider index when sorting operations)",
|
|
98
|
-
startIndex: { index: 3, skip: 1 },
|
|
99
|
-
operationsA: buildOperations([
|
|
100
|
-
{
|
|
101
|
-
index: 2,
|
|
102
|
-
skip: 0,
|
|
103
|
-
type: "OP_A_2",
|
|
104
|
-
timestampUtcMs: "2021-01-01T00:00:00.000Z",
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
index: 3,
|
|
108
|
-
skip: 0,
|
|
109
|
-
type: "OP_A_3",
|
|
110
|
-
timestampUtcMs: "2021-01-03T00:00:00.000Z",
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
index: 4,
|
|
114
|
-
skip: 0,
|
|
115
|
-
type: "OP_A_4",
|
|
116
|
-
timestampUtcMs: "2021-01-05T00:00:00.000Z",
|
|
117
|
-
},
|
|
118
|
-
]),
|
|
119
|
-
operationsB: buildOperations([
|
|
120
|
-
{
|
|
121
|
-
index: 3,
|
|
122
|
-
skip: 0,
|
|
123
|
-
type: "OP_B_3",
|
|
124
|
-
timestampUtcMs: "2021-01-02T00:00:00.000Z",
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
index: 5,
|
|
128
|
-
skip: 1,
|
|
129
|
-
type: "OP_B_5",
|
|
130
|
-
timestampUtcMs: "2021-01-04T00:00:00.000Z",
|
|
131
|
-
},
|
|
132
|
-
]),
|
|
133
|
-
expected: [
|
|
134
|
-
{ index: 3, skip: 1, type: "OP_A_2" },
|
|
135
|
-
{ index: 4, skip: 0, type: "OP_B_3" },
|
|
136
|
-
{ index: 5, skip: 0, type: "OP_A_3" },
|
|
137
|
-
{ index: 6, skip: 0, type: "OP_A_4" },
|
|
138
|
-
{ index: 7, skip: 0, type: "OP_B_5" },
|
|
139
|
-
],
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
title: "case 4 (should consider index when sorting operations)",
|
|
143
|
-
startIndex: { index: 3, skip: 1 },
|
|
144
|
-
operationsA: buildOperations([
|
|
145
|
-
{
|
|
146
|
-
index: 2,
|
|
147
|
-
skip: 0,
|
|
148
|
-
type: "OP_A_2",
|
|
149
|
-
timestampUtcMs: "2021-01-01T00:00:00.000Z",
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
index: 3,
|
|
153
|
-
skip: 0,
|
|
154
|
-
type: "OP_A_3",
|
|
155
|
-
timestampUtcMs: "2021-01-02T00:00:00.000Z",
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
index: 4,
|
|
159
|
-
skip: 0,
|
|
160
|
-
type: "OP_A_4",
|
|
161
|
-
timestampUtcMs: "2021-01-03T00:00:00.000Z",
|
|
162
|
-
},
|
|
163
|
-
]),
|
|
164
|
-
operationsB: buildOperations([
|
|
165
|
-
{
|
|
166
|
-
index: 2,
|
|
167
|
-
skip: 0,
|
|
168
|
-
type: "OP_B_2",
|
|
169
|
-
timestampUtcMs: "2021-01-04T00:00:00.000Z",
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
index: 3,
|
|
173
|
-
skip: 0,
|
|
174
|
-
type: "OP_B_3",
|
|
175
|
-
timestampUtcMs: "2021-01-05T00:00:00.000Z",
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
index: 4,
|
|
179
|
-
skip: 0,
|
|
180
|
-
type: "OP_B_4",
|
|
181
|
-
timestampUtcMs: "2021-01-06T00:00:00.000Z",
|
|
182
|
-
},
|
|
183
|
-
]),
|
|
184
|
-
expected: [
|
|
185
|
-
{ index: 3, skip: 1, type: "OP_A_2" },
|
|
186
|
-
{ index: 4, skip: 0, type: "OP_B_2" },
|
|
187
|
-
{ index: 5, skip: 0, type: "OP_A_3" },
|
|
188
|
-
{ index: 6, skip: 0, type: "OP_B_3" },
|
|
189
|
-
{ index: 7, skip: 0, type: "OP_A_4" },
|
|
190
|
-
{ index: 8, skip: 0, type: "OP_B_4" },
|
|
191
|
-
],
|
|
192
|
-
},
|
|
193
|
-
];
|
|
194
|
-
it.each(scenarios)("should reshuffle the operations: $title", (testInput) => {
|
|
195
|
-
const result = reshuffleByTimestampAndIndex(testInput.startIndex, testInput.operationsA, testInput.operationsB);
|
|
196
|
-
expect(result.length).toBe(testInput.expected.length);
|
|
197
|
-
expect(result).toMatchObject(testInput.expected);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
//# sourceMappingURL=reshuffleByTimestampAndIndex.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reshuffleByTimestampAndIndex.test.js","sourceRoot":"","sources":["../../../test/document-helpers/reshuffleByTimestampAndIndex.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,MAAM,SAAS,GAAG;QAChB;YACE,KAAK,EAAE,QAAQ;YACf,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE;YACjC,WAAW,EAAE,eAAe,CAAC;gBAC3B;oBACE,KAAK,EAAE,CAAC;oBACR,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F,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,yCAAyC,EAAE,CAAC,SAAS,EAAE,EAAE;QAC1E,MAAM,MAAM,GAAG,4BAA4B,CACzC,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,WAAW,EACrB,SAAS,CAAC,WAAW,CACtB,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtD,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skipHeaderOperations.test.d.ts","sourceRoot":"","sources":["../../../test/document-helpers/skipHeaderOperations.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { deriveOperationId, generateId, skipHeaderOperations, } from "document-model/core";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
const TEST_DOC_ID = "test-doc-id";
|
|
4
|
-
const TEST_BRANCH = "main";
|
|
5
|
-
const TEST_SCOPE = "global";
|
|
6
|
-
const fakeOperation = (index, skip, type) => {
|
|
7
|
-
const timestamp = new Date().toISOString();
|
|
8
|
-
const actionId = generateId();
|
|
9
|
-
return {
|
|
10
|
-
id: deriveOperationId(TEST_DOC_ID, TEST_SCOPE, TEST_BRANCH, actionId),
|
|
11
|
-
index,
|
|
12
|
-
skip,
|
|
13
|
-
timestampUtcMs: timestamp,
|
|
14
|
-
hash: "123",
|
|
15
|
-
action: {
|
|
16
|
-
id: actionId,
|
|
17
|
-
timestampUtcMs: timestamp,
|
|
18
|
-
type,
|
|
19
|
-
input: {},
|
|
20
|
-
scope: "global",
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
describe("skipHeaderOperations", () => {
|
|
25
|
-
const op000 = fakeOperation(0, 0, "OP_0");
|
|
26
|
-
const op101 = fakeOperation(1, 0, "OP_1");
|
|
27
|
-
const op202 = fakeOperation(2, 0, "OP_2");
|
|
28
|
-
const op303 = fakeOperation(3, 0, "OP_3");
|
|
29
|
-
const op323 = fakeOperation(3, 2, "OP_3");
|
|
30
|
-
const op404 = fakeOperation(4, 0, "OP_4");
|
|
31
|
-
const scenarios = [
|
|
32
|
-
{
|
|
33
|
-
title: "case 1: should use nextIndex and skip 1 operation",
|
|
34
|
-
operations: [op000, op101, op202],
|
|
35
|
-
skipHeaderOperation: { skip: 1, type: "SKIP_HEADER" },
|
|
36
|
-
expected: [op000, op101],
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
title: "case 2: should use nextIndex and skip 2 operations",
|
|
40
|
-
operations: [op000, op101, op202, op303],
|
|
41
|
-
skipHeaderOperation: { skip: 2, type: "SKIP_HEADER" },
|
|
42
|
-
expected: [op000, op101],
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
title: "case 3: should use current index from skipHeaderOperation and skip 3 operations",
|
|
46
|
-
operations: [op000, op101, op202, op303],
|
|
47
|
-
skipHeaderOperation: { skip: 3, index: 4, type: "SKIP_HEADER" },
|
|
48
|
-
expected: [op000],
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
title: "case 4: should return garbage collected operations",
|
|
52
|
-
operations: [op000, op101, op202, op323, op404],
|
|
53
|
-
skipHeaderOperation: { skip: 1, index: 5, type: "SKIP_HEADER" },
|
|
54
|
-
expected: [op000, op323],
|
|
55
|
-
},
|
|
56
|
-
];
|
|
57
|
-
it.each(scenarios)("should skip header operations: $title", (testInput) => {
|
|
58
|
-
const result = skipHeaderOperations(testInput.operations, testInput.skipHeaderOperation);
|
|
59
|
-
expect(result.length).toBe(testInput.expected.length);
|
|
60
|
-
expect(result).toMatchObject(testInput.expected);
|
|
61
|
-
});
|
|
62
|
-
it("should throw an error if try to use an index < lastIndex", () => {
|
|
63
|
-
const operations = [
|
|
64
|
-
fakeOperation(0, 0, "OP_0"),
|
|
65
|
-
fakeOperation(1, 0, "OP_1"),
|
|
66
|
-
fakeOperation(2, 0, "OP_2"),
|
|
67
|
-
];
|
|
68
|
-
const skipHeaderOperation = { skip: 1, index: 1, type: "SKIP_HEADER" };
|
|
69
|
-
expect(() => skipHeaderOperations(operations, skipHeaderOperation)).toThrow("The skip header operation index must be greater than or equal to 2");
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
//# sourceMappingURL=skipHeaderOperations.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skipHeaderOperations.test.js","sourceRoot":"","sources":["../../../test/document-helpers/skipHeaderOperations.test.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,MAAM,UAAU,GAAG,QAAQ,CAAC;AAE5B,MAAM,aAAa,GAAG,CACpB,KAAa,EACb,IAAY,EACZ,IAAY,EACD,EAAE;IACb,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,UAAU,EAAE,CAAC;IAC9B,OAAO;QACL,EAAE,EAAE,iBAAiB,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,CAAC;QACrE,KAAK;QACL,IAAI;QACJ,cAAc,EAAE,SAAS;QACzB,IAAI,EAAE,KAAK;QACX,MAAM,EAAE;YACN,EAAE,EAAE,QAAQ;YACZ,cAAc,EAAE,SAAS;YACzB,IAAI;YACJ,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,QAAQ;SAChB;KACF,CAAC;AACJ,CA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