@shaxpir/duiduidui-models 1.32.0 → 1.33.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/Device.d.ts +12 -0
- package/dist/models/Device.js +62 -2
- package/dist/models/Session.d.ts +5 -4
- package/package.json +1 -1
package/dist/models/Device.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { CompactDateTime } from "@shaxpir/shaxpir-common";
|
|
|
3
3
|
import { ShareSync } from '../repo';
|
|
4
4
|
import { Content, ContentBody, ContentId, ContentMeta } from "./Content";
|
|
5
5
|
import { Conditions } from './Condition';
|
|
6
|
+
import { ChallengeLevel, ReviewConfig } from './Session';
|
|
6
7
|
import { BuiltInDbState, DatabaseVersion } from '../util/Database';
|
|
7
8
|
import { SearchHistory, SearchState } from './SearchState';
|
|
8
9
|
export interface LastSync {
|
|
@@ -29,6 +30,7 @@ export interface ImageUploadQueueItem extends BaseQueueItem {
|
|
|
29
30
|
image_id: ContentId;
|
|
30
31
|
}
|
|
31
32
|
export type UploadQueueItem = ImageUploadQueueItem;
|
|
33
|
+
export declare const DEFAULT_REVIEW_CONFIG: ReviewConfig;
|
|
32
34
|
export interface DevicePayload {
|
|
33
35
|
last_sync?: LastSync;
|
|
34
36
|
chinese_font?: string;
|
|
@@ -39,6 +41,8 @@ export interface DevicePayload {
|
|
|
39
41
|
upload_queue?: UploadQueueItem[];
|
|
40
42
|
builtin_db?: BuiltInDbState;
|
|
41
43
|
search_history: SearchHistory;
|
|
44
|
+
review_config: ReviewConfig;
|
|
45
|
+
review_custom_conditions: Conditions;
|
|
42
46
|
}
|
|
43
47
|
export interface DeviceBody extends ContentBody {
|
|
44
48
|
meta: ContentMeta;
|
|
@@ -54,6 +58,14 @@ export declare class Device extends Content {
|
|
|
54
58
|
setLastSyncAtUtcTime(value: CompactDateTime): void;
|
|
55
59
|
get chineseFont(): string;
|
|
56
60
|
setChineseFont(value: string): void;
|
|
61
|
+
get reviewConfig(): ReviewConfig;
|
|
62
|
+
setReviewShowPinyin(value: boolean): void;
|
|
63
|
+
setReviewAutoPlaySpeech(value: boolean): void;
|
|
64
|
+
setReviewCardLimit(value: number | null): void;
|
|
65
|
+
setReviewChallenge(value: ChallengeLevel): void;
|
|
66
|
+
setReviewCollection(value: string | undefined): void;
|
|
67
|
+
get reviewCustomConditions(): Conditions;
|
|
68
|
+
setReviewCustomConditions(value: Conditions): void;
|
|
57
69
|
getBuiltInDbState(): BuiltInDbState | undefined;
|
|
58
70
|
getBuiltInDbVersion(): DatabaseVersion;
|
|
59
71
|
getBuiltInDbPendingVersion(): DatabaseVersion;
|
package/dist/models/Device.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Device = void 0;
|
|
3
|
+
exports.Device = exports.DEFAULT_REVIEW_CONFIG = void 0;
|
|
4
4
|
const shaxpir_common_1 = require("@shaxpir/shaxpir-common");
|
|
5
5
|
const repo_1 = require("../repo");
|
|
6
6
|
const ArrayView_1 = require("./ArrayView");
|
|
@@ -8,6 +8,18 @@ const Content_1 = require("./Content");
|
|
|
8
8
|
const ContentKind_1 = require("./ContentKind");
|
|
9
9
|
const Operation_1 = require("./Operation");
|
|
10
10
|
const SearchState_1 = require("./SearchState");
|
|
11
|
+
exports.DEFAULT_REVIEW_CONFIG = {
|
|
12
|
+
display: {
|
|
13
|
+
show_pinyin: true,
|
|
14
|
+
auto_play_speech: true,
|
|
15
|
+
},
|
|
16
|
+
constraints: {
|
|
17
|
+
card_limit: 25,
|
|
18
|
+
},
|
|
19
|
+
selection: {
|
|
20
|
+
challenge: 'easy',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
11
23
|
class Device extends Content_1.Content {
|
|
12
24
|
static create(userId, deviceId) {
|
|
13
25
|
const now = shaxpir_common_1.ClockService.getClock().now();
|
|
@@ -31,7 +43,9 @@ class Device extends Content_1.Content {
|
|
|
31
43
|
last_check: null,
|
|
32
44
|
last_error: null
|
|
33
45
|
},
|
|
34
|
-
search_history: (0, SearchState_1.createEmptySearchHistory)()
|
|
46
|
+
search_history: (0, SearchState_1.createEmptySearchHistory)(),
|
|
47
|
+
review_config: { ...exports.DEFAULT_REVIEW_CONFIG },
|
|
48
|
+
review_custom_conditions: {},
|
|
35
49
|
}
|
|
36
50
|
});
|
|
37
51
|
}
|
|
@@ -68,6 +82,52 @@ class Device extends Content_1.Content {
|
|
|
68
82
|
batch.commit();
|
|
69
83
|
}
|
|
70
84
|
}
|
|
85
|
+
// Review Config
|
|
86
|
+
get reviewConfig() {
|
|
87
|
+
this.checkDisposed("Device.reviewConfig");
|
|
88
|
+
return this.payload.review_config || exports.DEFAULT_REVIEW_CONFIG;
|
|
89
|
+
}
|
|
90
|
+
setReviewShowPinyin(value) {
|
|
91
|
+
this.checkDisposed("Device.setReviewShowPinyin");
|
|
92
|
+
const batch = new Operation_1.BatchOperation(this);
|
|
93
|
+
batch.setPathValue(['payload', 'review_config', 'display', 'show_pinyin'], value);
|
|
94
|
+
batch.commit();
|
|
95
|
+
}
|
|
96
|
+
setReviewAutoPlaySpeech(value) {
|
|
97
|
+
this.checkDisposed("Device.setReviewAutoPlaySpeech");
|
|
98
|
+
const batch = new Operation_1.BatchOperation(this);
|
|
99
|
+
batch.setPathValue(['payload', 'review_config', 'display', 'auto_play_speech'], value);
|
|
100
|
+
batch.commit();
|
|
101
|
+
}
|
|
102
|
+
setReviewCardLimit(value) {
|
|
103
|
+
this.checkDisposed("Device.setReviewCardLimit");
|
|
104
|
+
const batch = new Operation_1.BatchOperation(this);
|
|
105
|
+
batch.setPathValue(['payload', 'review_config', 'constraints', 'card_limit'], value);
|
|
106
|
+
batch.commit();
|
|
107
|
+
}
|
|
108
|
+
setReviewChallenge(value) {
|
|
109
|
+
this.checkDisposed("Device.setReviewChallenge");
|
|
110
|
+
const batch = new Operation_1.BatchOperation(this);
|
|
111
|
+
batch.setPathValue(['payload', 'review_config', 'selection', 'challenge'], value);
|
|
112
|
+
batch.commit();
|
|
113
|
+
}
|
|
114
|
+
setReviewCollection(value) {
|
|
115
|
+
this.checkDisposed("Device.setReviewCollection");
|
|
116
|
+
const batch = new Operation_1.BatchOperation(this);
|
|
117
|
+
batch.setPathValue(['payload', 'review_config', 'selection', 'collection'], value);
|
|
118
|
+
batch.commit();
|
|
119
|
+
}
|
|
120
|
+
// Review Custom Conditions (for Custom mode)
|
|
121
|
+
get reviewCustomConditions() {
|
|
122
|
+
this.checkDisposed("Device.reviewCustomConditions");
|
|
123
|
+
return this.payload.review_custom_conditions || {};
|
|
124
|
+
}
|
|
125
|
+
setReviewCustomConditions(value) {
|
|
126
|
+
this.checkDisposed("Device.setReviewCustomConditions");
|
|
127
|
+
const batch = new Operation_1.BatchOperation(this);
|
|
128
|
+
batch.setPathValue(['payload', 'review_custom_conditions'], value);
|
|
129
|
+
batch.commit();
|
|
130
|
+
}
|
|
71
131
|
// Built-in Database State Methods
|
|
72
132
|
getBuiltInDbState() {
|
|
73
133
|
this.checkDisposed("Device.getBuiltInDbState");
|
package/dist/models/Session.d.ts
CHANGED
|
@@ -10,12 +10,13 @@ import { SkillLevel } from './SkillLevel';
|
|
|
10
10
|
* beyond their current skill level.
|
|
11
11
|
*/
|
|
12
12
|
export type ChallengeLevel = 'easy' | 'mild' | 'medium' | 'hard' | 'max';
|
|
13
|
-
export interface
|
|
13
|
+
export interface ReviewConfig {
|
|
14
14
|
constraints?: {
|
|
15
15
|
card_limit?: number | null;
|
|
16
16
|
time_limit?: number;
|
|
17
17
|
};
|
|
18
18
|
selection?: {
|
|
19
|
+
collection?: string;
|
|
19
20
|
challenge?: ChallengeLevel;
|
|
20
21
|
filters?: Conditions;
|
|
21
22
|
strategy?: {
|
|
@@ -62,7 +63,7 @@ export interface SessionPayload {
|
|
|
62
63
|
review_count: number;
|
|
63
64
|
is_complete: boolean;
|
|
64
65
|
app_version?: string;
|
|
65
|
-
config?:
|
|
66
|
+
config?: ReviewConfig;
|
|
66
67
|
stats?: {
|
|
67
68
|
before?: SessionStats;
|
|
68
69
|
after?: SessionStats;
|
|
@@ -88,8 +89,8 @@ export declare class Session extends Content {
|
|
|
88
89
|
get reviews(): Review[];
|
|
89
90
|
get reviewCount(): number;
|
|
90
91
|
addReview(review: Review): void;
|
|
91
|
-
get config():
|
|
92
|
-
setConfig(config:
|
|
92
|
+
get config(): ReviewConfig | undefined;
|
|
93
|
+
setConfig(config: ReviewConfig): void;
|
|
93
94
|
get isComplete(): boolean;
|
|
94
95
|
markComplete(): void;
|
|
95
96
|
get statsBefore(): SessionStats | undefined;
|