@shaxpir/duiduidui-models 1.4.6 → 1.4.8
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/Billing.d.ts +2 -1
- package/dist/models/Billing.js +5 -3
- package/dist/models/Manifest.d.ts +1 -1
- package/dist/models/Manifest.js +4 -4
- package/dist/models/Progress.d.ts +3 -0
- package/dist/models/Progress.js +12 -0
- package/dist/models/Term.d.ts +8 -0
- package/dist/models/Term.js +32 -0
- package/dist/models/User.js +1 -1
- package/dist/models/Workspace.d.ts +5 -3
- package/dist/models/Workspace.js +16 -19
- package/package.json +1 -1
package/dist/models/Billing.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Doc } from '@shaxpir/sharedb/lib/client';
|
|
2
|
+
import { MultiTime } from '@shaxpir/shaxpir-common';
|
|
2
3
|
import { ShareSync } from '../repo';
|
|
3
4
|
import { Content, ContentBody, ContentId, ContentMeta } from "./Content";
|
|
4
5
|
export interface BillingPayload {
|
|
@@ -10,7 +11,7 @@ export interface BillingBody extends ContentBody {
|
|
|
10
11
|
}
|
|
11
12
|
export declare class Billing extends Content {
|
|
12
13
|
static makeBillingId(userId: ContentId): ContentId;
|
|
13
|
-
static create(userId: ContentId, payload: BillingPayload): Billing;
|
|
14
|
+
static create(userId: ContentId, payload: BillingPayload, createdAt?: MultiTime): Billing;
|
|
14
15
|
constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
|
|
15
16
|
get payload(): BillingPayload;
|
|
16
17
|
}
|
package/dist/models/Billing.js
CHANGED
|
@@ -9,8 +9,10 @@ class Billing extends Content_1.Content {
|
|
|
9
9
|
static makeBillingId(userId) {
|
|
10
10
|
return shaxpir_common_1.CachingHasher.makeMd5Base62Hash(userId + "-" + ContentKind_1.ContentKind.BILLING);
|
|
11
11
|
}
|
|
12
|
-
static create(userId, payload) {
|
|
12
|
+
static create(userId, payload, createdAt) {
|
|
13
13
|
const now = shaxpir_common_1.MultiClock.now();
|
|
14
|
+
// If the createdAt time is not provided, use the current time
|
|
15
|
+
createdAt ??= now;
|
|
14
16
|
const billingId = Billing.makeBillingId(userId);
|
|
15
17
|
return repo_1.ShareSyncFactory.get().createContent({
|
|
16
18
|
meta: {
|
|
@@ -18,8 +20,8 @@ class Billing extends Content_1.Content {
|
|
|
18
20
|
kind: ContentKind_1.ContentKind.BILLING,
|
|
19
21
|
id: billingId,
|
|
20
22
|
owner: userId,
|
|
21
|
-
created_at:
|
|
22
|
-
updated_at:
|
|
23
|
+
created_at: createdAt,
|
|
24
|
+
updated_at: createdAt
|
|
23
25
|
},
|
|
24
26
|
payload
|
|
25
27
|
});
|
|
@@ -34,7 +34,7 @@ export interface ManifestPayload {
|
|
|
34
34
|
export declare class Manifest extends Model {
|
|
35
35
|
constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
|
|
36
36
|
static makeManifestId(userId: ContentId): ContentId;
|
|
37
|
-
static create(userId: ContentId): Manifest;
|
|
37
|
+
static create(userId: ContentId, createdAt?: SingleTime): Manifest;
|
|
38
38
|
get meta(): ManifestMeta;
|
|
39
39
|
get owner(): ContentId;
|
|
40
40
|
canUserView(userId: ContentId): boolean;
|
package/dist/models/Manifest.js
CHANGED
|
@@ -13,16 +13,16 @@ class Manifest extends Model_1.Model {
|
|
|
13
13
|
static makeManifestId(userId) {
|
|
14
14
|
return shaxpir_common_1.CachingHasher.makeMd5Base62Hash(userId + "-" + ContentKind_1.ContentKind.MANIFEST);
|
|
15
15
|
}
|
|
16
|
-
static create(userId) {
|
|
16
|
+
static create(userId, createdAt) {
|
|
17
17
|
const now = shaxpir_common_1.Time.utc();
|
|
18
|
+
// If the createdAt time is not provided, use the current time
|
|
19
|
+
const createdTime = createdAt ?? { utc_time: now };
|
|
18
20
|
const manifestId = Manifest.makeManifestId(userId);
|
|
19
21
|
return repo_1.ShareSyncFactory.get().createManifest({
|
|
20
22
|
meta: {
|
|
21
23
|
kind: ContentKind_1.ContentKind.MANIFEST,
|
|
22
24
|
ref: manifestId,
|
|
23
|
-
updated_at:
|
|
24
|
-
utc_time: now
|
|
25
|
-
},
|
|
25
|
+
updated_at: createdTime,
|
|
26
26
|
owner: userId
|
|
27
27
|
},
|
|
28
28
|
payload: {
|
|
@@ -23,6 +23,9 @@ export declare class Progress extends Content {
|
|
|
23
23
|
static create(userId: ContentId): Progress;
|
|
24
24
|
constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
|
|
25
25
|
get payload(): ProgressPayload;
|
|
26
|
+
getUserRank(): number;
|
|
27
|
+
getCognitiveLoad(): number;
|
|
28
|
+
getPhrases(): Record<string, PhraseProgress>;
|
|
26
29
|
setUserRank(value: number): void;
|
|
27
30
|
setCognitiveLoad(value: number): void;
|
|
28
31
|
updatePhraseProgress(phraseId: string, progress: PhraseProgress): void;
|
package/dist/models/Progress.js
CHANGED
|
@@ -36,6 +36,18 @@ class Progress extends Content_1.Content {
|
|
|
36
36
|
this.checkDisposed("Progress.payload");
|
|
37
37
|
return this.doc.data.payload;
|
|
38
38
|
}
|
|
39
|
+
getUserRank() {
|
|
40
|
+
this.checkDisposed("Progress.getUserRank");
|
|
41
|
+
return this.payload.user_rank;
|
|
42
|
+
}
|
|
43
|
+
getCognitiveLoad() {
|
|
44
|
+
this.checkDisposed("Progress.getCognitiveLoad");
|
|
45
|
+
return this.payload.cognitive_load;
|
|
46
|
+
}
|
|
47
|
+
getPhrases() {
|
|
48
|
+
this.checkDisposed("Progress.getPhrases");
|
|
49
|
+
return this.payload.phrases;
|
|
50
|
+
}
|
|
39
51
|
setUserRank(value) {
|
|
40
52
|
this.checkDisposed("Progress.setUserRank");
|
|
41
53
|
if (this.payload.user_rank !== value) {
|
package/dist/models/Term.d.ts
CHANGED
|
@@ -35,6 +35,14 @@ export declare class Term extends Content {
|
|
|
35
35
|
static forUserPhrase(userId: ContentId, phrase: Phrase): Term;
|
|
36
36
|
static forBuiltinPhrase(userId: ContentId, phrase: BuiltInPhrase): Term;
|
|
37
37
|
get payload(): TermPayload;
|
|
38
|
+
getText(): string;
|
|
39
|
+
getSenseRank(): number;
|
|
40
|
+
getLearnRank(): number;
|
|
41
|
+
getAlpha(): number;
|
|
42
|
+
getBeta(): number;
|
|
43
|
+
getTheta(): number;
|
|
44
|
+
getReviews(): ReviewLike[];
|
|
45
|
+
getStarredAt(): CompactDateTime | null;
|
|
38
46
|
setStarredAt(value: CompactDateTime | null): void;
|
|
39
47
|
updateBayesianScore(alpha: number, beta: number, theta: number): void;
|
|
40
48
|
addReview(review: ReviewLike): void;
|
package/dist/models/Term.js
CHANGED
|
@@ -101,6 +101,38 @@ class Term extends Content_1.Content {
|
|
|
101
101
|
this.checkDisposed("Term.payload");
|
|
102
102
|
return this.doc.data.payload;
|
|
103
103
|
}
|
|
104
|
+
getText() {
|
|
105
|
+
this.checkDisposed("Term.getText");
|
|
106
|
+
return this.payload.text;
|
|
107
|
+
}
|
|
108
|
+
getSenseRank() {
|
|
109
|
+
this.checkDisposed("Term.getSenseRank");
|
|
110
|
+
return this.payload.sense_rank;
|
|
111
|
+
}
|
|
112
|
+
getLearnRank() {
|
|
113
|
+
this.checkDisposed("Term.getLearnRank");
|
|
114
|
+
return this.payload.learn_rank;
|
|
115
|
+
}
|
|
116
|
+
getAlpha() {
|
|
117
|
+
this.checkDisposed("Term.getAlpha");
|
|
118
|
+
return this.payload.alpha;
|
|
119
|
+
}
|
|
120
|
+
getBeta() {
|
|
121
|
+
this.checkDisposed("Term.getBeta");
|
|
122
|
+
return this.payload.beta;
|
|
123
|
+
}
|
|
124
|
+
getTheta() {
|
|
125
|
+
this.checkDisposed("Term.getTheta");
|
|
126
|
+
return this.payload.theta;
|
|
127
|
+
}
|
|
128
|
+
getReviews() {
|
|
129
|
+
this.checkDisposed("Term.getReviews");
|
|
130
|
+
return this.payload.reviews;
|
|
131
|
+
}
|
|
132
|
+
getStarredAt() {
|
|
133
|
+
this.checkDisposed("Term.getStarredAt");
|
|
134
|
+
return this.payload.starred_at;
|
|
135
|
+
}
|
|
104
136
|
setStarredAt(value) {
|
|
105
137
|
this.checkDisposed("Term.setStarredAt");
|
|
106
138
|
if (this.payload.starred_at !== value) {
|
package/dist/models/User.js
CHANGED
|
@@ -12,10 +12,10 @@ export interface JourneyEntry {
|
|
|
12
12
|
export interface WorkspacePayload {
|
|
13
13
|
devices: ContentId[];
|
|
14
14
|
sessions: MultiTime[];
|
|
15
|
-
journey
|
|
15
|
+
journey: {
|
|
16
16
|
[key: string]: CompactDateTime;
|
|
17
17
|
};
|
|
18
|
-
global_tags
|
|
18
|
+
global_tags: TagFilterConfig;
|
|
19
19
|
}
|
|
20
20
|
export interface WorkspaceBody extends ContentBody {
|
|
21
21
|
meta: ContentMeta;
|
|
@@ -26,12 +26,14 @@ export declare class Workspace extends Content {
|
|
|
26
26
|
private _sessionsView;
|
|
27
27
|
constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
|
|
28
28
|
get payload(): WorkspacePayload;
|
|
29
|
+
getGlobalTags(): TagFilterConfig;
|
|
29
30
|
static makeWorkspaceId(userId: ContentId): ContentId;
|
|
30
|
-
static create(userId: ContentId,
|
|
31
|
+
static create(userId: ContentId, payload: WorkspacePayload): Workspace;
|
|
31
32
|
get sessions(): ArrayView<MultiTime>;
|
|
32
33
|
get devices(): ArrayView<ContentId>;
|
|
33
34
|
acquireSessionsFromDate(sessionId: ContentId, localDate: CompactDate): Promise<Session[]>;
|
|
34
35
|
hasJourneyDate(journeyKey: string): boolean;
|
|
35
36
|
getJourneyDate(journeyKey: string): CompactDateTime;
|
|
36
37
|
setJourneyDate(journeyKey: string, journeyDate: CompactDateTime): void;
|
|
38
|
+
setGlobalTags(tags: TagFilterConfig): void;
|
|
37
39
|
}
|
package/dist/models/Workspace.js
CHANGED
|
@@ -17,10 +17,14 @@ class Workspace extends Content_1.Content {
|
|
|
17
17
|
get payload() {
|
|
18
18
|
return this.doc.data.payload;
|
|
19
19
|
}
|
|
20
|
+
getGlobalTags() {
|
|
21
|
+
this.checkDisposed("Workspace.getGlobalTags");
|
|
22
|
+
return this.payload.global_tags;
|
|
23
|
+
}
|
|
20
24
|
static makeWorkspaceId(userId) {
|
|
21
25
|
return shaxpir_common_1.CachingHasher.makeMd5Base62Hash(userId + "-" + ContentKind_1.ContentKind.WORKSPACE);
|
|
22
26
|
}
|
|
23
|
-
static create(userId,
|
|
27
|
+
static create(userId, payload) {
|
|
24
28
|
const now = shaxpir_common_1.MultiClock.now();
|
|
25
29
|
const workspaceId = Workspace.makeWorkspaceId(userId);
|
|
26
30
|
return repo_1.ShareSyncFactory.get().createContent({
|
|
@@ -32,11 +36,7 @@ class Workspace extends Content_1.Content {
|
|
|
32
36
|
created_at: now,
|
|
33
37
|
updated_at: now
|
|
34
38
|
},
|
|
35
|
-
payload
|
|
36
|
-
devices: [deviceId],
|
|
37
|
-
journey: {},
|
|
38
|
-
sessions: []
|
|
39
|
-
}
|
|
39
|
+
payload
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
get sessions() {
|
|
@@ -66,28 +66,25 @@ class Workspace extends Content_1.Content {
|
|
|
66
66
|
}
|
|
67
67
|
hasJourneyDate(journeyKey) {
|
|
68
68
|
this.checkDisposed("Workspace.hasJourneyDate");
|
|
69
|
-
return this.payload.
|
|
69
|
+
return this.payload.journey.hasOwnProperty(journeyKey);
|
|
70
70
|
}
|
|
71
71
|
getJourneyDate(journeyKey) {
|
|
72
72
|
this.checkDisposed("Workspace.getJourneyDate");
|
|
73
|
-
if (this.payload.hasOwnProperty(
|
|
74
|
-
|
|
75
|
-
return this.payload.journey[journeyKey];
|
|
76
|
-
}
|
|
73
|
+
if (this.payload.journey.hasOwnProperty(journeyKey)) {
|
|
74
|
+
return this.payload.journey[journeyKey];
|
|
77
75
|
}
|
|
78
76
|
return null;
|
|
79
77
|
}
|
|
80
78
|
setJourneyDate(journeyKey, journeyDate) {
|
|
81
79
|
this.checkDisposed("Workspace.setJourneyDate");
|
|
82
80
|
const batch = new Operation_1.BatchOperation(this);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
81
|
+
batch.setPathValue(['payload', 'journey', journeyKey], journeyDate);
|
|
82
|
+
batch.commit();
|
|
83
|
+
}
|
|
84
|
+
setGlobalTags(tags) {
|
|
85
|
+
this.checkDisposed("Workspace.setGlobalTags");
|
|
86
|
+
const batch = new Operation_1.BatchOperation(this);
|
|
87
|
+
batch.setPathValue(['payload', 'global_tags'], tags);
|
|
91
88
|
batch.commit();
|
|
92
89
|
}
|
|
93
90
|
}
|