@speakableio/core 0.1.65 → 0.1.67
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/index.native.d.mts +12 -2
- package/dist/index.native.mjs +101 -4
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.web.d.mts +12 -2
- package/dist/index.web.js +101 -4
- package/dist/index.web.js.map +1 -1
- package/package.json +1 -1
package/dist/index.web.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
4
4
|
import { QueryClient } from '@tanstack/react-query';
|
|
5
5
|
import { FirebaseFirestoreTypes, Timestamp } from '@react-native-firebase/firestore';
|
|
6
|
-
import { Firestore, getDoc, getDocs, addDoc, setDoc, updateDoc, deleteDoc, runTransaction, writeBatch, doc, collection, query, serverTimestamp, orderBy, limit, startAt, startAfter, endAt, endBefore, where, Timestamp as Timestamp$1, FieldValue } from 'firebase/firestore';
|
|
6
|
+
import { Firestore, getDoc, getDocs, addDoc, setDoc, updateDoc, deleteDoc, runTransaction, writeBatch, doc, collection, query, serverTimestamp, orderBy, limit, startAt, startAfter, endAt, endBefore, where, increment, Timestamp as Timestamp$1, FieldValue } from 'firebase/firestore';
|
|
7
7
|
|
|
8
8
|
type FirebaseInstance = FirebaseFirestoreTypes.Module | Firestore;
|
|
9
9
|
interface FirestoreHelpers {
|
|
@@ -26,6 +26,7 @@ interface FirestoreHelpers {
|
|
|
26
26
|
endAt: typeof endAt;
|
|
27
27
|
endBefore: typeof endBefore;
|
|
28
28
|
where: typeof where;
|
|
29
|
+
increment: typeof increment;
|
|
29
30
|
}
|
|
30
31
|
type CustomTimestamp = Timestamp | Timestamp$1;
|
|
31
32
|
type CallableFunction<T = any, R = any> = (data: T) => Promise<R>;
|
|
@@ -1228,6 +1229,7 @@ declare function debounce<T extends (...args: any[]) => Promise<any>>(func: T, w
|
|
|
1228
1229
|
declare const purify: (word: string) => string;
|
|
1229
1230
|
declare const cleanString: (words: string) => string | string[];
|
|
1230
1231
|
declare const getWordHash: (word: string, language: string) => string;
|
|
1232
|
+
declare function getPhraseLength(phrase: string, input?: string): number;
|
|
1231
1233
|
|
|
1232
1234
|
declare function useActivity({ id, isAssignment, onAssignmentSubmitted, ltiData, }: {
|
|
1233
1235
|
id: string;
|
|
@@ -2310,6 +2312,14 @@ declare const useOrganizationAccess: () => {
|
|
|
2310
2312
|
promise: Promise<OrganizationAccess>;
|
|
2311
2313
|
};
|
|
2312
2314
|
|
|
2315
|
+
declare const useUpdateStudentVocab: (page: PageActivityWithId | null) => {
|
|
2316
|
+
studentVocabMarkVoiceSuccess: undefined;
|
|
2317
|
+
studentVocabMarkVoiceFail: undefined;
|
|
2318
|
+
} | {
|
|
2319
|
+
studentVocabMarkVoiceSuccess: () => Promise<void>;
|
|
2320
|
+
studentVocabMarkVoiceFail: () => Promise<void>;
|
|
2321
|
+
};
|
|
2322
|
+
|
|
2313
2323
|
declare const useBaseOpenAI: ({ onTranscriptSuccess, onTranscriptError, onCompletionSuccess, onCompletionError, aiEnabled, submitAudioResponse, uploadAudioAndGetTranscript, }: {
|
|
2314
2324
|
onTranscriptSuccess: (transcript: string) => void;
|
|
2315
2325
|
onTranscriptError: ({ type, message }: {
|
|
@@ -2721,4 +2731,4 @@ declare const createFsClientWeb: ({ db, httpsCallable, logEvent }: FsClientParam
|
|
|
2721
2731
|
};
|
|
2722
2732
|
};
|
|
2723
2733
|
|
|
2724
|
-
export { ActivityPageType, type Assignment, type AssignmentWithId, BASE_MULTIPLE_CHOICE_FIELD_VALUES, BASE_REPEAT_FIELD_VALUES, BASE_RESPOND_FIELD_VALUES, type CreditContract, FeedbackTypesCard, FsCtx, type InstitutionSubscription, LENIENCY_OPTIONS, LeniencyCard, MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES, type Organization, type OrganizationAccess, type PageActivity, type PageActivityWithId, type PageScore, REPEAT_PAGE_ACTIVITY_TYPES, RESPOND_AUDIO_PAGE_ACTIVITY_TYPES, RESPOND_PAGE_ACTIVITY_TYPES, RESPOND_WRITE_PAGE_ACTIVITY_TYPES, type RefsCardsFiresotre, type RefsSetsFirestore, SPEAKABLE_NOTIFICATIONS, STUDENT_LEVELS_OPTIONS, type Score, type ScoreWithId, type Set, type SetWithId, type SpeakableNotificationType, SpeakableNotificationTypes, SpeakableProvider, VerificationCardStatus, assignmentQueryKeys, cardsQueryKeys, checkIsMCPage, checkIsMediaPage, checkIsRepeatPage, checkIsRespondAudioPage, checkIsRespondPage, checkIsRespondWrittenPage, checkIsShortAnswerPage, checkTypePageActivity, cleanString, createAssignmentRepo, createCardRepo, createFsClientWeb as createFsClient, createSetRepo, creditQueryKeys, debounce, getCardFromCache, getPagePrompt, getRespondCardTool, getSetFromCache, getWordHash, purify, refsCardsFiresotre, refsSetsFirestore, scoreQueryKeys, setsQueryKeys, updateCardInCache, updateSetInCache, useActivity, useActivityFeedbackAccess, useAssignment, useBaseOpenAI, useCards, useClearScore, useCreateCard, useCreateCards, useCreateNotification, useGetCard, useOrganizationAccess, useScore, useSet, useSpeakableApi, useSubmitAssignmentScore, useSubmitPracticeScore, useUpdateCardScore, useUpdateScore, useUserCredits };
|
|
2734
|
+
export { ActivityPageType, type Assignment, type AssignmentWithId, BASE_MULTIPLE_CHOICE_FIELD_VALUES, BASE_REPEAT_FIELD_VALUES, BASE_RESPOND_FIELD_VALUES, type CreditContract, FeedbackTypesCard, FsCtx, type InstitutionSubscription, LENIENCY_OPTIONS, LeniencyCard, MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES, type Organization, type OrganizationAccess, type PageActivity, type PageActivityWithId, type PageScore, REPEAT_PAGE_ACTIVITY_TYPES, RESPOND_AUDIO_PAGE_ACTIVITY_TYPES, RESPOND_PAGE_ACTIVITY_TYPES, RESPOND_WRITE_PAGE_ACTIVITY_TYPES, type RefsCardsFiresotre, type RefsSetsFirestore, SPEAKABLE_NOTIFICATIONS, STUDENT_LEVELS_OPTIONS, type Score, type ScoreWithId, type Set, type SetWithId, type SpeakableNotificationType, SpeakableNotificationTypes, SpeakableProvider, VerificationCardStatus, assignmentQueryKeys, cardsQueryKeys, checkIsMCPage, checkIsMediaPage, checkIsRepeatPage, checkIsRespondAudioPage, checkIsRespondPage, checkIsRespondWrittenPage, checkIsShortAnswerPage, checkTypePageActivity, cleanString, createAssignmentRepo, createCardRepo, createFsClientWeb as createFsClient, createSetRepo, creditQueryKeys, debounce, getCardFromCache, getPagePrompt, getPhraseLength, getRespondCardTool, getSetFromCache, getWordHash, purify, refsCardsFiresotre, refsSetsFirestore, scoreQueryKeys, setsQueryKeys, updateCardInCache, updateSetInCache, useActivity, useActivityFeedbackAccess, useAssignment, useBaseOpenAI, useCards, useClearScore, useCreateCard, useCreateCards, useCreateNotification, useGetCard, useOrganizationAccess, useScore, useSet, useSpeakableApi, useSubmitAssignmentScore, useSubmitPracticeScore, useUpdateCardScore, useUpdateScore, useUpdateStudentVocab, useUserCredits };
|
package/dist/index.web.js
CHANGED
|
@@ -95,7 +95,7 @@ var FirebaseAPI = class _FirebaseAPI {
|
|
|
95
95
|
(_a = this.config) == null ? void 0 : _a.logEvent(name, data);
|
|
96
96
|
}
|
|
97
97
|
accessQueryConstraints() {
|
|
98
|
-
const { query: query2, orderBy: orderBy2, limit: limit2, startAt: startAt2, startAfter: startAfter2, endAt: endAt2, endBefore: endBefore2, where: where2 } = this.helpers;
|
|
98
|
+
const { query: query2, orderBy: orderBy2, limit: limit2, startAt: startAt2, startAfter: startAfter2, endAt: endAt2, endBefore: endBefore2, where: where2, increment: increment2 } = this.helpers;
|
|
99
99
|
return {
|
|
100
100
|
query: query2,
|
|
101
101
|
orderBy: orderBy2,
|
|
@@ -104,7 +104,8 @@ var FirebaseAPI = class _FirebaseAPI {
|
|
|
104
104
|
startAfter: startAfter2,
|
|
105
105
|
endAt: endAt2,
|
|
106
106
|
endBefore: endBefore2,
|
|
107
|
-
where: where2
|
|
107
|
+
where: where2,
|
|
108
|
+
increment: increment2
|
|
108
109
|
};
|
|
109
110
|
}
|
|
110
111
|
accessHelpers() {
|
|
@@ -1669,6 +1670,13 @@ var getWordHash = (word, language) => {
|
|
|
1669
1670
|
console.log("wordHash core library", wordHash);
|
|
1670
1671
|
return wordHash;
|
|
1671
1672
|
};
|
|
1673
|
+
function getPhraseLength(phrase, input) {
|
|
1674
|
+
if (Array.isArray(phrase) && phrase.includes(input)) {
|
|
1675
|
+
return phrase[phrase.indexOf(input)].split(" ").length;
|
|
1676
|
+
} else {
|
|
1677
|
+
return phrase ? phrase.split(" ").length : 0;
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1672
1680
|
|
|
1673
1681
|
// src/domains/cards/services/get-card-verification-status.service.ts
|
|
1674
1682
|
var charactarLanguages = ["zh", "ja", "ko"];
|
|
@@ -2675,6 +2683,91 @@ var getOrganizationAccess = async (email) => {
|
|
|
2675
2683
|
}
|
|
2676
2684
|
};
|
|
2677
2685
|
|
|
2686
|
+
// src/hooks/useUpdateStudentVoc.ts
|
|
2687
|
+
var useUpdateStudentVocab = (page) => {
|
|
2688
|
+
const { user } = useSpeakableApi();
|
|
2689
|
+
const currentUserId = user == null ? void 0 : user.auth.uid;
|
|
2690
|
+
if (!page || !currentUserId || !page.target_text || !page.language) {
|
|
2691
|
+
return {
|
|
2692
|
+
studentVocabMarkVoiceSuccess: void 0,
|
|
2693
|
+
studentVocabMarkVoiceFail: void 0
|
|
2694
|
+
};
|
|
2695
|
+
}
|
|
2696
|
+
const getDataObject = () => {
|
|
2697
|
+
var _a, _b;
|
|
2698
|
+
const { serverTimestamp: serverTimestamp2 } = api.accessHelpers();
|
|
2699
|
+
const language = (_a = page.language) != null ? _a : "en";
|
|
2700
|
+
const word = (_b = page.target_text) != null ? _b : "";
|
|
2701
|
+
const phrase_length = getPhraseLength(word);
|
|
2702
|
+
const wordHash = getWordHash(word, language);
|
|
2703
|
+
const docPath = `users/${currentUserId}/vocab/${wordHash}`;
|
|
2704
|
+
const communityPath = `checked-pronunciations/${wordHash}`;
|
|
2705
|
+
const id = `${language}-${cleanString(word)}`;
|
|
2706
|
+
const data = {
|
|
2707
|
+
id,
|
|
2708
|
+
word,
|
|
2709
|
+
words: (word == null ? void 0 : word.split(" ")) || [],
|
|
2710
|
+
wordHash,
|
|
2711
|
+
language,
|
|
2712
|
+
lastSeen: serverTimestamp2(),
|
|
2713
|
+
phrase_length
|
|
2714
|
+
};
|
|
2715
|
+
return {
|
|
2716
|
+
docPath,
|
|
2717
|
+
communityPath,
|
|
2718
|
+
data
|
|
2719
|
+
};
|
|
2720
|
+
};
|
|
2721
|
+
const markVoiceSuccess = async () => {
|
|
2722
|
+
const { docPath, communityPath, data } = getDataObject();
|
|
2723
|
+
const { increment: increment2 } = api.accessQueryConstraints();
|
|
2724
|
+
const { serverTimestamp: serverTimestamp2 } = api.accessHelpers();
|
|
2725
|
+
data.voiceSuccess = increment2(1);
|
|
2726
|
+
try {
|
|
2727
|
+
await api.updateDoc(docPath, data);
|
|
2728
|
+
} catch (error) {
|
|
2729
|
+
if (error instanceof Error && error.message === "not-found") {
|
|
2730
|
+
data.firstSeen = serverTimestamp2();
|
|
2731
|
+
await api.setDoc(docPath, data);
|
|
2732
|
+
} else {
|
|
2733
|
+
console.log(error);
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
try {
|
|
2737
|
+
data.pronunciations = increment2(1);
|
|
2738
|
+
await api.setDoc(communityPath, data, { merge: true });
|
|
2739
|
+
} catch (error) {
|
|
2740
|
+
console.log(error);
|
|
2741
|
+
}
|
|
2742
|
+
};
|
|
2743
|
+
const markVoiceFail = async () => {
|
|
2744
|
+
const { docPath, communityPath, data } = getDataObject();
|
|
2745
|
+
const { increment: increment2 } = api.accessQueryConstraints();
|
|
2746
|
+
const { serverTimestamp: serverTimestamp2 } = api.accessHelpers();
|
|
2747
|
+
data.voiceFail = increment2(1);
|
|
2748
|
+
try {
|
|
2749
|
+
await api.updateDoc(docPath, data);
|
|
2750
|
+
} catch (error) {
|
|
2751
|
+
if (error instanceof Error && error.message === "not-found") {
|
|
2752
|
+
data.firstSeen = serverTimestamp2();
|
|
2753
|
+
await api.setDoc(docPath, data);
|
|
2754
|
+
} else {
|
|
2755
|
+
console.log(error);
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
try {
|
|
2759
|
+
data.fails = increment2(1);
|
|
2760
|
+
await api.setDoc(communityPath, data, { merge: true });
|
|
2761
|
+
} catch (error) {
|
|
2762
|
+
console.log(error);
|
|
2763
|
+
}
|
|
2764
|
+
};
|
|
2765
|
+
return {
|
|
2766
|
+
studentVocabMarkVoiceSuccess: markVoiceSuccess,
|
|
2767
|
+
studentVocabMarkVoiceFail: markVoiceFail
|
|
2768
|
+
};
|
|
2769
|
+
};
|
|
2770
|
+
|
|
2678
2771
|
// src/hooks/useActivityFeedbackAccess.ts
|
|
2679
2772
|
import { useQuery as useQuery7 } from "@tanstack/react-query";
|
|
2680
2773
|
var activityFeedbackAccessQueryKeys = {
|
|
@@ -3014,7 +3107,8 @@ import {
|
|
|
3014
3107
|
startAfter,
|
|
3015
3108
|
endAt,
|
|
3016
3109
|
endBefore,
|
|
3017
|
-
where
|
|
3110
|
+
where,
|
|
3111
|
+
increment
|
|
3018
3112
|
} from "firebase/firestore";
|
|
3019
3113
|
|
|
3020
3114
|
// src/lib/create-firebase-client.ts
|
|
@@ -3062,7 +3156,8 @@ var createFsClientWeb = ({ db, httpsCallable, logEvent }) => {
|
|
|
3062
3156
|
startAfter,
|
|
3063
3157
|
endAt,
|
|
3064
3158
|
endBefore,
|
|
3065
|
-
where
|
|
3159
|
+
where,
|
|
3160
|
+
increment
|
|
3066
3161
|
}
|
|
3067
3162
|
});
|
|
3068
3163
|
};
|
|
@@ -3104,6 +3199,7 @@ export {
|
|
|
3104
3199
|
debounce,
|
|
3105
3200
|
getCardFromCache,
|
|
3106
3201
|
getPagePrompt,
|
|
3202
|
+
getPhraseLength,
|
|
3107
3203
|
getRespondCardTool,
|
|
3108
3204
|
getSetFromCache,
|
|
3109
3205
|
getWordHash,
|
|
@@ -3132,6 +3228,7 @@ export {
|
|
|
3132
3228
|
useSubmitPracticeScore,
|
|
3133
3229
|
useUpdateCardScore,
|
|
3134
3230
|
useUpdateScore,
|
|
3231
|
+
useUpdateStudentVocab,
|
|
3135
3232
|
useUserCredits
|
|
3136
3233
|
};
|
|
3137
3234
|
//# sourceMappingURL=index.web.js.map
|