@shaxpir/duiduidui-models 1.7.0 → 1.7.2

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.
@@ -6,7 +6,6 @@ import { Content, ContentBody, ContentId, ContentMeta, ContentRef } from "./Cont
6
6
  import { Review } from './Review';
7
7
  import { UncertainValue } from './Progress';
8
8
  export interface SessionConfig {
9
- version: number;
10
9
  constraints?: {
11
10
  card_limit?: number | null;
12
11
  time_limit?: number;
@@ -16,7 +15,6 @@ export interface SessionConfig {
16
15
  filters?: ConditionFilters;
17
16
  strategy?: {
18
17
  name: string;
19
- version?: string;
20
18
  constants?: Record<string, any>;
21
19
  };
22
20
  };
@@ -57,12 +55,13 @@ export interface SessionPayload {
57
55
  duration_minutes: number;
58
56
  reviews: Review[];
59
57
  review_count: number;
58
+ is_complete: boolean;
59
+ app_version?: string;
60
60
  config?: SessionConfig;
61
61
  metrics?: {
62
62
  before?: SessionMetrics;
63
63
  after?: SessionMetrics;
64
64
  };
65
- is_complete?: boolean;
66
65
  }
67
66
  export interface SessionBody extends ContentBody {
68
67
  meta: ContentMeta;
@@ -73,7 +72,7 @@ export declare class Session extends Content {
73
72
  constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
74
73
  static makeSessionId(userId: ContentId): ContentId;
75
74
  static makeSessionRef(userId: ContentId, at: MultiTime): ContentRef;
76
- static create(userId: ContentId, deviceId: ContentId): Session;
75
+ static create(userId: ContentId, deviceId: ContentId, appVersion: string): Session;
77
76
  get payload(): SessionPayload;
78
77
  touch(): void;
79
78
  get start(): MultiTime;
@@ -93,5 +92,7 @@ export declare class Session extends Content {
93
92
  get metricsAfter(): SessionMetrics | undefined;
94
93
  setMetricsAfter(metrics: SessionMetrics): void;
95
94
  isActive(): boolean;
95
+ get appVersion(): string | undefined;
96
+ setAppVersion(version: string): void;
96
97
  modelUpdated(): Promise<void>;
97
98
  }
@@ -21,7 +21,7 @@ class Session extends Content_1.Content {
21
21
  let sessionId = Session.makeSessionId(userId);
22
22
  return `${sessionId}_${at.utc_time}`;
23
23
  }
24
- static create(userId, deviceId) {
24
+ static create(userId, deviceId, appVersion) {
25
25
  let now = shaxpir_common_1.ClockService.getClock().now();
26
26
  let sessionId = Session.makeSessionId(userId);
27
27
  let sessionRef = Session.makeSessionRef(userId, now);
@@ -37,11 +37,13 @@ class Session extends Content_1.Content {
37
37
  payload: {
38
38
  start: now,
39
39
  end: now,
40
+ is_complete: false,
40
41
  tz_offset: (new Date()).getTimezoneOffset(),
41
42
  duration_minutes: 0,
42
43
  device_id: deviceId,
43
44
  reviews: [],
44
- review_count: 0
45
+ review_count: 0,
46
+ app_version: appVersion
45
47
  }
46
48
  });
47
49
  }
@@ -162,6 +164,16 @@ class Session extends Content_1.Content {
162
164
  const fifteenMinutesAgo = shaxpir_common_1.Time.plus(now.utc_time, -15, 'minutes');
163
165
  return shaxpir_common_1.Time.isDateTimeAfter(this.updatedAt.utc_time, fifteenMinutesAgo);
164
166
  }
167
+ get appVersion() {
168
+ this.checkDisposed("Session.appVersion");
169
+ return this.payload.app_version;
170
+ }
171
+ setAppVersion(version) {
172
+ this.checkDisposed("Session.setAppVersion");
173
+ const batch = new Operation_1.BatchOperation(this);
174
+ batch.setPathValue(['payload', 'app_version'], version);
175
+ batch.commit();
176
+ }
165
177
  async modelUpdated() {
166
178
  this.checkDisposed("Session.modelUpdated");
167
179
  await super.modelUpdated();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"