@shaxpir/duiduidui-models 1.5.7 → 1.5.9
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.
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { CompactDateTime } from "@shaxpir/shaxpir-common";
|
|
2
|
+
export interface BaseCondition {
|
|
3
|
+
type: string;
|
|
4
|
+
}
|
|
5
|
+
export interface TagCondition extends BaseCondition {
|
|
6
|
+
type: 'tag';
|
|
7
|
+
tag: string;
|
|
8
|
+
}
|
|
9
|
+
export interface GradeCondition extends BaseCondition {
|
|
10
|
+
type: 'grade';
|
|
11
|
+
grade: 'A' | 'B' | 'C' | 'D' | 'F';
|
|
12
|
+
}
|
|
13
|
+
export interface ThetaCondition extends BaseCondition {
|
|
14
|
+
type: 'theta';
|
|
15
|
+
min?: number;
|
|
16
|
+
max?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface TemporalCondition extends BaseCondition {
|
|
19
|
+
type: 'temporal';
|
|
20
|
+
field: 'last_review_utc' | 'starred_at' | 'created_at' | 'updated_at';
|
|
21
|
+
operator: '>' | '<' | '>=' | '<=' | '=' | '!=';
|
|
22
|
+
days?: number;
|
|
23
|
+
timestamp?: CompactDateTime;
|
|
24
|
+
}
|
|
25
|
+
export interface CountCondition extends BaseCondition {
|
|
26
|
+
type: 'count';
|
|
27
|
+
field: 'review_count' | 'implied_review_count';
|
|
28
|
+
operator: '>' | '<' | '>=' | '<=' | '=' | '!=';
|
|
29
|
+
value: number;
|
|
30
|
+
}
|
|
31
|
+
export interface StarredCondition extends BaseCondition {
|
|
32
|
+
type: 'starred';
|
|
33
|
+
value: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface DifficultyCondition extends BaseCondition {
|
|
36
|
+
type: 'difficulty';
|
|
37
|
+
min?: number;
|
|
38
|
+
max?: number;
|
|
39
|
+
}
|
|
40
|
+
export type AnyCondition = TagCondition | GradeCondition | ThetaCondition | TemporalCondition | CountCondition | StarredCondition | DifficultyCondition;
|
|
41
|
+
export interface ConditionFilters {
|
|
42
|
+
all?: AnyCondition[];
|
|
43
|
+
any?: AnyCondition[];
|
|
44
|
+
none?: AnyCondition[];
|
|
45
|
+
}
|
|
46
|
+
export declare const Condition: {
|
|
47
|
+
tag: (name: string) => TagCondition;
|
|
48
|
+
grade: (grade: "A" | "B" | "C" | "D" | "F") => GradeCondition;
|
|
49
|
+
gradeA: () => GradeCondition;
|
|
50
|
+
gradeB: () => GradeCondition;
|
|
51
|
+
gradeC: () => GradeCondition;
|
|
52
|
+
gradeD: () => GradeCondition;
|
|
53
|
+
gradeF: () => GradeCondition;
|
|
54
|
+
theta: (min?: number, max?: number) => ThetaCondition;
|
|
55
|
+
learningZone: () => ThetaCondition;
|
|
56
|
+
struggling: () => ThetaCondition;
|
|
57
|
+
nearMastery: () => ThetaCondition;
|
|
58
|
+
mastered: () => ThetaCondition;
|
|
59
|
+
daysSince: (field: "last_review_utc" | "starred_at" | "created_at" | "updated_at", operator: ">" | "<" | ">=" | "<=", days: number) => TemporalCondition;
|
|
60
|
+
stale: (days?: number) => TemporalCondition;
|
|
61
|
+
fresh: (days?: number) => TemporalCondition;
|
|
62
|
+
recentlyStarred: (days?: number) => TemporalCondition;
|
|
63
|
+
count: (field: "review_count" | "implied_review_count", operator: ">" | "<" | ">=" | "<=" | "=" | "!=", value: number) => CountCondition;
|
|
64
|
+
neverReviewed: () => CountCondition;
|
|
65
|
+
reviewed: () => CountCondition;
|
|
66
|
+
wellPracticed: (minReviews?: number) => CountCondition;
|
|
67
|
+
starred: () => StarredCondition;
|
|
68
|
+
notStarred: () => StarredCondition;
|
|
69
|
+
difficulty: (min?: number, max?: number) => DifficultyCondition;
|
|
70
|
+
beginner: () => DifficultyCondition;
|
|
71
|
+
elementary: () => DifficultyCondition;
|
|
72
|
+
intermediate: () => DifficultyCondition;
|
|
73
|
+
advanced: () => DifficultyCondition;
|
|
74
|
+
expert: () => DifficultyCondition;
|
|
75
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Condition = void 0;
|
|
4
|
+
// Factory functions for creating conditions
|
|
5
|
+
exports.Condition = {
|
|
6
|
+
// Tag conditions
|
|
7
|
+
tag: (name) => ({ type: 'tag', tag: name }),
|
|
8
|
+
// Grade conditions
|
|
9
|
+
grade: (grade) => ({ type: 'grade', grade }),
|
|
10
|
+
gradeA: () => ({ type: 'grade', grade: 'A' }),
|
|
11
|
+
gradeB: () => ({ type: 'grade', grade: 'B' }),
|
|
12
|
+
gradeC: () => ({ type: 'grade', grade: 'C' }),
|
|
13
|
+
gradeD: () => ({ type: 'grade', grade: 'D' }),
|
|
14
|
+
gradeF: () => ({ type: 'grade', grade: 'F' }),
|
|
15
|
+
// Theta conditions
|
|
16
|
+
theta: (min, max) => ({ type: 'theta', min, max }),
|
|
17
|
+
learningZone: () => ({ type: 'theta', min: 0.4, max: 0.6 }),
|
|
18
|
+
struggling: () => ({ type: 'theta', max: 0.3 }),
|
|
19
|
+
nearMastery: () => ({ type: 'theta', min: 0.7, max: 0.8 }),
|
|
20
|
+
mastered: () => ({ type: 'theta', min: 0.8 }),
|
|
21
|
+
// Temporal conditions
|
|
22
|
+
daysSince: (field, operator, days) => ({ type: 'temporal', field, operator, days }),
|
|
23
|
+
stale: (days = 7) => ({ type: 'temporal', field: 'last_review_utc', operator: '>', days }),
|
|
24
|
+
fresh: (days = 1) => ({ type: 'temporal', field: 'last_review_utc', operator: '<=', days }),
|
|
25
|
+
recentlyStarred: (days = 7) => ({ type: 'temporal', field: 'starred_at', operator: '<=', days }),
|
|
26
|
+
// Count conditions
|
|
27
|
+
count: (field, operator, value) => ({ type: 'count', field, operator, value }),
|
|
28
|
+
neverReviewed: () => ({ type: 'count', field: 'review_count', operator: '=', value: 0 }),
|
|
29
|
+
reviewed: () => ({ type: 'count', field: 'review_count', operator: '>', value: 0 }),
|
|
30
|
+
wellPracticed: (minReviews = 10) => ({ type: 'count', field: 'review_count', operator: '>', value: minReviews }),
|
|
31
|
+
// Starred condition
|
|
32
|
+
starred: () => ({ type: 'starred', value: true }),
|
|
33
|
+
notStarred: () => ({ type: 'starred', value: false }),
|
|
34
|
+
// Difficulty conditions
|
|
35
|
+
difficulty: (min, max) => ({ type: 'difficulty', min, max }),
|
|
36
|
+
beginner: () => ({ type: 'difficulty', max: 100 }), // Very easy content
|
|
37
|
+
elementary: () => ({ type: 'difficulty', min: 100, max: 500 }), // Easy
|
|
38
|
+
intermediate: () => ({ type: 'difficulty', min: 500, max: 1500 }), // Medium
|
|
39
|
+
advanced: () => ({ type: 'difficulty', min: 1500, max: 3000 }), // Hard
|
|
40
|
+
expert: () => ({ type: 'difficulty', min: 3000 }) // Very hard
|
|
41
|
+
};
|
package/dist/models/Device.d.ts
CHANGED
|
@@ -2,20 +2,16 @@ import { Doc } from '@shaxpir/sharedb/lib/client';
|
|
|
2
2
|
import { CompactDateTime } from "@shaxpir/shaxpir-common";
|
|
3
3
|
import { ShareSync } from '../repo';
|
|
4
4
|
import { Content, ContentBody, ContentId, ContentMeta } from "./Content";
|
|
5
|
+
import { ConditionFilters } from './Condition';
|
|
5
6
|
export interface LastSync {
|
|
6
7
|
at_utc_time: CompactDateTime | null;
|
|
7
8
|
}
|
|
8
|
-
export interface TagFilterConfig {
|
|
9
|
-
any?: string[];
|
|
10
|
-
all?: string[];
|
|
11
|
-
none?: string[];
|
|
12
|
-
}
|
|
13
9
|
export interface DevicePayload {
|
|
14
10
|
last_sync?: LastSync;
|
|
15
11
|
chinese_font?: string;
|
|
16
12
|
raw_search_text?: string;
|
|
17
13
|
star_filter?: boolean;
|
|
18
|
-
|
|
14
|
+
conditions?: ConditionFilters;
|
|
19
15
|
}
|
|
20
16
|
export interface DeviceBody extends ContentBody {
|
|
21
17
|
meta: ContentMeta;
|
|
@@ -3,7 +3,7 @@ import { CompactDate, CompactDateTime, MultiTime } from "@shaxpir/shaxpir-common
|
|
|
3
3
|
import { ShareSync } from '../repo';
|
|
4
4
|
import { ArrayView } from './ArrayView';
|
|
5
5
|
import { Content, ContentBody, ContentId, ContentMeta } from "./Content";
|
|
6
|
-
import {
|
|
6
|
+
import { ConditionFilters } from './Condition';
|
|
7
7
|
import { Session } from './Session';
|
|
8
8
|
export interface JourneyEntry {
|
|
9
9
|
key: string;
|
|
@@ -15,7 +15,7 @@ export interface WorkspacePayload {
|
|
|
15
15
|
journey: {
|
|
16
16
|
[key: string]: CompactDateTime;
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
global_conditions: ConditionFilters;
|
|
19
19
|
}
|
|
20
20
|
export interface WorkspaceBody extends ContentBody {
|
|
21
21
|
meta: ContentMeta;
|
|
@@ -26,7 +26,7 @@ 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
|
-
|
|
29
|
+
getGlobalConditions(): ConditionFilters;
|
|
30
30
|
static makeWorkspaceId(userId: ContentId): ContentId;
|
|
31
31
|
static create(userId: ContentId, payload: WorkspacePayload): Workspace;
|
|
32
32
|
get sessions(): ArrayView<MultiTime>;
|
|
@@ -36,5 +36,5 @@ export declare class Workspace extends Content {
|
|
|
36
36
|
hasJourneyDate(journeyKey: string): boolean;
|
|
37
37
|
getJourneyDate(journeyKey: string): CompactDateTime;
|
|
38
38
|
setJourneyDate(journeyKey: string, journeyDate: CompactDateTime): void;
|
|
39
|
-
|
|
39
|
+
setGlobalConditions(filters: ConditionFilters): void;
|
|
40
40
|
}
|
package/dist/models/Workspace.js
CHANGED
|
@@ -17,9 +17,9 @@ class Workspace extends Content_1.Content {
|
|
|
17
17
|
get payload() {
|
|
18
18
|
return this.doc.data.payload;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
this.checkDisposed("Workspace.
|
|
22
|
-
return this.payload.
|
|
20
|
+
getGlobalConditions() {
|
|
21
|
+
this.checkDisposed("Workspace.getGlobalConditions");
|
|
22
|
+
return this.payload.global_conditions;
|
|
23
23
|
}
|
|
24
24
|
static makeWorkspaceId(userId) {
|
|
25
25
|
return shaxpir_common_1.CachingHasher.makeMd5Base62Hash(userId + "-" + ContentKind_1.ContentKind.WORKSPACE);
|
|
@@ -100,10 +100,10 @@ class Workspace extends Content_1.Content {
|
|
|
100
100
|
batch.setPathValue(['payload', 'journey', journeyKey], journeyDate);
|
|
101
101
|
batch.commit();
|
|
102
102
|
}
|
|
103
|
-
|
|
104
|
-
this.checkDisposed("Workspace.
|
|
103
|
+
setGlobalConditions(filters) {
|
|
104
|
+
this.checkDisposed("Workspace.setGlobalConditions");
|
|
105
105
|
const batch = new Operation_1.BatchOperation(this);
|
|
106
|
-
batch.setPathValue(['payload', '
|
|
106
|
+
batch.setPathValue(['payload', 'global_conditions'], filters);
|
|
107
107
|
batch.commit();
|
|
108
108
|
}
|
|
109
109
|
}
|
package/dist/models/index.d.ts
CHANGED
package/dist/models/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./ArrayView"), exports);
|
|
|
19
19
|
__exportStar(require("./BayesianScore"), exports);
|
|
20
20
|
__exportStar(require("./Billing"), exports);
|
|
21
21
|
__exportStar(require("./ChangeModel"), exports);
|
|
22
|
+
__exportStar(require("./Condition"), exports);
|
|
22
23
|
__exportStar(require("./Content"), exports);
|
|
23
24
|
__exportStar(require("./ContentKind"), exports);
|
|
24
25
|
__exportStar(require("./Device"), exports);
|