@speakableio/core 1.0.0 → 1.0.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.
- package/dist/analytics.d.mts +38 -1
- package/dist/analytics.js +117 -1
- package/dist/analytics.js.map +1 -1
- package/dist/index.native.js +15 -1
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +15 -1
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.web.js +15 -1
- package/dist/index.web.js.map +1 -1
- package/package.json +2 -2
- package/dist/analytics-Bj2i88Zk.d.ts +0 -89
- package/dist/analytics.d.ts +0 -88
- package/dist/assignment.constants-BIKM6fYi.d.ts +0 -32
- package/dist/assignment.model-BRS4h8gX.d.ts +0 -301
- package/dist/assignment.model-Bc61gBHl.d.ts +0 -302
- package/dist/assignment.model-Bm9gE2YK.d.ts +0 -301
- package/dist/card.constants-DhKFipX3.d.ts +0 -54
- package/dist/const.d.ts +0 -261
- package/dist/const.js +0 -503
- package/dist/const.js.map +0 -1
- package/dist/everything.d.ts +0 -1348
- package/dist/everything.js +0 -3509
- package/dist/everything.js.map +0 -1
- package/dist/hooks.d.ts +0 -911
- package/dist/hooks.js +0 -2699
- package/dist/hooks.js.map +0 -1
- package/dist/index.web-DNYJV_41.d.ts +0 -469
- package/dist/index.web.d.ts +0 -471
- package/dist/models.d.ts +0 -56
- package/dist/models.js +0 -52
- package/dist/models.js.map +0 -1
- package/dist/notification.constants-B72fb734.d.ts +0 -21
- package/dist/repos.d.ts +0 -209
- package/dist/repos.js +0 -453
- package/dist/repos.js.map +0 -1
- package/dist/speakable-plans-BjWWEWrQ.d.ts +0 -72
- package/dist/speakable-plans-DR1cQ6IK.d.ts +0 -92
- package/dist/speakable-plans-Dq9nRefI.d.ts +0 -72
- package/dist/utils.d.ts +0 -121
- package/dist/utils.js +0 -646
- package/dist/utils.js.map +0 -1
- package/dist/web.constants-qmx4rGyO.d.ts +0 -26
package/dist/repos.d.ts
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { A as AssignmentWithId, C as CustomTimestamp, a as ActivityPageType, P as PageActivity, b as PageActivityWithId } from './assignment.model-Bm9gE2YK.js';
|
|
2
|
-
import { A as AssignmentAnalyticsType } from './assignment.constants-BIKM6fYi.js';
|
|
3
|
-
import { V as VerificationCardStatus } from './card.constants-DhKFipX3.js';
|
|
4
|
-
import { SetWithId } from './models.js';
|
|
5
|
-
import '@react-native-firebase/firestore';
|
|
6
|
-
import 'firebase/firestore';
|
|
7
|
-
|
|
8
|
-
declare const createAssignmentRepo: () => {
|
|
9
|
-
getAssignment: (params: {
|
|
10
|
-
assignmentId: string;
|
|
11
|
-
currentUserId: string;
|
|
12
|
-
analyticType?: AssignmentAnalyticsType;
|
|
13
|
-
studentId?: string;
|
|
14
|
-
}) => Promise<AssignmentWithId | {
|
|
15
|
-
scores: any;
|
|
16
|
-
id: string;
|
|
17
|
-
isAvailable: boolean;
|
|
18
|
-
name: string;
|
|
19
|
-
description: string;
|
|
20
|
-
scheduledTime?: string | null;
|
|
21
|
-
dueTime?: {
|
|
22
|
-
hours: number;
|
|
23
|
-
minutes: number;
|
|
24
|
-
nanos: number;
|
|
25
|
-
};
|
|
26
|
-
speakableio: boolean;
|
|
27
|
-
owners: string[];
|
|
28
|
-
image: {
|
|
29
|
-
path: string | null;
|
|
30
|
-
url: string;
|
|
31
|
-
};
|
|
32
|
-
dueDate: {
|
|
33
|
-
day: number;
|
|
34
|
-
month: number;
|
|
35
|
-
year: number;
|
|
36
|
-
};
|
|
37
|
-
teacherName: string;
|
|
38
|
-
courseWorkId: string | null;
|
|
39
|
-
dueDateTimestamp: CustomTimestamp;
|
|
40
|
-
scheduledTimeTimestamp: number;
|
|
41
|
-
active: boolean;
|
|
42
|
-
voice: string | null;
|
|
43
|
-
setId: string;
|
|
44
|
-
dateMade: {
|
|
45
|
-
seconds: number;
|
|
46
|
-
nanoseconds: number;
|
|
47
|
-
};
|
|
48
|
-
maxPoints: number;
|
|
49
|
-
courseId: string;
|
|
50
|
-
isAssessment: boolean;
|
|
51
|
-
ltiDeeplink?: string;
|
|
52
|
-
content?: string[];
|
|
53
|
-
weights?: Record<string, number>;
|
|
54
|
-
language?: string;
|
|
55
|
-
types?: { [key in ActivityPageType]?: number; };
|
|
56
|
-
aiEnabled?: boolean;
|
|
57
|
-
chat_experience?: boolean;
|
|
58
|
-
} | null>;
|
|
59
|
-
attachScoresAssignment: (args_0: {
|
|
60
|
-
assignments: AssignmentWithId[];
|
|
61
|
-
analyticType: AssignmentAnalyticsType;
|
|
62
|
-
studentId?: string;
|
|
63
|
-
currentUserId: string;
|
|
64
|
-
}) => Promise<{
|
|
65
|
-
scores: any;
|
|
66
|
-
id: string;
|
|
67
|
-
isAvailable: boolean;
|
|
68
|
-
name: string;
|
|
69
|
-
description: string;
|
|
70
|
-
scheduledTime?: string | null;
|
|
71
|
-
dueTime?: {
|
|
72
|
-
hours: number;
|
|
73
|
-
minutes: number;
|
|
74
|
-
nanos: number;
|
|
75
|
-
};
|
|
76
|
-
speakableio: boolean;
|
|
77
|
-
owners: string[];
|
|
78
|
-
image: {
|
|
79
|
-
path: string | null;
|
|
80
|
-
url: string;
|
|
81
|
-
};
|
|
82
|
-
dueDate: {
|
|
83
|
-
day: number;
|
|
84
|
-
month: number;
|
|
85
|
-
year: number;
|
|
86
|
-
};
|
|
87
|
-
teacherName: string;
|
|
88
|
-
courseWorkId: string | null;
|
|
89
|
-
dueDateTimestamp: CustomTimestamp;
|
|
90
|
-
scheduledTimeTimestamp: number;
|
|
91
|
-
active: boolean;
|
|
92
|
-
voice: string | null;
|
|
93
|
-
setId: string;
|
|
94
|
-
dateMade: {
|
|
95
|
-
seconds: number;
|
|
96
|
-
nanoseconds: number;
|
|
97
|
-
};
|
|
98
|
-
maxPoints: number;
|
|
99
|
-
courseId: string;
|
|
100
|
-
isAssessment: boolean;
|
|
101
|
-
ltiDeeplink?: string;
|
|
102
|
-
content?: string[];
|
|
103
|
-
weights?: Record<string, number>;
|
|
104
|
-
language?: string;
|
|
105
|
-
types?: { [key in ActivityPageType]?: number; };
|
|
106
|
-
aiEnabled?: boolean;
|
|
107
|
-
chat_experience?: boolean;
|
|
108
|
-
}[]>;
|
|
109
|
-
getAssignmentScores: (args_0: {
|
|
110
|
-
assignmentId: string;
|
|
111
|
-
currentUserId: string;
|
|
112
|
-
analyticType?: AssignmentAnalyticsType;
|
|
113
|
-
studentId?: string;
|
|
114
|
-
}) => Promise<{
|
|
115
|
-
scores: unknown;
|
|
116
|
-
id: string;
|
|
117
|
-
} | undefined>;
|
|
118
|
-
getAllAssignments: () => Promise<(AssignmentWithId & {
|
|
119
|
-
id: string;
|
|
120
|
-
})[]>;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
declare const createCardRepo: () => {
|
|
124
|
-
createCard: (args_0: {
|
|
125
|
-
data: Partial<PageActivity>;
|
|
126
|
-
}) => Promise<{
|
|
127
|
-
id: string;
|
|
128
|
-
} & Partial<PageActivity>>;
|
|
129
|
-
createCards: (args_0: {
|
|
130
|
-
cards: PageActivity[];
|
|
131
|
-
}) => Promise<{
|
|
132
|
-
id: string;
|
|
133
|
-
owners: string[];
|
|
134
|
-
checked?: boolean;
|
|
135
|
-
completed?: boolean;
|
|
136
|
-
media_area_id?: string | null;
|
|
137
|
-
media_area_layout?: "left" | "right" | null;
|
|
138
|
-
score?: number;
|
|
139
|
-
verificationStatus?: VerificationCardStatus;
|
|
140
|
-
native_text?: string;
|
|
141
|
-
repeat?: number;
|
|
142
|
-
language?: string | null;
|
|
143
|
-
image?: {
|
|
144
|
-
path?: string | null;
|
|
145
|
-
url?: string;
|
|
146
|
-
};
|
|
147
|
-
audio?: {
|
|
148
|
-
path?: string | null;
|
|
149
|
-
url?: string;
|
|
150
|
-
} | null;
|
|
151
|
-
notes?: string;
|
|
152
|
-
difficulty?: string;
|
|
153
|
-
default_language?: string;
|
|
154
|
-
target_text?: string;
|
|
155
|
-
type: ActivityPageType;
|
|
156
|
-
grading_criteria?: string;
|
|
157
|
-
scoring_type?: string;
|
|
158
|
-
grading_method?: "simple" | "rubric" | "manual" | "standards_based";
|
|
159
|
-
feedback_types?: string[];
|
|
160
|
-
rubricId?: string;
|
|
161
|
-
prompt?: string;
|
|
162
|
-
title?: string;
|
|
163
|
-
passing_score?: number;
|
|
164
|
-
maxCharacters?: number;
|
|
165
|
-
answer?: string[];
|
|
166
|
-
choices?: {
|
|
167
|
-
value: string;
|
|
168
|
-
option: string;
|
|
169
|
-
}[];
|
|
170
|
-
MCQType?: string;
|
|
171
|
-
multipleAttemptsAllowed?: boolean;
|
|
172
|
-
allowRetries?: boolean;
|
|
173
|
-
question?: string;
|
|
174
|
-
respondTime?: number;
|
|
175
|
-
hidePrompt?: boolean;
|
|
176
|
-
videoUrl?: string;
|
|
177
|
-
link?: string;
|
|
178
|
-
text?: string;
|
|
179
|
-
isListenAloud?: boolean;
|
|
180
|
-
embedCode?: string;
|
|
181
|
-
attempt?: number;
|
|
182
|
-
correct?: number;
|
|
183
|
-
autoGrade?: boolean;
|
|
184
|
-
points?: number;
|
|
185
|
-
shuffle?: boolean;
|
|
186
|
-
translation?: string;
|
|
187
|
-
includeAIContext?: boolean;
|
|
188
|
-
media_area_context_ref?: string | null;
|
|
189
|
-
standardId?: string;
|
|
190
|
-
target_proficiency_level?: string;
|
|
191
|
-
allowTTS?: boolean;
|
|
192
|
-
feedback_language?: string | null;
|
|
193
|
-
correct_answer?: string | null;
|
|
194
|
-
limit_attempts?: boolean;
|
|
195
|
-
max_attempts?: number;
|
|
196
|
-
rich_text?: string;
|
|
197
|
-
}[]>;
|
|
198
|
-
getCard: (params: {
|
|
199
|
-
cardId: string;
|
|
200
|
-
}) => Promise<PageActivityWithId | null>;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
declare const createSetRepo: () => {
|
|
204
|
-
getSet: (args_0: {
|
|
205
|
-
setId: string;
|
|
206
|
-
}) => Promise<SetWithId | null>;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
export { createAssignmentRepo, createCardRepo, createSetRepo };
|
package/dist/repos.js
DELETED
|
@@ -1,453 +0,0 @@
|
|
|
1
|
-
// src/utils/error-handler.ts
|
|
2
|
-
var ServiceError = class extends Error {
|
|
3
|
-
constructor(message, originalError, code) {
|
|
4
|
-
super(message);
|
|
5
|
-
this.originalError = originalError;
|
|
6
|
-
this.code = code;
|
|
7
|
-
this.name = "ServiceError";
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
function withErrorHandler(fn, serviceName) {
|
|
11
|
-
return async (...args) => {
|
|
12
|
-
try {
|
|
13
|
-
return await fn(...args);
|
|
14
|
-
} catch (error) {
|
|
15
|
-
if (error instanceof Error && "code" in error) {
|
|
16
|
-
const firebaseError = error;
|
|
17
|
-
throw new ServiceError(
|
|
18
|
-
`Error in ${serviceName}: ${firebaseError.message}`,
|
|
19
|
-
error,
|
|
20
|
-
firebaseError.code
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
if (error instanceof Error) {
|
|
24
|
-
throw new ServiceError(`Error in ${serviceName}: ${error.message}`, error);
|
|
25
|
-
}
|
|
26
|
-
throw new ServiceError(`Unknown error in ${serviceName}`, error);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// src/lib/firebase/api.ts
|
|
32
|
-
var FirebaseAPI = class _FirebaseAPI {
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
34
|
-
constructor() {
|
|
35
|
-
this.config = null;
|
|
36
|
-
}
|
|
37
|
-
static getInstance() {
|
|
38
|
-
if (!_FirebaseAPI.instance) {
|
|
39
|
-
_FirebaseAPI.instance = new _FirebaseAPI();
|
|
40
|
-
}
|
|
41
|
-
return _FirebaseAPI.instance;
|
|
42
|
-
}
|
|
43
|
-
initialize(config) {
|
|
44
|
-
this.config = config;
|
|
45
|
-
}
|
|
46
|
-
get db() {
|
|
47
|
-
if (!this.config) throw new Error("Firebase API not initialized");
|
|
48
|
-
return this.config.db;
|
|
49
|
-
}
|
|
50
|
-
get helpers() {
|
|
51
|
-
if (!this.config) throw new Error("Firebase API not initialized");
|
|
52
|
-
return this.config.helpers;
|
|
53
|
-
}
|
|
54
|
-
get httpsCallable() {
|
|
55
|
-
var _a;
|
|
56
|
-
return (_a = this.config) == null ? void 0 : _a.httpsCallable;
|
|
57
|
-
}
|
|
58
|
-
logEvent(name, data) {
|
|
59
|
-
var _a;
|
|
60
|
-
(_a = this.config) == null ? void 0 : _a.logEvent(name, data);
|
|
61
|
-
}
|
|
62
|
-
accessQueryConstraints() {
|
|
63
|
-
const { query, orderBy, limit, startAt, startAfter, endAt, endBefore, where, increment } = this.helpers;
|
|
64
|
-
return {
|
|
65
|
-
query,
|
|
66
|
-
orderBy,
|
|
67
|
-
limit,
|
|
68
|
-
startAt,
|
|
69
|
-
startAfter,
|
|
70
|
-
endAt,
|
|
71
|
-
endBefore,
|
|
72
|
-
where,
|
|
73
|
-
increment
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
accessHelpers() {
|
|
77
|
-
const { doc, collection, writeBatch, serverTimestamp, setDoc } = this.helpers;
|
|
78
|
-
return {
|
|
79
|
-
doc: (path) => doc(this.db, path),
|
|
80
|
-
collection: (path) => collection(this.db, path),
|
|
81
|
-
writeBatch: () => writeBatch(this.db),
|
|
82
|
-
serverTimestamp,
|
|
83
|
-
setDoc
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
async getDoc(path) {
|
|
87
|
-
const { getDoc, doc } = this.helpers;
|
|
88
|
-
const docRef = doc(this.db, path);
|
|
89
|
-
const docSnap = await getDoc(docRef);
|
|
90
|
-
const data = docSnap.exists() ? {
|
|
91
|
-
...docSnap.data(),
|
|
92
|
-
id: docSnap.id
|
|
93
|
-
} : null;
|
|
94
|
-
return {
|
|
95
|
-
id: docSnap.id,
|
|
96
|
-
data
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
async getDocs(path, ...queryConstraints) {
|
|
100
|
-
const { getDocs, query, collection } = this.helpers;
|
|
101
|
-
const collectionRef = collection(this.db, path);
|
|
102
|
-
const q = queryConstraints.length > 0 ? query(collectionRef, ...queryConstraints) : collectionRef;
|
|
103
|
-
const querySnapshot = await getDocs(q);
|
|
104
|
-
const data = querySnapshot.docs.map((doc) => ({
|
|
105
|
-
data: doc.data(),
|
|
106
|
-
id: doc.id
|
|
107
|
-
}));
|
|
108
|
-
return {
|
|
109
|
-
data,
|
|
110
|
-
querySnapshot,
|
|
111
|
-
empty: querySnapshot.empty
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
async addDoc(path, data) {
|
|
115
|
-
const { addDoc, collection } = this.helpers;
|
|
116
|
-
const collectionRef = collection(this.db, path);
|
|
117
|
-
const docRef = await addDoc(collectionRef, data);
|
|
118
|
-
return {
|
|
119
|
-
...data,
|
|
120
|
-
id: docRef.id
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
async setDoc(path, data, options = {}) {
|
|
124
|
-
const { setDoc, doc } = this.helpers;
|
|
125
|
-
const docRef = doc(this.db, path);
|
|
126
|
-
await setDoc(docRef, data, options);
|
|
127
|
-
}
|
|
128
|
-
async updateDoc(path, data) {
|
|
129
|
-
const { updateDoc, doc } = this.helpers;
|
|
130
|
-
const docRef = doc(this.db, path);
|
|
131
|
-
await updateDoc(docRef, data);
|
|
132
|
-
}
|
|
133
|
-
async deleteDoc(path) {
|
|
134
|
-
const { deleteDoc, doc } = this.helpers;
|
|
135
|
-
const docRef = doc(this.db, path);
|
|
136
|
-
await deleteDoc(docRef);
|
|
137
|
-
}
|
|
138
|
-
async runTransaction(updateFunction) {
|
|
139
|
-
const { runTransaction } = this.helpers;
|
|
140
|
-
return runTransaction(this.db, updateFunction);
|
|
141
|
-
}
|
|
142
|
-
async runBatch(operations) {
|
|
143
|
-
const { writeBatch } = this.helpers;
|
|
144
|
-
const batch = writeBatch(this.db);
|
|
145
|
-
await Promise.all(operations.map((op) => op()));
|
|
146
|
-
await batch.commit();
|
|
147
|
-
}
|
|
148
|
-
writeBatch() {
|
|
149
|
-
const { writeBatch } = this.helpers;
|
|
150
|
-
const batch = writeBatch(this.db);
|
|
151
|
-
return batch;
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
var api = FirebaseAPI.getInstance();
|
|
155
|
-
|
|
156
|
-
// src/domains/assignment/assignment.constants.ts
|
|
157
|
-
var ASSIGNMENT_ANALYTICS_TYPES = [
|
|
158
|
-
"macro" /* Macro */,
|
|
159
|
-
"gradebook" /* Gradebook */,
|
|
160
|
-
"cards" /* Cards */,
|
|
161
|
-
"student" /* Student */,
|
|
162
|
-
"student_summary" /* StudentSummary */
|
|
163
|
-
];
|
|
164
|
-
var ASSIGNMENTS_COLLECTION = "assignments";
|
|
165
|
-
var ANALYTICS_SUBCOLLECTION = "analytics";
|
|
166
|
-
var SCORES_SUBCOLLECTION = "scores";
|
|
167
|
-
var refsAssignmentFiresotre = {
|
|
168
|
-
allAssignments: () => ASSIGNMENTS_COLLECTION,
|
|
169
|
-
assignment: (params) => `${ASSIGNMENTS_COLLECTION}/${params.id}`,
|
|
170
|
-
assignmentAllAnalytics: (params) => `${ASSIGNMENTS_COLLECTION}/${params.id}/${ANALYTICS_SUBCOLLECTION}`,
|
|
171
|
-
assignmentAnalytics: (params) => `${ASSIGNMENTS_COLLECTION}/${params.id}/${ANALYTICS_SUBCOLLECTION}/${params.type}`,
|
|
172
|
-
assignmentScores: (params) => `${ASSIGNMENTS_COLLECTION}/${params.id}/${SCORES_SUBCOLLECTION}/${params.userId}`
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
// src/domains/assignment/services/get-assignments-score.service.ts
|
|
176
|
-
var _getAssignmentScores = async ({
|
|
177
|
-
assignmentId,
|
|
178
|
-
analyticType = "macro" /* Macro */,
|
|
179
|
-
studentId,
|
|
180
|
-
currentUserId
|
|
181
|
-
}) => {
|
|
182
|
-
if (analyticType === "student" /* Student */) {
|
|
183
|
-
const path = refsAssignmentFiresotre.assignmentScores({
|
|
184
|
-
id: assignmentId,
|
|
185
|
-
userId: currentUserId
|
|
186
|
-
});
|
|
187
|
-
const response = await api.getDoc(path);
|
|
188
|
-
return { scores: response.data, id: assignmentId };
|
|
189
|
-
}
|
|
190
|
-
if (analyticType === "student_summary" /* StudentSummary */ && studentId) {
|
|
191
|
-
const path = refsAssignmentFiresotre.assignmentScores({
|
|
192
|
-
id: assignmentId,
|
|
193
|
-
userId: studentId
|
|
194
|
-
});
|
|
195
|
-
const response = await api.getDoc(path);
|
|
196
|
-
return { scores: response.data, id: assignmentId };
|
|
197
|
-
}
|
|
198
|
-
if (analyticType !== "all" /* All */ && ASSIGNMENT_ANALYTICS_TYPES.includes(analyticType)) {
|
|
199
|
-
const ref = refsAssignmentFiresotre.assignmentAnalytics({
|
|
200
|
-
id: assignmentId,
|
|
201
|
-
type: analyticType
|
|
202
|
-
});
|
|
203
|
-
const docData = await api.getDoc(ref);
|
|
204
|
-
return { scores: docData.data, id: assignmentId };
|
|
205
|
-
} else if (analyticType === "all" /* All */) {
|
|
206
|
-
const ref = refsAssignmentFiresotre.assignmentAllAnalytics({ id: assignmentId });
|
|
207
|
-
const response = await api.getDocs(ref);
|
|
208
|
-
const data = response.data.reduce((acc, curr) => {
|
|
209
|
-
acc[curr.id] = curr;
|
|
210
|
-
return acc;
|
|
211
|
-
}, {});
|
|
212
|
-
return { scores: data, id: assignmentId };
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
var getAssignmentScores = withErrorHandler(_getAssignmentScores, "getAssignmentScores");
|
|
216
|
-
|
|
217
|
-
// src/domains/assignment/services/attach-score-assignment.service.ts
|
|
218
|
-
var _attachScoresAssignment = async ({
|
|
219
|
-
assignments,
|
|
220
|
-
analyticType,
|
|
221
|
-
studentId,
|
|
222
|
-
currentUserId
|
|
223
|
-
}) => {
|
|
224
|
-
const scoresPromises = assignments.map((a) => {
|
|
225
|
-
return getAssignmentScores({
|
|
226
|
-
assignmentId: a.id,
|
|
227
|
-
analyticType,
|
|
228
|
-
studentId,
|
|
229
|
-
currentUserId
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
const scores = await Promise.all(scoresPromises);
|
|
233
|
-
const scoresObject = scores.reduce((acc, curr) => {
|
|
234
|
-
acc[curr.id] = curr.scores;
|
|
235
|
-
return acc;
|
|
236
|
-
}, {});
|
|
237
|
-
const assignmentsWithScores = assignments.map((a) => {
|
|
238
|
-
var _a;
|
|
239
|
-
return {
|
|
240
|
-
...a,
|
|
241
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/ban-ts-comment
|
|
242
|
-
// @ts-ignore
|
|
243
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
244
|
-
scores: (_a = scoresObject[a.id]) != null ? _a : null
|
|
245
|
-
};
|
|
246
|
-
});
|
|
247
|
-
return assignmentsWithScores;
|
|
248
|
-
};
|
|
249
|
-
var attachScoresAssignment = withErrorHandler(
|
|
250
|
-
_attachScoresAssignment,
|
|
251
|
-
"attachScoresAssignment"
|
|
252
|
-
);
|
|
253
|
-
|
|
254
|
-
// src/domains/assignment/services/get-all-assignment.service.ts
|
|
255
|
-
async function _getAllAssignments() {
|
|
256
|
-
const path = refsAssignmentFiresotre.allAssignments();
|
|
257
|
-
const response = await api.getDocs(path);
|
|
258
|
-
return response.data;
|
|
259
|
-
}
|
|
260
|
-
var getAllAssignments = withErrorHandler(_getAllAssignments, "getAllAssignments");
|
|
261
|
-
|
|
262
|
-
// src/domains/assignment/utils/check-assignment-availability.ts
|
|
263
|
-
import dayjs from "dayjs";
|
|
264
|
-
var checkAssignmentAvailability = (scheduledTime) => {
|
|
265
|
-
if (!scheduledTime) return true;
|
|
266
|
-
const scheduledDate = typeof scheduledTime === "string" ? dayjs(scheduledTime) : dayjs(scheduledTime.toDate());
|
|
267
|
-
if (!scheduledDate.isValid()) return true;
|
|
268
|
-
return dayjs().isAfter(scheduledDate);
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
// src/domains/assignment/services/get-assignment.service.ts
|
|
272
|
-
async function _getAssignment(params) {
|
|
273
|
-
var _a;
|
|
274
|
-
const path = refsAssignmentFiresotre.assignment({ id: params.assignmentId });
|
|
275
|
-
const response = await api.getDoc(path);
|
|
276
|
-
if (!response.data) return null;
|
|
277
|
-
const assignment = response.data;
|
|
278
|
-
const isAvailable = checkAssignmentAvailability(assignment.scheduledTime);
|
|
279
|
-
const assignmentWithId = {
|
|
280
|
-
...assignment,
|
|
281
|
-
isAvailable,
|
|
282
|
-
id: params.assignmentId,
|
|
283
|
-
scheduledTime: (_a = assignment.scheduledTime) != null ? _a : null
|
|
284
|
-
};
|
|
285
|
-
if (params.analyticType) {
|
|
286
|
-
const assignmentsWithScores = await attachScoresAssignment({
|
|
287
|
-
assignments: [assignmentWithId],
|
|
288
|
-
analyticType: params.analyticType,
|
|
289
|
-
currentUserId: params.currentUserId
|
|
290
|
-
});
|
|
291
|
-
return assignmentsWithScores.length > 0 ? assignmentsWithScores[0] : assignmentWithId;
|
|
292
|
-
}
|
|
293
|
-
return assignmentWithId;
|
|
294
|
-
}
|
|
295
|
-
var getAssignment = withErrorHandler(_getAssignment, "getAssignment");
|
|
296
|
-
|
|
297
|
-
// src/domains/assignment/assignment.repo.ts
|
|
298
|
-
var createAssignmentRepo = () => {
|
|
299
|
-
return {
|
|
300
|
-
getAssignment,
|
|
301
|
-
attachScoresAssignment,
|
|
302
|
-
getAssignmentScores,
|
|
303
|
-
getAllAssignments
|
|
304
|
-
};
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
// src/domains/cards/services/create-card.service.ts
|
|
308
|
-
import { v4 } from "uuid";
|
|
309
|
-
|
|
310
|
-
// src/domains/cards/card.constants.ts
|
|
311
|
-
var CARDS_COLLECTION = "flashcards";
|
|
312
|
-
var refsCardsFiresotre = {
|
|
313
|
-
allCards: CARDS_COLLECTION,
|
|
314
|
-
card: (id) => `${CARDS_COLLECTION}/${id}`
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
// src/utils/text-utils.ts
|
|
318
|
-
import sha1 from "js-sha1";
|
|
319
|
-
var purify = (word) => {
|
|
320
|
-
return word.normalize("NFD").replace(/\/([^" "]*)/g, "").replace(/\([^()]*\)/g, "").replace(/([^()]*)/g, "").replace(/[\u0300-\u036f]/g, "").replace(/[-]/g, " ").replace(/[.,/#!¡¿?؟。,.?$%^&*;:{}=\-_`~()’'…\s]/g, "").replace(/\s\s+/g, " ").toLowerCase().trim();
|
|
321
|
-
};
|
|
322
|
-
var cleanString = (words) => {
|
|
323
|
-
const splitWords = words == null ? void 0 : words.split("+");
|
|
324
|
-
if (splitWords && splitWords.length === 1) {
|
|
325
|
-
const newWord = purify(words);
|
|
326
|
-
return newWord;
|
|
327
|
-
} else if (splitWords && splitWords.length > 1) {
|
|
328
|
-
const split = splitWords.map((w) => purify(w));
|
|
329
|
-
return split;
|
|
330
|
-
} else {
|
|
331
|
-
return "";
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
var getWordHash = (word, language) => {
|
|
335
|
-
const cleanedWord = cleanString(word);
|
|
336
|
-
const wordHash = sha1(`${language}-${cleanedWord}`);
|
|
337
|
-
console.log("wordHash core library", wordHash);
|
|
338
|
-
return wordHash;
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
// src/domains/cards/services/get-card-verification-status.service.ts
|
|
342
|
-
var charactarLanguages = ["zh", "ja", "ko"];
|
|
343
|
-
var getVerificationStatus = async (target_text, language) => {
|
|
344
|
-
if ((target_text == null ? void 0 : target_text.length) < 3 && !charactarLanguages.includes(language)) {
|
|
345
|
-
return "NOT_RECOMMENDED" /* NOT_RECOMMENDED */;
|
|
346
|
-
}
|
|
347
|
-
const hash = getWordHash(target_text, language);
|
|
348
|
-
const response = await api.getDoc(`checked-pronunciations/${hash}`);
|
|
349
|
-
try {
|
|
350
|
-
if (response.data) {
|
|
351
|
-
return processRecord(response.data);
|
|
352
|
-
} else {
|
|
353
|
-
return "NOT_CHECKED" /* NOT_CHECKED */;
|
|
354
|
-
}
|
|
355
|
-
} catch (e) {
|
|
356
|
-
return "NOT_CHECKED" /* NOT_CHECKED */;
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
var processRecord = (data) => {
|
|
360
|
-
const { pronunciations = 0, fails = 0 } = data;
|
|
361
|
-
const attempts = pronunciations + fails;
|
|
362
|
-
const successRate = attempts > 0 ? pronunciations / attempts * 100 : 0;
|
|
363
|
-
let newStatus = null;
|
|
364
|
-
if (attempts < 6) {
|
|
365
|
-
return "NOT_CHECKED" /* NOT_CHECKED */;
|
|
366
|
-
}
|
|
367
|
-
if (successRate > 25) {
|
|
368
|
-
newStatus = "VERIFIED" /* VERIFIED */;
|
|
369
|
-
} else if (successRate > 10) {
|
|
370
|
-
newStatus = "WARNING" /* WARNING */;
|
|
371
|
-
} else if (fails > 20 && successRate < 10 && pronunciations > 1) {
|
|
372
|
-
newStatus = "NOT_RECOMMENDED" /* NOT_RECOMMENDED */;
|
|
373
|
-
} else if (pronunciations === 0 && fails > 20) {
|
|
374
|
-
newStatus = "NOT_WORKING" /* NOT_WORKING */;
|
|
375
|
-
} else {
|
|
376
|
-
newStatus = "NOT_CHECKED" /* NOT_CHECKED */;
|
|
377
|
-
}
|
|
378
|
-
return newStatus;
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
// src/domains/cards/services/create-card.service.ts
|
|
382
|
-
async function _createCard({ data }) {
|
|
383
|
-
const response = await api.addDoc(refsCardsFiresotre.allCards, data);
|
|
384
|
-
return response;
|
|
385
|
-
}
|
|
386
|
-
var createCard = withErrorHandler(_createCard, "createCard");
|
|
387
|
-
async function _createCards({ cards }) {
|
|
388
|
-
const { writeBatch, doc } = api.accessHelpers();
|
|
389
|
-
const batch = writeBatch();
|
|
390
|
-
const cardsWithId = [];
|
|
391
|
-
for (const card of cards) {
|
|
392
|
-
const cardId = v4();
|
|
393
|
-
const ref = doc(refsCardsFiresotre.card(cardId));
|
|
394
|
-
const newCardObject = {
|
|
395
|
-
...card,
|
|
396
|
-
id: cardId
|
|
397
|
-
};
|
|
398
|
-
if (card.type === "READ_REPEAT" /* READ_REPEAT */ && card.target_text && card.language) {
|
|
399
|
-
const verificationStatus = await getVerificationStatus(card.target_text, card.language);
|
|
400
|
-
newCardObject.verificationStatus = verificationStatus || null;
|
|
401
|
-
}
|
|
402
|
-
cardsWithId.push(newCardObject);
|
|
403
|
-
batch.set(ref, newCardObject);
|
|
404
|
-
}
|
|
405
|
-
await batch.commit();
|
|
406
|
-
return cardsWithId;
|
|
407
|
-
}
|
|
408
|
-
var createCards = withErrorHandler(_createCards, "createCards");
|
|
409
|
-
|
|
410
|
-
// src/domains/cards/services/get-card.service.ts
|
|
411
|
-
async function _getCard(params) {
|
|
412
|
-
const ref = refsCardsFiresotre.card(params.cardId);
|
|
413
|
-
const response = await api.getDoc(ref);
|
|
414
|
-
if (!response.data) return null;
|
|
415
|
-
return response.data;
|
|
416
|
-
}
|
|
417
|
-
var getCard = withErrorHandler(_getCard, "getCard");
|
|
418
|
-
|
|
419
|
-
// src/domains/cards/card.repo.ts
|
|
420
|
-
var createCardRepo = () => {
|
|
421
|
-
return {
|
|
422
|
-
createCard,
|
|
423
|
-
createCards,
|
|
424
|
-
getCard
|
|
425
|
-
};
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
// src/domains/sets/set.constants.ts
|
|
429
|
-
var SETS_COLLECTION = "sets";
|
|
430
|
-
var refsSetsFirestore = {
|
|
431
|
-
allSets: SETS_COLLECTION,
|
|
432
|
-
set: (id) => `${SETS_COLLECTION}/${id}`
|
|
433
|
-
};
|
|
434
|
-
|
|
435
|
-
// src/domains/sets/services/get-set.service.ts
|
|
436
|
-
async function _getSet({ setId }) {
|
|
437
|
-
const response = await api.getDoc(refsSetsFirestore.set(setId));
|
|
438
|
-
return response.data;
|
|
439
|
-
}
|
|
440
|
-
var getSet = withErrorHandler(_getSet, "getSet");
|
|
441
|
-
|
|
442
|
-
// src/domains/sets/set.repo.ts
|
|
443
|
-
var createSetRepo = () => {
|
|
444
|
-
return {
|
|
445
|
-
getSet
|
|
446
|
-
};
|
|
447
|
-
};
|
|
448
|
-
export {
|
|
449
|
-
createAssignmentRepo,
|
|
450
|
-
createCardRepo,
|
|
451
|
-
createSetRepo
|
|
452
|
-
};
|
|
453
|
-
//# sourceMappingURL=repos.js.map
|