@shaxpir/duiduidui-models 1.0.1 → 1.1.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/dist/models/{content/ArrayView.d.ts → ArrayView.d.ts} +1 -1
- package/dist/models/{content/ArrayView.js → ArrayView.js} +14 -14
- package/dist/models/BayesianScore.d.ts +9 -0
- package/dist/models/BayesianScore.js +27 -0
- package/dist/models/{markup/ChangeModel.d.ts → ChangeModel.d.ts} +2 -3
- package/dist/models/{markup/ChangeModel.js → ChangeModel.js} +20 -10
- package/dist/models/{content/Content.d.ts → Content.d.ts} +9 -10
- package/dist/models/{content/Content.js → Content.js} +2 -6
- package/dist/models/{content/ContentKind.d.ts → ContentKind.d.ts} +3 -0
- package/dist/models/{content/ContentKind.js → ContentKind.js} +5 -1
- package/dist/models/{content/Device.d.ts → Device.d.ts} +15 -7
- package/dist/models/{content/Device.js → Device.js} +14 -18
- package/dist/models/Hanzi.d.ts +15 -0
- package/dist/models/{content/Manifest.d.ts → Manifest.d.ts} +7 -3
- package/dist/models/{content/Manifest.js → Manifest.js} +12 -8
- package/dist/models/{content/Media.d.ts → Media.d.ts} +2 -3
- package/dist/models/{content/Media.js → Media.js} +4 -5
- package/dist/models/{content/Metric.d.ts → Metric.d.ts} +2 -3
- package/dist/models/{content/Metric.js → Metric.js} +18 -20
- package/dist/models/{content/Model.d.ts → Model.d.ts} +3 -5
- package/dist/models/{content/Model.js → Model.js} +5 -6
- package/dist/models/{markup/Operation.d.ts → Operation.d.ts} +2 -5
- package/dist/models/{markup/Operation.js → Operation.js} +30 -25
- package/dist/models/Phrase.d.ts +39 -0
- package/dist/models/{content/Profile.d.ts → Profile.d.ts} +1 -2
- package/dist/models/{content/Profile.js → Profile.js} +7 -9
- package/dist/models/Progress.d.ts +26 -0
- package/dist/models/Progress.js +39 -0
- package/dist/models/Review.d.ts +14 -0
- package/dist/models/{content/Session.d.ts → Session.d.ts} +7 -15
- package/dist/models/Session.js +103 -0
- package/dist/models/Term.d.ts +36 -0
- package/dist/models/Term.js +82 -0
- package/dist/models/User.d.ts +32 -0
- package/dist/models/User.js +65 -0
- package/dist/models/Workspace.d.ts +37 -0
- package/dist/models/Workspace.js +94 -0
- package/dist/models/index.d.ts +22 -2
- package/dist/models/index.js +22 -2
- package/dist/repo/PermissiveJson1.d.ts +16 -16
- package/dist/repo/PermissiveJson1.js +17 -7
- package/dist/repo/ShareSync.d.ts +6 -6
- package/dist/repo/ShareSync.js +26 -19
- package/dist/repo/index.d.ts +1 -0
- package/dist/repo/index.js +1 -0
- package/dist/util/index.d.ts +0 -6
- package/dist/util/index.js +0 -6
- package/lib/models/{content/ArrayView.ts → ArrayView.ts} +2 -2
- package/lib/models/BayesianScore.ts +32 -0
- package/lib/models/{markup/ChangeModel.ts → ChangeModel.ts} +3 -4
- package/lib/models/{content/Content.ts → Content.ts} +15 -18
- package/lib/models/{content/ContentKind.ts → ContentKind.ts} +6 -1
- package/lib/models/{content/Device.ts → Device.ts} +26 -22
- package/lib/models/Hanzi.ts +16 -0
- package/lib/models/{content/Manifest.ts → Manifest.ts} +15 -6
- package/lib/models/{content/Media.ts → Media.ts} +3 -4
- package/lib/models/Metric.ts +233 -0
- package/lib/models/{content/Model.ts → Model.ts} +4 -6
- package/lib/models/{markup/Operation.ts → Operation.ts} +6 -16
- package/lib/models/{content/Permissions.ts → Permissions.ts} +0 -2
- package/lib/models/Phrase.ts +53 -0
- package/lib/models/{content/Profile.ts → Profile.ts} +4 -6
- package/lib/models/Progress.ts +66 -0
- package/lib/models/Review.ts +18 -0
- package/lib/models/Session.ts +140 -0
- package/lib/models/Term.ts +139 -0
- package/lib/models/User.ts +97 -0
- package/lib/models/Workspace.ts +129 -0
- package/lib/models/index.ts +22 -2
- package/lib/repo/ShareSync.ts +9 -13
- package/lib/repo/index.ts +1 -0
- package/lib/util/index.ts +0 -6
- package/package.json +4 -15
- package/dist/models/OutboundMessage.d.ts +0 -18
- package/dist/models/OutboundMessage.js +0 -25
- package/dist/models/content/Activity.d.ts +0 -10
- package/dist/models/content/Billing.d.ts +0 -144
- package/dist/models/content/Billing.js +0 -418
- package/dist/models/content/Book.d.ts +0 -77
- package/dist/models/content/Book.js +0 -407
- package/dist/models/content/Category.d.ts +0 -16
- package/dist/models/content/Category.js +0 -20
- package/dist/models/content/Checkpointable.d.ts +0 -21
- package/dist/models/content/Checkpointable.js +0 -156
- package/dist/models/content/Comment.d.ts +0 -19
- package/dist/models/content/Comment.js +0 -53
- package/dist/models/content/ConceptArt.d.ts +0 -31
- package/dist/models/content/ConceptArt.js +0 -84
- package/dist/models/content/Context.d.ts +0 -28
- package/dist/models/content/Context.js +0 -162
- package/dist/models/content/DevEnv.d.ts +0 -5
- package/dist/models/content/DevEnv.js +0 -9
- package/dist/models/content/Dictionary.d.ts +0 -31
- package/dist/models/content/Dictionary.js +0 -5
- package/dist/models/content/DictionaryEntry.d.ts +0 -20
- package/dist/models/content/DictionaryEntry.js +0 -2
- package/dist/models/content/ElasticModel.d.ts +0 -149
- package/dist/models/content/ElasticModel.js +0 -179
- package/dist/models/content/Environment.d.ts +0 -61
- package/dist/models/content/Environment.js +0 -124
- package/dist/models/content/ExportOptions.d.ts +0 -64
- package/dist/models/content/ExportOptions.js +0 -213
- package/dist/models/content/Folder.d.ts +0 -16
- package/dist/models/content/Folder.js +0 -33
- package/dist/models/content/Fragment.d.ts +0 -54
- package/dist/models/content/Fragment.js +0 -181
- package/dist/models/content/Hanzi.d.ts +0 -21
- package/dist/models/content/HighlightRule.d.ts +0 -9
- package/dist/models/content/HighlightRule.js +0 -2
- package/dist/models/content/Migration.d.ts +0 -68
- package/dist/models/content/Migration.js +0 -155
- package/dist/models/content/Phrase.d.ts +0 -8
- package/dist/models/content/Placeholder.d.ts +0 -8
- package/dist/models/content/Placeholder.js +0 -36
- package/dist/models/content/RichText.d.ts +0 -58
- package/dist/models/content/RichText.js +0 -79
- package/dist/models/content/Session.js +0 -173
- package/dist/models/content/Speech.d.ts +0 -67
- package/dist/models/content/Speech.js +0 -97
- package/dist/models/content/Stub.d.ts +0 -24
- package/dist/models/content/Stub.js +0 -179
- package/dist/models/content/Time.d.ts +0 -56
- package/dist/models/content/Time.js +0 -295
- package/dist/models/content/User.d.ts +0 -36
- package/dist/models/content/User.js +0 -95
- package/dist/models/content/Workspace.d.ts +0 -71
- package/dist/models/content/Workspace.js +0 -237
- package/dist/models/content/index.d.ts +0 -17
- package/dist/models/content/index.js +0 -34
- package/dist/models/legacy/LegacyBodyFormat.d.ts +0 -9
- package/dist/models/legacy/LegacyBodyFormat.js +0 -2
- package/dist/models/legacy/LegacyComment.d.ts +0 -12
- package/dist/models/legacy/LegacyComment.js +0 -2
- package/dist/models/legacy/LegacyContent.d.ts +0 -53
- package/dist/models/legacy/LegacyContent.js +0 -55
- package/dist/models/legacy/LegacyConversion.d.ts +0 -55
- package/dist/models/legacy/LegacyConversion.js +0 -401
- package/dist/models/legacy/LegacyFragment.d.ts +0 -21
- package/dist/models/legacy/LegacyFragment.js +0 -2
- package/dist/models/legacy/LegacyLocator.d.ts +0 -8
- package/dist/models/legacy/LegacyLocator.js +0 -31
- package/dist/models/legacy/LegacyOutboundMessage.d.ts +0 -16
- package/dist/models/legacy/LegacyOutboundMessage.js +0 -13
- package/dist/models/legacy/LegacyPicture.d.ts +0 -14
- package/dist/models/legacy/LegacyPicture.js +0 -2
- package/dist/models/legacy/LegacyProfile.d.ts +0 -9
- package/dist/models/legacy/LegacyProfile.js +0 -2
- package/dist/models/legacy/LegacySession.d.ts +0 -41
- package/dist/models/legacy/LegacySession.js +0 -35
- package/dist/models/legacy/LegacyStory.d.ts +0 -23
- package/dist/models/legacy/LegacyStory.js +0 -2
- package/dist/models/legacy/LegacyStub.d.ts +0 -15
- package/dist/models/legacy/LegacyStub.js +0 -2
- package/dist/models/legacy/LegacyTransaction.d.ts +0 -14
- package/dist/models/legacy/LegacyTransaction.js +0 -49
- package/dist/models/legacy/LegacyUser.d.ts +0 -28
- package/dist/models/legacy/LegacyUser.js +0 -32
- package/dist/models/legacy/LegacyWorkspace.d.ts +0 -23
- package/dist/models/legacy/LegacyWorkspace.js +0 -6
- package/dist/models/legacy/index.d.ts +0 -15
- package/dist/models/legacy/index.js +0 -32
- package/dist/models/markup/BodyFormat.d.ts +0 -14
- package/dist/models/markup/BodyFormat.js +0 -190
- package/dist/models/markup/DeltaOps.d.ts +0 -5
- package/dist/models/markup/DeltaOps.js +0 -74
- package/dist/models/markup/HtmlMarkup.d.ts +0 -4
- package/dist/models/markup/HtmlMarkup.js +0 -21
- package/dist/models/markup/index.d.ts +0 -4
- package/dist/models/markup/index.js +0 -21
- package/dist/util/Async.d.ts +0 -8
- package/dist/util/Async.js +0 -18
- package/dist/util/Base62.d.ts +0 -6
- package/dist/util/Base62.js +0 -47
- package/dist/util/BinarySearch.d.ts +0 -7
- package/dist/util/BinarySearch.js +0 -46
- package/dist/util/CachingHasher.d.ts +0 -8
- package/dist/util/CachingHasher.js +0 -41
- package/dist/util/Color.d.ts +0 -32
- package/dist/util/Color.js +0 -204
- package/dist/util/Dispatch.d.ts +0 -15
- package/dist/util/Dispatch.js +0 -79
- package/dist/util/EditDistance.d.ts +0 -13
- package/dist/util/EditDistance.js +0 -184
- package/dist/util/NumberFormat.d.ts +0 -14
- package/dist/util/NumberFormat.js +0 -224
- package/dist/util/Struct.d.ts +0 -4
- package/dist/util/Struct.js +0 -15
- package/dist/util/Template.d.ts +0 -16
- package/dist/util/Template.js +0 -128
- package/dist/util/Text.d.ts +0 -45
- package/dist/util/Text.js +0 -243
- package/dist/util/Tuples.d.ts +0 -9
- package/dist/util/Tuples.js +0 -135
- package/dist/util/Validate.d.ts +0 -4
- package/dist/util/Validate.js +0 -11
- package/dist/util/Vocabulary.d.ts +0 -3
- package/dist/util/Vocabulary.js +0 -35
- package/lib/models/content/Billing.ts +0 -558
- package/lib/models/content/DevEnv.ts +0 -5
- package/lib/models/content/DictionaryEntry.ts +0 -22
- package/lib/models/content/Hanzi.ts +0 -25
- package/lib/models/content/Phrase.ts +0 -10
- package/lib/models/content/Time.ts +0 -328
- package/lib/models/content/User.ts +0 -130
- package/lib/models/content/index.ts +0 -19
- package/lib/models/markup/DeltaOps.ts +0 -71
- package/lib/models/markup/index.ts +0 -6
- package/lib/util/Base62.ts +0 -47
- package/lib/util/CachingHasher.ts +0 -38
- package/lib/util/Dispatch.ts +0 -92
- package/lib/util/NumberFormat.ts +0 -194
- package/lib/util/Struct.ts +0 -14
- package/lib/util/Tuples.ts +0 -131
- /package/dist/models/{content/GeoLocation.d.ts → GeoLocation.d.ts} +0 -0
- /package/dist/models/{content/GeoLocation.js → GeoLocation.js} +0 -0
- /package/dist/models/{content/Hanzi.js → Hanzi.js} +0 -0
- /package/dist/models/{content/Permissions.d.ts → Permissions.d.ts} +0 -0
- /package/dist/models/{content/Permissions.js → Permissions.js} +0 -0
- /package/dist/models/{content/Phrase.js → Phrase.js} +0 -0
- /package/dist/models/{content/Activity.js → Review.js} +0 -0
- /package/dist/{models/markup → repo}/TextEditOps.d.ts +0 -0
- /package/dist/{models/markup → repo}/TextEditOps.js +0 -0
- /package/lib/models/{content/GeoLocation.ts → GeoLocation.ts} +0 -0
- /package/lib/{models/markup → repo}/TextEditOps.ts +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ArrayView = void 0;
|
|
4
|
-
const
|
|
5
|
-
const Operation_1 = require("
|
|
4
|
+
const shaxpir_common_1 = require("@shaxpir/shaxpir-common");
|
|
5
|
+
const Operation_1 = require("./Operation");
|
|
6
6
|
class ArrayView {
|
|
7
7
|
constructor(content, path) {
|
|
8
8
|
this.content = content;
|
|
@@ -18,11 +18,11 @@ class ArrayView {
|
|
|
18
18
|
}
|
|
19
19
|
get values() {
|
|
20
20
|
this.content.checkDisposed("ArrayView.values");
|
|
21
|
-
return
|
|
21
|
+
return shaxpir_common_1.Struct.clone(this.root);
|
|
22
22
|
}
|
|
23
23
|
get(idx) {
|
|
24
24
|
this.content.checkDisposed("ArrayView.get");
|
|
25
|
-
return
|
|
25
|
+
return shaxpir_common_1.Struct.clone(this.root[idx]);
|
|
26
26
|
}
|
|
27
27
|
indexOf(value) {
|
|
28
28
|
this.content.checkDisposed("ArrayView.indexOf");
|
|
@@ -66,7 +66,7 @@ class ArrayView {
|
|
|
66
66
|
const array = Operation_1.JsonPathSelect.getValueAtPath(this.content.doc, this.path);
|
|
67
67
|
for (let i = 0; i < array.length; i++) {
|
|
68
68
|
if (predicate(array[i])) {
|
|
69
|
-
const pathToElement =
|
|
69
|
+
const pathToElement = shaxpir_common_1.Struct.clone(this.path);
|
|
70
70
|
pathToElement.push(i);
|
|
71
71
|
batch.removeValueAtPath(pathToElement);
|
|
72
72
|
foundMatch = true;
|
|
@@ -115,7 +115,7 @@ class ArrayView {
|
|
|
115
115
|
}
|
|
116
116
|
removeAt(index) {
|
|
117
117
|
this.content.checkDisposed("ArrayView.removeAt");
|
|
118
|
-
const pathToElement =
|
|
118
|
+
const pathToElement = shaxpir_common_1.Struct.clone(this.path);
|
|
119
119
|
pathToElement.push(index);
|
|
120
120
|
const batch = new Operation_1.BatchOperation(this.content);
|
|
121
121
|
batch.removeValueAtPath(pathToElement);
|
|
@@ -124,8 +124,8 @@ class ArrayView {
|
|
|
124
124
|
move(originIndex, destinationIndex) {
|
|
125
125
|
this.content.checkDisposed("ArrayView.move");
|
|
126
126
|
if (originIndex != destinationIndex) {
|
|
127
|
-
const originPath =
|
|
128
|
-
const destinationPath =
|
|
127
|
+
const originPath = shaxpir_common_1.Struct.clone(this.path);
|
|
128
|
+
const destinationPath = shaxpir_common_1.Struct.clone(this.path);
|
|
129
129
|
originPath.push(originIndex);
|
|
130
130
|
destinationPath.push(destinationIndex);
|
|
131
131
|
const batch = new Operation_1.BatchOperation(this.content);
|
|
@@ -135,11 +135,11 @@ class ArrayView {
|
|
|
135
135
|
}
|
|
136
136
|
removeObjectPropertyAtIndex(index, fieldName) {
|
|
137
137
|
this.content.checkDisposed("ArrayView.setObjectValueAtIndex");
|
|
138
|
-
const pathToElement =
|
|
138
|
+
const pathToElement = shaxpir_common_1.Struct.clone(this.path);
|
|
139
139
|
pathToElement.push(index);
|
|
140
140
|
const element = Operation_1.JsonPathSelect.getValueAtPath(this.content.doc, pathToElement);
|
|
141
141
|
if (element.hasOwnProperty(fieldName)) {
|
|
142
|
-
const pathToProperty =
|
|
142
|
+
const pathToProperty = shaxpir_common_1.Struct.clone(this.path);
|
|
143
143
|
pathToProperty.push(fieldName);
|
|
144
144
|
const batch = new Operation_1.BatchOperation(this.content);
|
|
145
145
|
batch.removeValueAtPath(pathToProperty);
|
|
@@ -148,11 +148,11 @@ class ArrayView {
|
|
|
148
148
|
}
|
|
149
149
|
setObjectValueAtIndex(index, fieldName, newValue) {
|
|
150
150
|
this.content.checkDisposed("ArrayView.setObjectValueAtIndex");
|
|
151
|
-
const pathToElement =
|
|
151
|
+
const pathToElement = shaxpir_common_1.Struct.clone(this.path);
|
|
152
152
|
pathToElement.push(index);
|
|
153
153
|
pathToElement.push(fieldName);
|
|
154
154
|
const prevValue = Operation_1.JsonPathSelect.getValueAtPath(this.content.doc, pathToElement);
|
|
155
|
-
if (!
|
|
155
|
+
if (!shaxpir_common_1.Struct.equals(prevValue, newValue)) {
|
|
156
156
|
const batch = new Operation_1.BatchOperation(this.content);
|
|
157
157
|
batch.setPathValue(pathToElement, newValue);
|
|
158
158
|
batch.commit();
|
|
@@ -160,11 +160,11 @@ class ArrayView {
|
|
|
160
160
|
}
|
|
161
161
|
editObjectTextValueAtIndex(index, fieldName, newValue) {
|
|
162
162
|
this.content.checkDisposed("ArrayView.editObjectTextValueAtIndex");
|
|
163
|
-
const pathToElement =
|
|
163
|
+
const pathToElement = shaxpir_common_1.Struct.clone(this.path);
|
|
164
164
|
pathToElement.push(index);
|
|
165
165
|
pathToElement.push(fieldName);
|
|
166
166
|
const prevValue = Operation_1.JsonPathSelect.getValueAtPath(this.content.doc, pathToElement);
|
|
167
|
-
if (!
|
|
167
|
+
if (!shaxpir_common_1.Struct.equals(prevValue, newValue)) {
|
|
168
168
|
const batch = new Operation_1.BatchOperation(this.content);
|
|
169
169
|
batch.editPathText(pathToElement, newValue);
|
|
170
170
|
batch.commit();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReviewResult } from "./Review";
|
|
2
|
+
export interface BayesianScore {
|
|
3
|
+
alpha: number;
|
|
4
|
+
beta: number;
|
|
5
|
+
theta: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class BayesianScoreModel {
|
|
8
|
+
static apply(prevScore: BayesianScore, result: ReviewResult, weight: number): BayesianScore;
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BayesianScoreModel = void 0;
|
|
4
|
+
const shaxpir_common_1 = require("@shaxpir/shaxpir-common");
|
|
5
|
+
class BayesianScoreModel {
|
|
6
|
+
static apply(prevScore, result, weight) {
|
|
7
|
+
if (isNaN(weight) || !isFinite(weight) || weight < 0 || weight > 1) {
|
|
8
|
+
throw new Error(`illegal weight value: ${weight}`);
|
|
9
|
+
}
|
|
10
|
+
const nextScore = shaxpir_common_1.Struct.clone(prevScore);
|
|
11
|
+
if (result == 'EASY') {
|
|
12
|
+
nextScore.alpha += (weight * 1.0);
|
|
13
|
+
}
|
|
14
|
+
else if (result == 'GOOD') {
|
|
15
|
+
nextScore.alpha += (weight * 0.7);
|
|
16
|
+
}
|
|
17
|
+
else if (result == 'HARD') {
|
|
18
|
+
nextScore.beta += (weight * 0.3);
|
|
19
|
+
}
|
|
20
|
+
else if (result == 'FAIL') {
|
|
21
|
+
nextScore.beta += (weight * 1.0);
|
|
22
|
+
}
|
|
23
|
+
nextScore.theta = nextScore.alpha / (nextScore.alpha + nextScore.beta);
|
|
24
|
+
return nextScore;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.BayesianScoreModel = BayesianScoreModel;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Op as DeltaOp } from "@shaxpir/quill-delta";
|
|
2
1
|
import { Operation } from "json-diff-ts";
|
|
3
|
-
import { Model } from "
|
|
2
|
+
import { Model } from "./Model";
|
|
4
3
|
export interface ChangeItem {
|
|
5
4
|
type: Operation;
|
|
6
5
|
path: string;
|
|
@@ -11,7 +10,7 @@ export interface ModelChange {
|
|
|
11
10
|
local: boolean;
|
|
12
11
|
model: Model;
|
|
13
12
|
items: ChangeItem[];
|
|
14
|
-
op:
|
|
13
|
+
op: any[];
|
|
15
14
|
}
|
|
16
15
|
export declare class Changes {
|
|
17
16
|
static withPathPrefix(change: ModelChange, prefix: string): boolean;
|
|
@@ -15,17 +15,27 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.ChangeModel = exports.Changes = void 0;
|
|
37
|
+
const shaxpir_common_1 = require("@shaxpir/shaxpir-common");
|
|
27
38
|
const Changesets = __importStar(require("json-diff-ts"));
|
|
28
|
-
const Tuples_1 = require("../../util/Tuples");
|
|
29
39
|
class Changes {
|
|
30
40
|
static withPathPrefix(change, prefix) {
|
|
31
41
|
let matchingItems = Changes.havingPathPrefix(change, prefix);
|
|
@@ -63,7 +73,7 @@ class ChangeModel {
|
|
|
63
73
|
let valueType = diffItem.valueType;
|
|
64
74
|
let key = diffItem.key;
|
|
65
75
|
if (valueType === 'Object' || valueType == 'Array') {
|
|
66
|
-
let tuples =
|
|
76
|
+
let tuples = shaxpir_common_1.Tuples.of(value);
|
|
67
77
|
let fullPath = path;
|
|
68
78
|
if (/^\d+$/.test(key) && !path.endsWith('[' + key + ']')) {
|
|
69
79
|
fullPath = path + '[' + key + ']';
|
|
@@ -82,7 +92,7 @@ class ChangeModel {
|
|
|
82
92
|
else {
|
|
83
93
|
for (let j = 0; j < tuples.length; j++) {
|
|
84
94
|
let tuple = tuples[j];
|
|
85
|
-
let fullTuplePath =
|
|
95
|
+
let fullTuplePath = shaxpir_common_1.Tuples.stringifyPath(fullPath, tuple.path);
|
|
86
96
|
if (type == 'REMOVE') {
|
|
87
97
|
changeItems.push({ type: type, path: fullTuplePath, oldValue: tuple.val });
|
|
88
98
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
/// <reference path="../../../decs.d.ts" />
|
|
2
1
|
import { Doc } from '@shaxpir/sharedb/lib/client';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { CompactDateTime, MultiTime } from '@shaxpir/shaxpir-common';
|
|
3
|
+
import { ShareSync } from '../repo';
|
|
5
4
|
import { ContentKind } from './ContentKind';
|
|
6
5
|
import { DevicePayload } from './Device';
|
|
7
|
-
import {
|
|
6
|
+
import { MediaPayload } from './Media';
|
|
7
|
+
import { MetricPayload } from './Metric';
|
|
8
8
|
import { Model } from './Model';
|
|
9
|
-
import { PhrasePayload } from './Phrase';
|
|
10
9
|
import { ProfilePayload } from "./Profile";
|
|
11
|
-
import {
|
|
10
|
+
import { ProgressPayload } from './Progress';
|
|
11
|
+
import { SessionPayload } from './Session';
|
|
12
|
+
import { TermPayload } from './Term';
|
|
12
13
|
import { UserPayload } from './User';
|
|
13
|
-
import {
|
|
14
|
+
import { WorkspacePayload } from './Workspace';
|
|
14
15
|
declare enum ContentIdBrand {
|
|
15
16
|
}
|
|
16
17
|
declare enum ContentRefBrand {
|
|
@@ -29,17 +30,15 @@ export interface ContentBody {
|
|
|
29
30
|
export interface ContentMeta {
|
|
30
31
|
ref: ContentRef;
|
|
31
32
|
kind: ContentKind;
|
|
32
|
-
is_head: boolean;
|
|
33
33
|
id: ContentId;
|
|
34
34
|
owner: ContentId;
|
|
35
35
|
created_at: MultiTime;
|
|
36
36
|
updated_at: MultiTime;
|
|
37
37
|
}
|
|
38
|
-
export type ContentPayload =
|
|
38
|
+
export type ContentPayload = DevicePayload | MediaPayload | MetricPayload | ProfilePayload | ProgressPayload | SessionPayload | TermPayload | UserPayload | WorkspacePayload;
|
|
39
39
|
export declare abstract class Content extends Model {
|
|
40
40
|
static ID_LENGTH: number;
|
|
41
41
|
constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
|
|
42
|
-
get isHead(): boolean;
|
|
43
42
|
get meta(): ContentMeta;
|
|
44
43
|
get payload(): ContentPayload;
|
|
45
44
|
cloneContentBody(): ContentBody;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Content = void 0;
|
|
4
|
-
const
|
|
4
|
+
const shaxpir_common_1 = require("@shaxpir/shaxpir-common");
|
|
5
5
|
const Model_1 = require("./Model");
|
|
6
6
|
var ContentIdBrand;
|
|
7
7
|
(function (ContentIdBrand) {
|
|
@@ -13,10 +13,6 @@ class Content extends Model_1.Model {
|
|
|
13
13
|
constructor(doc, shouldAcquire, shareSync) {
|
|
14
14
|
super(doc, shouldAcquire, shareSync);
|
|
15
15
|
}
|
|
16
|
-
get isHead() {
|
|
17
|
-
this.checkDisposed("Content.isHead");
|
|
18
|
-
return this.meta.is_head;
|
|
19
|
-
}
|
|
20
16
|
get meta() {
|
|
21
17
|
this.checkDisposed("Content.meta");
|
|
22
18
|
return this.doc.data.meta;
|
|
@@ -28,7 +24,7 @@ class Content extends Model_1.Model {
|
|
|
28
24
|
cloneContentBody() {
|
|
29
25
|
this.checkDisposed("Content.cloneContentBody");
|
|
30
26
|
if (this.exists()) {
|
|
31
|
-
return
|
|
27
|
+
return shaxpir_common_1.Struct.clone(this.doc.data);
|
|
32
28
|
}
|
|
33
29
|
else {
|
|
34
30
|
return null;
|
|
@@ -3,14 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ContentKind = void 0;
|
|
4
4
|
var ContentKind;
|
|
5
5
|
(function (ContentKind) {
|
|
6
|
-
//
|
|
6
|
+
// No models yet for these, but they're definitely coming
|
|
7
7
|
ContentKind["BILLING"] = "billing";
|
|
8
|
+
// These are all the current Content subclasses
|
|
8
9
|
ContentKind["DEVICE"] = "device";
|
|
9
10
|
ContentKind["METRIC"] = "metric";
|
|
10
11
|
ContentKind["PROFILE"] = "profile";
|
|
12
|
+
ContentKind["PROGRESS"] = "progress";
|
|
11
13
|
ContentKind["SESSION"] = "session";
|
|
14
|
+
ContentKind["TERM"] = "term";
|
|
12
15
|
ContentKind["USER"] = "user";
|
|
13
16
|
ContentKind["MEDIA"] = "media";
|
|
17
|
+
ContentKind["WORKSPACE"] = "workspace";
|
|
14
18
|
// These are used in the ShareDB system, but for internal bookkeeping, not for Content subclasses.
|
|
15
19
|
ContentKind["MANIFEST"] = "manifest";
|
|
16
20
|
})(ContentKind || (exports.ContentKind = ContentKind = {}));
|
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
/// <reference path="../../../decs.d.ts" />
|
|
2
1
|
import { Doc } from '@shaxpir/sharedb/lib/client';
|
|
3
|
-
import {
|
|
2
|
+
import { CompactDateTime } from "@shaxpir/shaxpir-common";
|
|
3
|
+
import { ShareSync } from '../repo';
|
|
4
4
|
import { Content, ContentBody, ContentId, ContentMeta } from "./Content";
|
|
5
|
-
import { CompactDateTime } from './Time';
|
|
6
5
|
export interface LastSync {
|
|
7
|
-
at_utc_time: CompactDateTime;
|
|
6
|
+
at_utc_time: CompactDateTime | null;
|
|
7
|
+
}
|
|
8
|
+
export interface TagFilterConfig {
|
|
9
|
+
any?: string[];
|
|
10
|
+
all?: string[];
|
|
11
|
+
none?: string[];
|
|
8
12
|
}
|
|
9
13
|
export interface DevicePayload {
|
|
10
14
|
last_sync?: LastSync;
|
|
15
|
+
chinese_font?: string;
|
|
16
|
+
raw_search_text?: string;
|
|
17
|
+
star_filter?: boolean;
|
|
18
|
+
tag_filter?: TagFilterConfig;
|
|
11
19
|
}
|
|
12
20
|
export interface DeviceBody extends ContentBody {
|
|
13
21
|
meta: ContentMeta;
|
|
14
22
|
payload: DevicePayload;
|
|
15
23
|
}
|
|
16
24
|
export declare class Device extends Content {
|
|
17
|
-
static
|
|
18
|
-
static create(userId: ContentId, deviceId: ContentId, theme: string, typeface: string, typesize: string): Device;
|
|
25
|
+
static create(userId: ContentId, deviceId: ContentId): Device;
|
|
19
26
|
constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
|
|
20
27
|
get payload(): DevicePayload;
|
|
21
28
|
get lastSyncAtUtcTime(): CompactDateTime;
|
|
22
29
|
setLastSyncAtUtcTime(value: CompactDateTime): void;
|
|
23
|
-
|
|
30
|
+
get chineseFont(): string;
|
|
31
|
+
setChineseFont(value: string): void;
|
|
24
32
|
}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Device = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const Operation_1 = require("../markup/Operation");
|
|
4
|
+
const shaxpir_common_1 = require("@shaxpir/shaxpir-common");
|
|
5
|
+
const repo_1 = require("../repo");
|
|
7
6
|
const Content_1 = require("./Content");
|
|
8
7
|
const ContentKind_1 = require("./ContentKind");
|
|
9
|
-
const
|
|
8
|
+
const Operation_1 = require("./Operation");
|
|
10
9
|
class Device extends Content_1.Content {
|
|
11
|
-
static
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
static create(userId, deviceId, theme, typeface, typesize) {
|
|
15
|
-
const now = Time_1.MultiClock.now();
|
|
16
|
-
return ShareSync_1.ShareSyncFactory.get().createContent({
|
|
10
|
+
static create(userId, deviceId) {
|
|
11
|
+
const now = shaxpir_common_1.MultiClock.now();
|
|
12
|
+
return repo_1.ShareSyncFactory.get().createContent({
|
|
17
13
|
meta: {
|
|
18
14
|
ref: deviceId,
|
|
19
|
-
is_head: true,
|
|
20
15
|
kind: ContentKind_1.ContentKind.DEVICE,
|
|
21
16
|
id: deviceId,
|
|
22
17
|
owner: userId,
|
|
@@ -37,24 +32,25 @@ class Device extends Content_1.Content {
|
|
|
37
32
|
}
|
|
38
33
|
get lastSyncAtUtcTime() {
|
|
39
34
|
this.checkDisposed("Device.lastSyncAtUtcTime");
|
|
40
|
-
this.ensureLastSyncAtUtcTimeExists();
|
|
41
35
|
return this.payload.last_sync.at_utc_time;
|
|
42
36
|
}
|
|
43
37
|
setLastSyncAtUtcTime(value) {
|
|
44
38
|
this.checkDisposed("Device.setLastSyncAtUtcTime");
|
|
45
|
-
this.ensureLastSyncAtUtcTimeExists();
|
|
46
39
|
if (this.lastSyncAtUtcTime !== value) {
|
|
47
40
|
const batch = new Operation_1.BatchOperation(this);
|
|
48
41
|
batch.setPathValue(['payload', 'last_sync', 'at_utc_time'], value);
|
|
49
42
|
batch.commit();
|
|
50
43
|
}
|
|
51
44
|
}
|
|
52
|
-
|
|
53
|
-
this.checkDisposed("Device.
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
get chineseFont() {
|
|
46
|
+
this.checkDisposed("Device.chineseFont");
|
|
47
|
+
return this.payload.chinese_font || 'Huninn';
|
|
48
|
+
}
|
|
49
|
+
setChineseFont(value) {
|
|
50
|
+
this.checkDisposed("Device.setChineseFont");
|
|
51
|
+
if (this.chineseFont !== value) {
|
|
56
52
|
const batch = new Operation_1.BatchOperation(this);
|
|
57
|
-
batch.setPathValue(['payload', '
|
|
53
|
+
batch.setPathValue(['payload', 'chinese_font'], value);
|
|
58
54
|
batch.commit();
|
|
59
55
|
}
|
|
60
56
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface Hanzi {
|
|
2
|
+
text: string;
|
|
3
|
+
rank: number;
|
|
4
|
+
components: Array<{
|
|
5
|
+
text: string;
|
|
6
|
+
meaning: string;
|
|
7
|
+
pinyin: string;
|
|
8
|
+
}>;
|
|
9
|
+
radical: string;
|
|
10
|
+
radical_analysis: string;
|
|
11
|
+
component_analysis: string;
|
|
12
|
+
}
|
|
13
|
+
export interface BuiltInHanzi extends Hanzi {
|
|
14
|
+
id: number;
|
|
15
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/// <reference path="../../../decs.d.ts" />
|
|
2
1
|
import { Doc } from '@shaxpir/sharedb/lib/client';
|
|
3
|
-
import {
|
|
2
|
+
import { CompactDateTime, SingleTime } from '@shaxpir/shaxpir-common';
|
|
3
|
+
import { ShareSync } from '../repo';
|
|
4
4
|
import { Content, ContentId, ContentRef } from "./Content";
|
|
5
5
|
import { ContentKind } from './ContentKind';
|
|
6
6
|
import { Model } from './Model';
|
|
7
|
-
import { CompactDateTime, SingleTime } from './Time';
|
|
8
7
|
export interface ManifestMeta {
|
|
9
8
|
kind: ContentKind;
|
|
10
9
|
ref: ContentRef;
|
|
@@ -23,8 +22,13 @@ export interface ManifestEntry {
|
|
|
23
22
|
export interface ManifestPayload {
|
|
24
23
|
device: any;
|
|
25
24
|
media: any;
|
|
25
|
+
metric: any;
|
|
26
26
|
profile: any;
|
|
27
|
+
progress: any;
|
|
28
|
+
session: any;
|
|
29
|
+
term: any;
|
|
27
30
|
user: any;
|
|
31
|
+
workspace: any;
|
|
28
32
|
}
|
|
29
33
|
export declare class Manifest extends Model {
|
|
30
34
|
constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Manifest = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const Operation_1 = require("../markup/Operation");
|
|
4
|
+
const shaxpir_common_1 = require("@shaxpir/shaxpir-common");
|
|
5
|
+
const repo_1 = require("../repo");
|
|
7
6
|
const ContentKind_1 = require("./ContentKind");
|
|
8
7
|
const Model_1 = require("./Model");
|
|
9
|
-
const
|
|
8
|
+
const Operation_1 = require("./Operation");
|
|
10
9
|
class Manifest extends Model_1.Model {
|
|
11
10
|
constructor(doc, shouldAcquire, shareSync) {
|
|
12
11
|
super(doc, shouldAcquire, shareSync);
|
|
13
12
|
}
|
|
14
13
|
static makeManifestId(userId) {
|
|
15
|
-
return
|
|
14
|
+
return shaxpir_common_1.CachingHasher.makeMd5Base62Hash(userId + "-" + ContentKind_1.ContentKind.MANIFEST);
|
|
16
15
|
}
|
|
17
16
|
static create(userId) {
|
|
18
|
-
const now =
|
|
17
|
+
const now = shaxpir_common_1.Time.utc();
|
|
19
18
|
const manifestId = Manifest.makeManifestId(userId);
|
|
20
|
-
return
|
|
19
|
+
return repo_1.ShareSyncFactory.get().createManifest({
|
|
21
20
|
meta: {
|
|
22
21
|
kind: ContentKind_1.ContentKind.MANIFEST,
|
|
23
22
|
ref: manifestId,
|
|
@@ -29,8 +28,13 @@ class Manifest extends Model_1.Model {
|
|
|
29
28
|
payload: {
|
|
30
29
|
device: {},
|
|
31
30
|
media: {},
|
|
31
|
+
metric: {},
|
|
32
32
|
profile: {},
|
|
33
|
-
|
|
33
|
+
progress: {},
|
|
34
|
+
session: {},
|
|
35
|
+
term: {},
|
|
36
|
+
user: {},
|
|
37
|
+
workspace: {}
|
|
34
38
|
}
|
|
35
39
|
});
|
|
36
40
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference path="../../../decs.d.ts" />
|
|
2
1
|
import { Doc } from '@shaxpir/sharedb/lib/client';
|
|
3
|
-
import { ShareSync } from '
|
|
4
|
-
import { Content, ContentBody, ContentId, ContentMeta } from
|
|
2
|
+
import { ShareSync } from '../repo';
|
|
3
|
+
import { Content, ContentBody, ContentId, ContentMeta } from "./Content";
|
|
5
4
|
export interface MediaDimensions {
|
|
6
5
|
width: number;
|
|
7
6
|
height: number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Media = void 0;
|
|
4
|
-
const
|
|
4
|
+
const shaxpir_common_1 = require("@shaxpir/shaxpir-common");
|
|
5
|
+
const repo_1 = require("../repo");
|
|
5
6
|
const Content_1 = require("./Content");
|
|
6
7
|
const ContentKind_1 = require("./ContentKind");
|
|
7
|
-
const Time_1 = require("./Time");
|
|
8
8
|
class Media extends Content_1.Content {
|
|
9
9
|
constructor(doc, shouldAcquire, shareSync) {
|
|
10
10
|
super(doc, shouldAcquire, shareSync);
|
|
@@ -14,11 +14,10 @@ class Media extends Content_1.Content {
|
|
|
14
14
|
return this.doc.data.payload;
|
|
15
15
|
}
|
|
16
16
|
static create(userId, mediaId, payload) {
|
|
17
|
-
const now =
|
|
18
|
-
return
|
|
17
|
+
const now = shaxpir_common_1.MultiClock.now();
|
|
18
|
+
return repo_1.ShareSyncFactory.get().createContent({
|
|
19
19
|
meta: {
|
|
20
20
|
ref: mediaId,
|
|
21
|
-
is_head: true,
|
|
22
21
|
kind: ContentKind_1.ContentKind.MEDIA,
|
|
23
22
|
id: mediaId,
|
|
24
23
|
owner: userId,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference path="../../../decs.d.ts" />
|
|
2
1
|
import { Doc } from '@shaxpir/sharedb/lib/client';
|
|
3
|
-
import {
|
|
2
|
+
import { CompactDate } from "@shaxpir/shaxpir-common";
|
|
3
|
+
import { ShareSync } from '../repo';
|
|
4
4
|
import { Content, ContentBody, ContentId, ContentMeta } from "./Content";
|
|
5
|
-
import { CompactDate } from "./Time";
|
|
6
5
|
export declare enum MetricName {
|
|
7
6
|
WORD_COUNT = "word_count",
|
|
8
7
|
MINUTES_WRITING = "minutes_writing"
|