@shaxpir/duiduidui-models 1.0.0 → 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 -4
- package/dist/models/index.js +22 -4
- 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 -14
- package/dist/util/index.js +0 -14
- package/lib/index.ts +5 -0
- 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 +24 -0
- package/lib/repo/ShareSync.ts +9 -13
- package/lib/repo/index.ts +6 -0
- package/lib/util/index.ts +4 -0
- 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 -36
- package/dist/models/content/index.js +0 -53
- 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 -6
- package/dist/models/markup/index.js +0 -23
- 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/markup/DeltaOps.ts +0 -71
- 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,155 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Migration = exports.MigrationStatus = void 0;
|
|
4
|
-
const ShareSync_1 = require("../../repo/ShareSync");
|
|
5
|
-
const CachingHasher_1 = require("../../util/CachingHasher");
|
|
6
|
-
const markup_1 = require("../markup");
|
|
7
|
-
const Content_1 = require("./Content");
|
|
8
|
-
const ContentKind_1 = require("./ContentKind");
|
|
9
|
-
const Time_1 = require("./Time");
|
|
10
|
-
var MigrationStatus;
|
|
11
|
-
(function (MigrationStatus) {
|
|
12
|
-
MigrationStatus["MIGRATED"] = "MIGRATED";
|
|
13
|
-
MigrationStatus["CANT_MIGRATE"] = "CANT_MIGRATE";
|
|
14
|
-
MigrationStatus["REPAIRED"] = "REPAIRED";
|
|
15
|
-
MigrationStatus["CANT_REPAIR"] = "CANT_REPAIR";
|
|
16
|
-
MigrationStatus["SKIPPED"] = "SKIPPED";
|
|
17
|
-
MigrationStatus["UPDATED"] = "UPDATED";
|
|
18
|
-
})(MigrationStatus || (exports.MigrationStatus = MigrationStatus = {}));
|
|
19
|
-
class Migration extends Content_1.Content {
|
|
20
|
-
constructor(doc, shouldAcquire, shareSync) {
|
|
21
|
-
super(doc, shouldAcquire, shareSync);
|
|
22
|
-
}
|
|
23
|
-
static makeMigrationId(userId) {
|
|
24
|
-
return CachingHasher_1.CachingHasher.makeMd5ContentId(userId + "-" + ContentKind_1.ContentKind.MIGRATION);
|
|
25
|
-
}
|
|
26
|
-
static create(userId, isPrimary, deviceId) {
|
|
27
|
-
const now = Time_1.MultiClock.now();
|
|
28
|
-
const migrationId = Migration.makeMigrationId(userId);
|
|
29
|
-
const migrationRef = Content_1.Content.makeContentRef(migrationId, now.utc_time);
|
|
30
|
-
return ShareSync_1.ShareSyncFactory.get().createContent({
|
|
31
|
-
meta: {
|
|
32
|
-
ref: migrationRef,
|
|
33
|
-
is_head: false,
|
|
34
|
-
kind: ContentKind_1.ContentKind.MIGRATION,
|
|
35
|
-
id: migrationId,
|
|
36
|
-
owner: userId,
|
|
37
|
-
created_at: now,
|
|
38
|
-
updated_at: now
|
|
39
|
-
},
|
|
40
|
-
payload: {
|
|
41
|
-
start: now,
|
|
42
|
-
end: now,
|
|
43
|
-
is_complete: false,
|
|
44
|
-
is_primary: isPrimary,
|
|
45
|
-
device_id: deviceId,
|
|
46
|
-
legacy_snapshot_count: 0,
|
|
47
|
-
migrated_count: 0,
|
|
48
|
-
cant_migrate_count: 0,
|
|
49
|
-
repaired_count: 0,
|
|
50
|
-
cant_repair_count: 0,
|
|
51
|
-
updated_count: 0,
|
|
52
|
-
skipped_count: 0,
|
|
53
|
-
duration_minutes: 0,
|
|
54
|
-
migration_entries: []
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
get payload() {
|
|
59
|
-
this.checkDisposed("Migration.payload");
|
|
60
|
-
return this.doc.data.payload;
|
|
61
|
-
}
|
|
62
|
-
get durationMinutes() {
|
|
63
|
-
this.checkDisposed("Migration.durationMinutes");
|
|
64
|
-
return this.payload.duration_minutes;
|
|
65
|
-
}
|
|
66
|
-
get isPrimary() {
|
|
67
|
-
this.checkDisposed("Migration.isPrimary");
|
|
68
|
-
return this.payload.is_primary;
|
|
69
|
-
}
|
|
70
|
-
get isComplete() {
|
|
71
|
-
this.checkDisposed("Migration.isComplete");
|
|
72
|
-
return this.payload.is_complete;
|
|
73
|
-
}
|
|
74
|
-
setIsComplete(value) {
|
|
75
|
-
this.checkDisposed("Migration.setIsComplete");
|
|
76
|
-
if (this.isComplete != value) {
|
|
77
|
-
const batch = new markup_1.BatchOperation(this);
|
|
78
|
-
batch.setPathValue(['payload', 'is_complete'], value);
|
|
79
|
-
this.touch(batch, batch.at);
|
|
80
|
-
batch.commit();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
get legacySnapshotCount() {
|
|
84
|
-
this.checkDisposed("Migration.legacySnapshotCount");
|
|
85
|
-
return this.payload.legacy_snapshot_count;
|
|
86
|
-
}
|
|
87
|
-
setLegacySnapshotCount(value) {
|
|
88
|
-
this.checkDisposed("Migration.setLegacySnapshotCount");
|
|
89
|
-
if (this.legacySnapshotCount != value) {
|
|
90
|
-
const batch = new markup_1.BatchOperation(this);
|
|
91
|
-
batch.setPathValue(['payload', 'legacy_snapshot_count'], value);
|
|
92
|
-
this.touch(batch, batch.at);
|
|
93
|
-
batch.commit();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
get repairedCount() {
|
|
97
|
-
this.checkDisposed("Migration.repairedCount");
|
|
98
|
-
return this.payload.repaired_count;
|
|
99
|
-
}
|
|
100
|
-
get cantRepairCount() {
|
|
101
|
-
this.checkDisposed("Migration.cantRepairCount");
|
|
102
|
-
return this.payload.cant_repair_count;
|
|
103
|
-
}
|
|
104
|
-
get migratedCount() {
|
|
105
|
-
this.checkDisposed("Migration.migratedCount");
|
|
106
|
-
return this.payload.migrated_count;
|
|
107
|
-
}
|
|
108
|
-
get cantMigrateCount() {
|
|
109
|
-
this.checkDisposed("Migration.cantMigrateCount");
|
|
110
|
-
return this.payload.cant_migrate_count;
|
|
111
|
-
}
|
|
112
|
-
get updatedCount() {
|
|
113
|
-
this.checkDisposed("Migration.updatedCount");
|
|
114
|
-
return this.payload.updated_count;
|
|
115
|
-
}
|
|
116
|
-
get skippedCount() {
|
|
117
|
-
this.checkDisposed("Migration.skippedCount");
|
|
118
|
-
return this.payload.skipped_count;
|
|
119
|
-
}
|
|
120
|
-
addMigrationEntry(entry) {
|
|
121
|
-
this.checkDisposed("Migration.addMigrationEntry");
|
|
122
|
-
const batch = new markup_1.BatchOperation(this, entry.at);
|
|
123
|
-
const modelCount = entry.models.length;
|
|
124
|
-
batch.pushIntoArray(['payload', 'migration_entries'], entry);
|
|
125
|
-
this.touch(batch, entry.at);
|
|
126
|
-
switch (entry.status) {
|
|
127
|
-
case MigrationStatus.MIGRATED:
|
|
128
|
-
batch.setPathValue(['payload', 'migrated_count'], this.migratedCount + modelCount);
|
|
129
|
-
break;
|
|
130
|
-
case MigrationStatus.CANT_MIGRATE:
|
|
131
|
-
batch.setPathValue(['payload', 'cant_migrate_count'], this.cantMigrateCount + modelCount);
|
|
132
|
-
break;
|
|
133
|
-
case MigrationStatus.REPAIRED:
|
|
134
|
-
batch.setPathValue(['payload', 'repaired_count'], this.repairedCount + modelCount);
|
|
135
|
-
break;
|
|
136
|
-
case MigrationStatus.CANT_REPAIR:
|
|
137
|
-
batch.setPathValue(['payload', 'cant_repair_count'], this.cantRepairCount + modelCount);
|
|
138
|
-
break;
|
|
139
|
-
case MigrationStatus.UPDATED:
|
|
140
|
-
batch.setPathValue(['payload', 'updated_count'], this.updatedCount + modelCount);
|
|
141
|
-
break;
|
|
142
|
-
case MigrationStatus.SKIPPED:
|
|
143
|
-
batch.setPathValue(['payload', 'skipped_count'], this.skippedCount + modelCount);
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
batch.commit();
|
|
147
|
-
}
|
|
148
|
-
touch(batch, at) {
|
|
149
|
-
const minutes = Time_1.Time.absDiffMinutes(at.utc_time, this.payload.start.utc_time);
|
|
150
|
-
batch.setPathValue(['payload', 'duration_minutes'], minutes);
|
|
151
|
-
batch.setPathValue(['payload', 'end', 'utc_time'], at.utc_time);
|
|
152
|
-
batch.setPathValue(['payload', 'end', 'local_time'], at.local_time);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
exports.Migration = Migration;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ContentBody, ContentMeta } from "./Content";
|
|
2
|
-
import { Definable, DictionaryEntry, Pronouncable } from "./DictionaryEntry";
|
|
3
|
-
export interface PhrasePayload extends DictionaryEntry, Pronouncable, Definable {
|
|
4
|
-
}
|
|
5
|
-
export interface PhraseBody extends ContentBody {
|
|
6
|
-
meta: ContentMeta;
|
|
7
|
-
payload: PhrasePayload;
|
|
8
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Content } from './Content';
|
|
2
|
-
import { Stub } from './Stub';
|
|
3
|
-
export declare class Placeholder {
|
|
4
|
-
static readonly PREFIX = "untitled";
|
|
5
|
-
static forCategory(name: string): string;
|
|
6
|
-
static forContent(content: Content): string;
|
|
7
|
-
static forStub(stub: Stub): string;
|
|
8
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Placeholder = void 0;
|
|
4
|
-
const Text_1 = require("../../util/Text");
|
|
5
|
-
const Book_1 = require("./Book");
|
|
6
|
-
const ContentKind_1 = require("./ContentKind");
|
|
7
|
-
const Fragment_1 = require("./Fragment");
|
|
8
|
-
class Placeholder {
|
|
9
|
-
static forCategory(name) {
|
|
10
|
-
let placeholder = "untitled ";
|
|
11
|
-
if (typeof (name) !== "undefined") { // TODO: does anyone call this without an arg?
|
|
12
|
-
placeholder += name.trim();
|
|
13
|
-
}
|
|
14
|
-
return Text_1.Text.capitalizeWords(placeholder.trim());
|
|
15
|
-
}
|
|
16
|
-
static forContent(content) {
|
|
17
|
-
if (content instanceof Book_1.Book) {
|
|
18
|
-
return Placeholder.forCategory(ContentKind_1.ContentKind.BOOK);
|
|
19
|
-
}
|
|
20
|
-
else if (content instanceof Fragment_1.Fragment) {
|
|
21
|
-
return Placeholder.forCategory(content.category);
|
|
22
|
-
}
|
|
23
|
-
return Text_1.Text.capitalizeWords(content.kind);
|
|
24
|
-
}
|
|
25
|
-
static forStub(stub) {
|
|
26
|
-
if (stub.kind === ContentKind_1.ContentKind.BOOK) {
|
|
27
|
-
return Placeholder.forCategory(ContentKind_1.ContentKind.BOOK);
|
|
28
|
-
}
|
|
29
|
-
else if (stub.kind === ContentKind_1.ContentKind.FRAGMENT) {
|
|
30
|
-
return Placeholder.forCategory(stub.category);
|
|
31
|
-
}
|
|
32
|
-
return Text_1.Text.capitalizeWords(stub.kind);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.Placeholder = Placeholder;
|
|
36
|
-
Placeholder.PREFIX = 'untitled';
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/// <reference path="../../../decs.d.ts" />
|
|
2
|
-
import { Op as DeltaOp } from "@shaxpir/quill-delta";
|
|
3
|
-
import { Doc } from '@shaxpir/sharedb/lib/client';
|
|
4
|
-
import { ShareSync } from '../../repo/ShareSync';
|
|
5
|
-
import { Checkpointable } from './Checkpointable';
|
|
6
|
-
import { ContentId, ContentMeta } from "./Content";
|
|
7
|
-
import { MultiTime } from './Time';
|
|
8
|
-
export interface FormatAttr {
|
|
9
|
-
align?: string;
|
|
10
|
-
blockquote?: boolean;
|
|
11
|
-
bold?: boolean;
|
|
12
|
-
comment?: ContentId[];
|
|
13
|
-
header?: number;
|
|
14
|
-
highlight?: any[];
|
|
15
|
-
indent?: number;
|
|
16
|
-
italic?: boolean;
|
|
17
|
-
link?: string;
|
|
18
|
-
list?: "ordered" | "bullet";
|
|
19
|
-
script: "sub" | "super";
|
|
20
|
-
strike?: boolean;
|
|
21
|
-
underline?: boolean;
|
|
22
|
-
}
|
|
23
|
-
export interface FormatEmbed {
|
|
24
|
-
divider?: boolean;
|
|
25
|
-
}
|
|
26
|
-
export interface Format {
|
|
27
|
-
at: number;
|
|
28
|
-
len: number;
|
|
29
|
-
attr?: FormatAttr;
|
|
30
|
-
embed?: FormatEmbed;
|
|
31
|
-
}
|
|
32
|
-
export declare enum RichTextFlavor {
|
|
33
|
-
quill = "quill"
|
|
34
|
-
}
|
|
35
|
-
export interface QuillDoc {
|
|
36
|
-
ops: DeltaOp[];
|
|
37
|
-
}
|
|
38
|
-
export interface RichTextPayload {
|
|
39
|
-
richtext_flavor: RichTextFlavor;
|
|
40
|
-
richtext_body: QuillDoc;
|
|
41
|
-
word_count: number;
|
|
42
|
-
}
|
|
43
|
-
export interface RichTextBody {
|
|
44
|
-
meta: ContentMeta;
|
|
45
|
-
payload: RichTextPayload;
|
|
46
|
-
}
|
|
47
|
-
export declare abstract class RichText extends Checkpointable {
|
|
48
|
-
constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
|
|
49
|
-
get payload(): RichTextPayload;
|
|
50
|
-
get richtextFlavor(): RichTextFlavor;
|
|
51
|
-
get richtextBody(): QuillDoc;
|
|
52
|
-
get wordCount(): number;
|
|
53
|
-
setWordCount(value: number): void;
|
|
54
|
-
get mediaIds(): ContentId[];
|
|
55
|
-
get commentIds(): ContentId[];
|
|
56
|
-
updateRichText(deltaOps: DeltaOp[], newWordCount: number): void;
|
|
57
|
-
beforeRestoreTo(checkpoint: Checkpointable, now: MultiTime): Promise<void>;
|
|
58
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RichText = exports.RichTextFlavor = void 0;
|
|
4
|
-
const util_1 = require("../../util");
|
|
5
|
-
const markup_1 = require("../markup");
|
|
6
|
-
const BodyFormat_1 = require("../markup/BodyFormat");
|
|
7
|
-
const Checkpointable_1 = require("./Checkpointable");
|
|
8
|
-
const ContentKind_1 = require("./ContentKind");
|
|
9
|
-
var RichTextFlavor;
|
|
10
|
-
(function (RichTextFlavor) {
|
|
11
|
-
RichTextFlavor["quill"] = "quill";
|
|
12
|
-
})(RichTextFlavor || (exports.RichTextFlavor = RichTextFlavor = {}));
|
|
13
|
-
class RichText extends Checkpointable_1.Checkpointable {
|
|
14
|
-
constructor(doc, shouldAcquire, shareSync) {
|
|
15
|
-
super(doc, shouldAcquire, shareSync);
|
|
16
|
-
}
|
|
17
|
-
get payload() {
|
|
18
|
-
this.checkDisposed("RichText.payload");
|
|
19
|
-
return this.doc.data.payload;
|
|
20
|
-
}
|
|
21
|
-
get richtextFlavor() {
|
|
22
|
-
this.checkDisposed("RichText.richtextFlavor");
|
|
23
|
-
return this.payload.richtext_flavor;
|
|
24
|
-
}
|
|
25
|
-
get richtextBody() {
|
|
26
|
-
this.checkDisposed("RichText.richtextBody");
|
|
27
|
-
return this.payload.richtext_body;
|
|
28
|
-
}
|
|
29
|
-
get wordCount() {
|
|
30
|
-
this.checkDisposed("RichText.wordCount");
|
|
31
|
-
return this.payload.word_count;
|
|
32
|
-
}
|
|
33
|
-
setWordCount(value) {
|
|
34
|
-
this.checkDisposed("RichText.setWordCount");
|
|
35
|
-
if (this.wordCount !== value) {
|
|
36
|
-
const batch = new markup_1.BatchOperation(this);
|
|
37
|
-
batch.setPathValue(['payload', 'word_count'], value);
|
|
38
|
-
batch.commit();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
get mediaIds() {
|
|
42
|
-
this.checkDisposed("RichText.mediaIds");
|
|
43
|
-
return BodyFormat_1.BodyFormatModel.getMediaIdsFromDeltaOps(this.richtextBody.ops);
|
|
44
|
-
}
|
|
45
|
-
get commentIds() {
|
|
46
|
-
this.checkDisposed("RichText.commentIds");
|
|
47
|
-
return BodyFormat_1.BodyFormatModel.getCommentIdsFromDeltaOps(this.richtextBody.ops);
|
|
48
|
-
}
|
|
49
|
-
updateRichText(deltaOps, newWordCount) {
|
|
50
|
-
this.checkDisposed("RichText.updateRichText");
|
|
51
|
-
const batch = new markup_1.BatchOperation(this);
|
|
52
|
-
batch.applyRichText(['payload', 'richtext_body'], deltaOps);
|
|
53
|
-
if (this.wordCount != newWordCount) {
|
|
54
|
-
batch.setPathValue(['payload', 'word_count'], newWordCount);
|
|
55
|
-
}
|
|
56
|
-
batch.commit();
|
|
57
|
-
}
|
|
58
|
-
async beforeRestoreTo(checkpoint, now) {
|
|
59
|
-
this.checkDisposed("RichText.beforeRestoreTo");
|
|
60
|
-
// Restore all embedded comments
|
|
61
|
-
const checkpointTimestamp = checkpoint.createdAt.utc_time;
|
|
62
|
-
const commentIds = this.commentIds;
|
|
63
|
-
if (commentIds.length > 0) {
|
|
64
|
-
for (let i = 0; i < commentIds.length; i++) {
|
|
65
|
-
const commentId = commentIds[i];
|
|
66
|
-
const commentHead = await this.shareSync.acquire(ContentKind_1.ContentKind.COMMENT, commentId);
|
|
67
|
-
const commentCheckpoint = await commentHead.acquireLatestCheckpointAt(checkpointTimestamp);
|
|
68
|
-
// If the HEAD comment is already the most recent checkpoint, or if the payload hasn't
|
|
69
|
-
// changed since that checkpoint was taken, then there's no need to restore this comment.
|
|
70
|
-
if (!commentCheckpoint.isHead && !util_1.Struct.equals(commentHead.payload, commentCheckpoint.payload)) {
|
|
71
|
-
await commentHead.restoreTo(commentCheckpoint, now);
|
|
72
|
-
}
|
|
73
|
-
commentCheckpoint.release();
|
|
74
|
-
commentHead.release();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.RichText = RichText;
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Session = void 0;
|
|
4
|
-
const ShareSync_1 = require("../../repo/ShareSync");
|
|
5
|
-
const CachingHasher_1 = require("../../util/CachingHasher");
|
|
6
|
-
const Struct_1 = require("../../util/Struct");
|
|
7
|
-
const Operation_1 = require("../markup/Operation");
|
|
8
|
-
const Content_1 = require("./Content");
|
|
9
|
-
const ContentKind_1 = require("./ContentKind");
|
|
10
|
-
const Metric_1 = require("./Metric");
|
|
11
|
-
const Time_1 = require("./Time");
|
|
12
|
-
const Workspace_1 = require("./Workspace");
|
|
13
|
-
class Session extends Content_1.Content {
|
|
14
|
-
static makeSessionId(userId) {
|
|
15
|
-
return CachingHasher_1.CachingHasher.makeMd5ContentId(userId + "-" + ContentKind_1.ContentKind.SESSION);
|
|
16
|
-
}
|
|
17
|
-
static create(userId, deviceId, environment) {
|
|
18
|
-
let now = Time_1.MultiClock.now();
|
|
19
|
-
let sessionId = Session.makeSessionId(userId);
|
|
20
|
-
let sessionRef = Content_1.Content.makeContentRef(sessionId, now.utc_time);
|
|
21
|
-
return ShareSync_1.ShareSyncFactory.get().createContent({
|
|
22
|
-
meta: {
|
|
23
|
-
ref: sessionRef,
|
|
24
|
-
is_head: false,
|
|
25
|
-
kind: ContentKind_1.ContentKind.SESSION,
|
|
26
|
-
id: sessionId,
|
|
27
|
-
owner: userId,
|
|
28
|
-
created_at: now,
|
|
29
|
-
updated_at: now
|
|
30
|
-
},
|
|
31
|
-
payload: {
|
|
32
|
-
start: now,
|
|
33
|
-
end: now,
|
|
34
|
-
tz_offset: (new Date()).getTimezoneOffset(),
|
|
35
|
-
duration_minutes: 0,
|
|
36
|
-
device_id: deviceId,
|
|
37
|
-
environment: environment,
|
|
38
|
-
word_count: 0,
|
|
39
|
-
activity: []
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
constructor(doc, shouldAcquire, shareSync) {
|
|
44
|
-
super(doc, shouldAcquire, shareSync);
|
|
45
|
-
}
|
|
46
|
-
get payload() {
|
|
47
|
-
this.checkDisposed("Session.payload");
|
|
48
|
-
return this.doc.data.payload;
|
|
49
|
-
}
|
|
50
|
-
touch() {
|
|
51
|
-
this.checkDisposed("Session.touch");
|
|
52
|
-
const batch = new Operation_1.BatchOperation(this);
|
|
53
|
-
let nowUtc = batch.at.utc_time;
|
|
54
|
-
let nowLocal = batch.at.local_time;
|
|
55
|
-
let minutes = Time_1.Time.absDiffMinutes(nowUtc, this.start.utc_time);
|
|
56
|
-
batch.setPathValue(['payload', 'duration_minutes'], minutes);
|
|
57
|
-
batch.setPathValue(['payload', 'end', 'utc_time'], nowUtc);
|
|
58
|
-
batch.setPathValue(['payload', 'end', 'local_time'], nowLocal);
|
|
59
|
-
batch.commit();
|
|
60
|
-
}
|
|
61
|
-
get start() {
|
|
62
|
-
this.checkDisposed("Session.start");
|
|
63
|
-
return this.payload.start;
|
|
64
|
-
}
|
|
65
|
-
get end() {
|
|
66
|
-
this.checkDisposed("Session.end");
|
|
67
|
-
return this.payload.end;
|
|
68
|
-
}
|
|
69
|
-
get tzOffset() {
|
|
70
|
-
this.checkDisposed("Session.tzOffset");
|
|
71
|
-
return this.payload.tz_offset;
|
|
72
|
-
}
|
|
73
|
-
get durationMinutes() {
|
|
74
|
-
this.checkDisposed("Session.durationMinutes");
|
|
75
|
-
return this.payload.duration_minutes;
|
|
76
|
-
}
|
|
77
|
-
get deviceId() {
|
|
78
|
-
this.checkDisposed("Session.deviceId");
|
|
79
|
-
return this.payload.device_id;
|
|
80
|
-
}
|
|
81
|
-
get environment() {
|
|
82
|
-
this.checkDisposed("Session.environment");
|
|
83
|
-
return this.payload.environment;
|
|
84
|
-
}
|
|
85
|
-
get wordCount() {
|
|
86
|
-
this.checkDisposed("Session.wordCount");
|
|
87
|
-
return this.payload.word_count;
|
|
88
|
-
}
|
|
89
|
-
setWordCount(value) {
|
|
90
|
-
this.checkDisposed("Session.setWordCount");
|
|
91
|
-
if (this.wordCount !== value) {
|
|
92
|
-
const batch = new Operation_1.BatchOperation(this);
|
|
93
|
-
batch.setPathValue(['payload', 'word_count'], value);
|
|
94
|
-
batch.commit();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
get activity() {
|
|
98
|
-
this.checkDisposed("Session.activity");
|
|
99
|
-
return this.payload.activity;
|
|
100
|
-
}
|
|
101
|
-
recordActivity(newActivity) {
|
|
102
|
-
this.checkDisposed("Session.recordActivity");
|
|
103
|
-
// TODO: instead of rebuilding the activity list completely on every change,
|
|
104
|
-
// update only the deeply-nested fields within the Activity array.
|
|
105
|
-
let newActivities = [];
|
|
106
|
-
let replaced = false;
|
|
107
|
-
// Iterate through the activities in the session, replacing any existing activities with new ones (having
|
|
108
|
-
// updated word-counts and timestamps) and summing them all up to produce the session-total-word-count.
|
|
109
|
-
let sessionWordCount = 0;
|
|
110
|
-
let existingActivities = this.payload.activity;
|
|
111
|
-
for (let i = 0, len = existingActivities.length; i < len; i++) {
|
|
112
|
-
let existingActivity = existingActivities[i];
|
|
113
|
-
if (existingActivity.id === newActivity.id) {
|
|
114
|
-
if (newActivity.hasOwnProperty("word_count")) {
|
|
115
|
-
sessionWordCount += newActivity.word_count;
|
|
116
|
-
}
|
|
117
|
-
newActivities.push(newActivity);
|
|
118
|
-
replaced = true;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
newActivities.push(existingActivity);
|
|
122
|
-
if (existingActivity.hasOwnProperty("word_count")) {
|
|
123
|
-
sessionWordCount += existingActivity.word_count;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (replaced === false) {
|
|
128
|
-
newActivities.push(newActivity);
|
|
129
|
-
if (newActivity.hasOwnProperty("word_count")) {
|
|
130
|
-
sessionWordCount += newActivity.word_count;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
const now = Time_1.MultiClock.now();
|
|
134
|
-
const batch = new Operation_1.BatchOperation(this, now);
|
|
135
|
-
batch.setPathValue(['payload', 'end'], now);
|
|
136
|
-
if (this.wordCount !== sessionWordCount) {
|
|
137
|
-
batch.setPathValue(['payload', 'word_count'], sessionWordCount);
|
|
138
|
-
}
|
|
139
|
-
if (!Struct_1.Struct.equals(existingActivities, newActivities)) {
|
|
140
|
-
batch.setPathValue(['payload', 'activity'], newActivities);
|
|
141
|
-
}
|
|
142
|
-
batch.commit();
|
|
143
|
-
}
|
|
144
|
-
async modelUpdated() {
|
|
145
|
-
this.checkDisposed("Session.modelUpdated");
|
|
146
|
-
await super.modelUpdated();
|
|
147
|
-
const shareSync = this.shareSync;
|
|
148
|
-
const sessionId = this.id;
|
|
149
|
-
const userId = this.owner;
|
|
150
|
-
const date = Time_1.Time.dateFrom(this.createdAt.local_time);
|
|
151
|
-
const workspaceId = Workspace_1.Workspace.makeWorkspaceId(userId);
|
|
152
|
-
const workspace = await this.shareSync.acquire(ContentKind_1.ContentKind.WORKSPACE, workspaceId);
|
|
153
|
-
const sessionsOnDate = await workspace.acquireSessionsFromDate(sessionId, date);
|
|
154
|
-
workspace.release();
|
|
155
|
-
let wordCountOnDate = 0;
|
|
156
|
-
let minutesWritingOnDate = 0;
|
|
157
|
-
for (let i = 0, len = sessionsOnDate.length; i < len; i++) {
|
|
158
|
-
const sessionOnDate = sessionsOnDate[i];
|
|
159
|
-
wordCountOnDate += sessionOnDate.wordCount;
|
|
160
|
-
minutesWritingOnDate += sessionOnDate.durationMinutes;
|
|
161
|
-
sessionOnDate.release();
|
|
162
|
-
}
|
|
163
|
-
const wordCountMetricId = Metric_1.Metric.makeMetricId(userId, Metric_1.MetricName.WORD_COUNT);
|
|
164
|
-
const wordCountMetric = await shareSync.acquire(ContentKind_1.ContentKind.METRIC, wordCountMetricId);
|
|
165
|
-
wordCountMetric.setDateAmount(date, wordCountOnDate);
|
|
166
|
-
wordCountMetric.release();
|
|
167
|
-
const minutesWritingMetricId = Metric_1.Metric.makeMetricId(userId, Metric_1.MetricName.MINUTES_WRITING);
|
|
168
|
-
const minutesWritingMetric = await shareSync.acquire(ContentKind_1.ContentKind.METRIC, minutesWritingMetricId);
|
|
169
|
-
minutesWritingMetric.setDateAmount(date, minutesWritingOnDate);
|
|
170
|
-
minutesWritingMetric.release();
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
exports.Session = Session;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export declare enum SpeechDataType {
|
|
2
|
-
AUDIO_MP3 = "audio_mp3",
|
|
3
|
-
AUDIO_OGG = "audio_ogg",
|
|
4
|
-
META_WORD_MARKS = "meta_word_marks"
|
|
5
|
-
}
|
|
6
|
-
export declare enum SpeechProvider {
|
|
7
|
-
AWS = "aws",
|
|
8
|
-
ELEVEN_LABS = "eleven_labs"
|
|
9
|
-
}
|
|
10
|
-
export declare enum SpeechEngine {
|
|
11
|
-
STANDARD = "standard",
|
|
12
|
-
NEURAL = "neural"
|
|
13
|
-
}
|
|
14
|
-
export declare enum SpeechLanguage {
|
|
15
|
-
ENGLISH = "English"
|
|
16
|
-
}
|
|
17
|
-
export declare enum SpeechDialect {
|
|
18
|
-
US = "US",
|
|
19
|
-
AU = "AU",
|
|
20
|
-
GB = "GB",
|
|
21
|
-
IN = "IN"
|
|
22
|
-
}
|
|
23
|
-
export declare enum SpeechGender {
|
|
24
|
-
MALE = "Male",
|
|
25
|
-
FEMALE = "Female"
|
|
26
|
-
}
|
|
27
|
-
export declare enum SpeechAge {
|
|
28
|
-
ADULT = "Adult",
|
|
29
|
-
CHILD = "Child",
|
|
30
|
-
ELDERLY = "Elderly"
|
|
31
|
-
}
|
|
32
|
-
export interface SpeechMarkItem {
|
|
33
|
-
time: number;
|
|
34
|
-
type: string;
|
|
35
|
-
start: number;
|
|
36
|
-
end: number;
|
|
37
|
-
value: string;
|
|
38
|
-
}
|
|
39
|
-
export declare class SpeechPersona {
|
|
40
|
-
static readonly AMY: SpeechPersona;
|
|
41
|
-
static readonly BRIAN: SpeechPersona;
|
|
42
|
-
static readonly EMMA: SpeechPersona;
|
|
43
|
-
static readonly IVY: SpeechPersona;
|
|
44
|
-
static readonly JOANNA: SpeechPersona;
|
|
45
|
-
static readonly JOEY: SpeechPersona;
|
|
46
|
-
static readonly JUSTIN: SpeechPersona;
|
|
47
|
-
static readonly KENDRA: SpeechPersona;
|
|
48
|
-
static readonly KEVIN: SpeechPersona;
|
|
49
|
-
static readonly KIMBERY: SpeechPersona;
|
|
50
|
-
static readonly MATTHEW: SpeechPersona;
|
|
51
|
-
static readonly SALLI: SpeechPersona;
|
|
52
|
-
static readonly DAVID: SpeechPersona;
|
|
53
|
-
static readonly RACHEL: SpeechPersona;
|
|
54
|
-
static readonly DEFAULT: SpeechPersona;
|
|
55
|
-
static readonly ALL: SpeechPersona[];
|
|
56
|
-
code: string;
|
|
57
|
-
name: string;
|
|
58
|
-
provider: SpeechProvider;
|
|
59
|
-
engine: SpeechEngine;
|
|
60
|
-
language: SpeechLanguage;
|
|
61
|
-
dialect: SpeechDialect;
|
|
62
|
-
gender: SpeechGender;
|
|
63
|
-
age: SpeechAge;
|
|
64
|
-
constructor(code: string, name: string, provider: SpeechProvider, engine: SpeechEngine, language: SpeechLanguage, dialect: SpeechDialect, gender: SpeechGender, age: SpeechAge);
|
|
65
|
-
static byName(name: string): SpeechPersona;
|
|
66
|
-
getLangaugeCode(): string;
|
|
67
|
-
}
|