@speakableio/core 0.1.8 → 0.1.10
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.d.mts +9 -18
- package/dist/index.d.ts +9 -18
- package/dist/index.js +24 -38
- package/dist/index.mjs +16 -30
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2,17 +2,12 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
4
4
|
import { QueryClient } from '@tanstack/react-query';
|
|
5
|
-
import { FirebaseFunctionsTypes } from '@react-native-firebase/functions';
|
|
6
|
-
import { Functions } from 'firebase/functions';
|
|
7
5
|
import { Firestore, Timestamp as Timestamp$1, FieldValue } from 'firebase/firestore';
|
|
8
6
|
import { FirebaseFirestoreTypes, Timestamp } from '@react-native-firebase/firestore';
|
|
9
|
-
import * as _firebase_functions from '@firebase/functions';
|
|
10
7
|
|
|
11
|
-
type FirebaseInstance =
|
|
12
|
-
functions: FirebaseFunctions;
|
|
13
|
-
};
|
|
8
|
+
type FirebaseInstance = FirebaseFirestoreTypes.Module | Firestore;
|
|
14
9
|
type CustomTimestamp = Timestamp | Timestamp$1;
|
|
15
|
-
type
|
|
10
|
+
type CallableFunction<T = any, R = any> = (data: T) => Promise<R>;
|
|
16
11
|
|
|
17
12
|
interface Assignment {
|
|
18
13
|
name: string;
|
|
@@ -730,17 +725,14 @@ declare const SpeakableNotificationTypes: {
|
|
|
730
725
|
};
|
|
731
726
|
|
|
732
727
|
declare const useCreateNotification: () => {
|
|
733
|
-
createNotification: (type: SpeakableNotificationType, data: any) => Promise<
|
|
734
|
-
success: boolean;
|
|
735
|
-
message: string;
|
|
736
|
-
} | null | undefined>;
|
|
728
|
+
createNotification: (type: SpeakableNotificationType, data: any) => Promise<any>;
|
|
737
729
|
};
|
|
738
730
|
|
|
739
731
|
type FsClient = ReturnType<typeof createFsClient>;
|
|
740
|
-
declare function createFsClient({ db, platform,
|
|
732
|
+
declare function createFsClient({ db, platform, httpsCallable, }: {
|
|
741
733
|
db: FirebaseInstance;
|
|
742
734
|
platform: 'web' | 'native';
|
|
743
|
-
|
|
735
|
+
httpsCallable: (name: string) => CallableFunction;
|
|
744
736
|
}): Promise<{
|
|
745
737
|
assignmentRepo: {
|
|
746
738
|
getAssignment: (params: {
|
|
@@ -974,17 +966,16 @@ interface FsContext {
|
|
|
974
966
|
queryClient: QueryClient;
|
|
975
967
|
user: User;
|
|
976
968
|
permissions: Permissions;
|
|
977
|
-
functions: FirebaseFunctions;
|
|
978
969
|
}
|
|
979
970
|
declare const FsCtx: React.Context<FsContext | null>;
|
|
980
|
-
declare function SpeakableProvider({ db, platform, children, queryClient, user, permissions,
|
|
971
|
+
declare function SpeakableProvider({ db, platform, children, queryClient, user, permissions, httpsCallable, }: {
|
|
972
|
+
user: User;
|
|
981
973
|
db: FirebaseInstance;
|
|
982
|
-
functions: FirebaseFunctions;
|
|
983
974
|
platform: 'web' | 'native';
|
|
984
|
-
children: React.ReactNode;
|
|
985
975
|
queryClient: QueryClient;
|
|
986
|
-
user: User;
|
|
987
976
|
permissions: Permissions;
|
|
977
|
+
httpsCallable: (name: string) => CallableFunction;
|
|
978
|
+
children: React.ReactNode;
|
|
988
979
|
}): react_jsx_runtime.JSX.Element | null;
|
|
989
980
|
declare function useSpeakableApi(): FsContext;
|
|
990
981
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,17 +2,12 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
4
4
|
import { QueryClient } from '@tanstack/react-query';
|
|
5
|
-
import { FirebaseFunctionsTypes } from '@react-native-firebase/functions';
|
|
6
|
-
import { Functions } from 'firebase/functions';
|
|
7
5
|
import { Firestore, Timestamp as Timestamp$1, FieldValue } from 'firebase/firestore';
|
|
8
6
|
import { FirebaseFirestoreTypes, Timestamp } from '@react-native-firebase/firestore';
|
|
9
|
-
import * as _firebase_functions from '@firebase/functions';
|
|
10
7
|
|
|
11
|
-
type FirebaseInstance =
|
|
12
|
-
functions: FirebaseFunctions;
|
|
13
|
-
};
|
|
8
|
+
type FirebaseInstance = FirebaseFirestoreTypes.Module | Firestore;
|
|
14
9
|
type CustomTimestamp = Timestamp | Timestamp$1;
|
|
15
|
-
type
|
|
10
|
+
type CallableFunction<T = any, R = any> = (data: T) => Promise<R>;
|
|
16
11
|
|
|
17
12
|
interface Assignment {
|
|
18
13
|
name: string;
|
|
@@ -730,17 +725,14 @@ declare const SpeakableNotificationTypes: {
|
|
|
730
725
|
};
|
|
731
726
|
|
|
732
727
|
declare const useCreateNotification: () => {
|
|
733
|
-
createNotification: (type: SpeakableNotificationType, data: any) => Promise<
|
|
734
|
-
success: boolean;
|
|
735
|
-
message: string;
|
|
736
|
-
} | null | undefined>;
|
|
728
|
+
createNotification: (type: SpeakableNotificationType, data: any) => Promise<any>;
|
|
737
729
|
};
|
|
738
730
|
|
|
739
731
|
type FsClient = ReturnType<typeof createFsClient>;
|
|
740
|
-
declare function createFsClient({ db, platform,
|
|
732
|
+
declare function createFsClient({ db, platform, httpsCallable, }: {
|
|
741
733
|
db: FirebaseInstance;
|
|
742
734
|
platform: 'web' | 'native';
|
|
743
|
-
|
|
735
|
+
httpsCallable: (name: string) => CallableFunction;
|
|
744
736
|
}): Promise<{
|
|
745
737
|
assignmentRepo: {
|
|
746
738
|
getAssignment: (params: {
|
|
@@ -974,17 +966,16 @@ interface FsContext {
|
|
|
974
966
|
queryClient: QueryClient;
|
|
975
967
|
user: User;
|
|
976
968
|
permissions: Permissions;
|
|
977
|
-
functions: FirebaseFunctions;
|
|
978
969
|
}
|
|
979
970
|
declare const FsCtx: React.Context<FsContext | null>;
|
|
980
|
-
declare function SpeakableProvider({ db, platform, children, queryClient, user, permissions,
|
|
971
|
+
declare function SpeakableProvider({ db, platform, children, queryClient, user, permissions, httpsCallable, }: {
|
|
972
|
+
user: User;
|
|
981
973
|
db: FirebaseInstance;
|
|
982
|
-
functions: FirebaseFunctions;
|
|
983
974
|
platform: 'web' | 'native';
|
|
984
|
-
children: React.ReactNode;
|
|
985
975
|
queryClient: QueryClient;
|
|
986
|
-
user: User;
|
|
987
976
|
permissions: Permissions;
|
|
977
|
+
httpsCallable: (name: string) => CallableFunction;
|
|
978
|
+
children: React.ReactNode;
|
|
988
979
|
}): react_jsx_runtime.JSX.Element | null;
|
|
989
980
|
declare function useSpeakableApi(): FsContext;
|
|
990
981
|
|
package/dist/index.js
CHANGED
|
@@ -54,15 +54,8 @@ var FirebaseAPI = class _FirebaseAPI {
|
|
|
54
54
|
if (!this.config) throw new Error("Firebase API not initialized");
|
|
55
55
|
return this.config.helpers;
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return this.config.functions;
|
|
60
|
-
}
|
|
61
|
-
get httpsCallable() {
|
|
62
|
-
return this.config.httpsCallable;
|
|
63
|
-
}
|
|
64
|
-
customHttpsCallable(functionName) {
|
|
65
|
-
return this.httpsCallable(this.functions, functionName);
|
|
57
|
+
httpsCallable(functionName) {
|
|
58
|
+
return _optionalChain([this, 'access', _ => _.config, 'optionalAccess', _2 => _2.httpsCallable, 'call', _3 => _3(functionName)]);
|
|
66
59
|
}
|
|
67
60
|
accessQueryConstraints() {
|
|
68
61
|
const { query, orderBy, limit, startAt, startAfter, endAt, endBefore } = this.helpers;
|
|
@@ -502,7 +495,7 @@ var purify = (word) => {
|
|
|
502
495
|
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();
|
|
503
496
|
};
|
|
504
497
|
var cleanString = (words) => {
|
|
505
|
-
const splitWords = _optionalChain([words, 'optionalAccess',
|
|
498
|
+
const splitWords = _optionalChain([words, 'optionalAccess', _4 => _4.split, 'call', _5 => _5("+")]);
|
|
506
499
|
if (splitWords && splitWords.length === 1) {
|
|
507
500
|
const newWord = purify(words);
|
|
508
501
|
return newWord;
|
|
@@ -522,7 +515,7 @@ var getWordHash = (word, language) => {
|
|
|
522
515
|
// src/domains/cards/services/get-card-verification-status.service.ts
|
|
523
516
|
var charactarLanguages = ["zh", "ja", "ko"];
|
|
524
517
|
var getVerificationStatus = async (target_text, language) => {
|
|
525
|
-
if (_optionalChain([target_text, 'optionalAccess',
|
|
518
|
+
if (_optionalChain([target_text, 'optionalAccess', _6 => _6.length]) < 3 && !charactarLanguages.includes(language)) {
|
|
526
519
|
return "NOT_RECOMMENDED" /* NOT_RECOMMENDED */;
|
|
527
520
|
}
|
|
528
521
|
const hash = getWordHash(target_text, language);
|
|
@@ -747,17 +740,15 @@ var WEB_BASE_URL = "https://app.speakable.io";
|
|
|
747
740
|
|
|
748
741
|
// src/lib/firebase/firebase-functions.ts
|
|
749
742
|
var SpeakableFirebaseFunctions = {
|
|
750
|
-
updateAssignmentGradebookStatus: api.
|
|
751
|
-
onSetOpened: api.
|
|
752
|
-
updateAlgoliaIndex: api.
|
|
753
|
-
submitAssignmentToGoogleClassroomV2: api.
|
|
754
|
-
|
|
755
|
-
),
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
sendAssessmentScoredEmail: api.customHttpsCallable("sendAssessmentScoredEmail"),
|
|
760
|
-
createNotification: api.customHttpsCallable("createNotificationV2")
|
|
743
|
+
updateAssignmentGradebookStatus: api.httpsCallable("updateAssignmentGradebookStatus"),
|
|
744
|
+
onSetOpened: api.httpsCallable("onSetOpened"),
|
|
745
|
+
updateAlgoliaIndex: api.httpsCallable("updateAlgoliaIndex"),
|
|
746
|
+
submitAssignmentToGoogleClassroomV2: api.httpsCallable("submitAssignmentToGoogleClassroomV2"),
|
|
747
|
+
submitLTIAssignmentScore: api.httpsCallable("submitLTIAssignmentScore"),
|
|
748
|
+
submitAssignmentV2: api.httpsCallable("submitLTIAssignmentScoreV2"),
|
|
749
|
+
submitAssessment: api.httpsCallable("submitAssessment"),
|
|
750
|
+
sendAssessmentScoredEmail: api.httpsCallable("sendAssessmentScoredEmail"),
|
|
751
|
+
createNotification: api.httpsCallable("createNotificationV2")
|
|
761
752
|
};
|
|
762
753
|
|
|
763
754
|
// src/domains/notification/services/send-notification.service.ts
|
|
@@ -842,7 +833,7 @@ var createNewAssignmentNotification = async ({
|
|
|
842
833
|
link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
|
|
843
834
|
messagePreview: `A new assignment "${assignment.name}" is now available. ${dueDate ? `Due ${dueDate}` : ""}`,
|
|
844
835
|
title: "New Assignment Available!",
|
|
845
|
-
imageUrl: _optionalChain([profile, 'access',
|
|
836
|
+
imageUrl: _optionalChain([profile, 'access', _7 => _7.image, 'optionalAccess', _8 => _8.url])
|
|
846
837
|
});
|
|
847
838
|
return results;
|
|
848
839
|
};
|
|
@@ -859,7 +850,7 @@ var createAssessmentSubmissionNotification = async ({
|
|
|
859
850
|
title: `Assessment Submitted!`,
|
|
860
851
|
senderName: studentName,
|
|
861
852
|
messagePreview: `${studentName} has submitted the assessment "${assignment.name}"`,
|
|
862
|
-
imageUrl: _optionalChain([profile, 'access',
|
|
853
|
+
imageUrl: _optionalChain([profile, 'access', _9 => _9.image, 'optionalAccess', _10 => _10.url])
|
|
863
854
|
});
|
|
864
855
|
return results;
|
|
865
856
|
};
|
|
@@ -877,13 +868,13 @@ var createAssessmentScoredNotification = async ({
|
|
|
877
868
|
link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
|
|
878
869
|
title,
|
|
879
870
|
messagePreview,
|
|
880
|
-
imageUrl: _optionalChain([profile, 'access',
|
|
871
|
+
imageUrl: _optionalChain([profile, 'access', _11 => _11.image, 'optionalAccess', _12 => _12.url]),
|
|
881
872
|
senderName: teacherName
|
|
882
873
|
});
|
|
883
874
|
await SpeakableFirebaseFunctions.sendAssessmentScoredEmail({
|
|
884
875
|
assessmentTitle: assignment.name,
|
|
885
876
|
link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
|
|
886
|
-
senderImage: _optionalChain([profile, 'access',
|
|
877
|
+
senderImage: _optionalChain([profile, 'access', _13 => _13.image, 'optionalAccess', _14 => _14.url]) || "",
|
|
887
878
|
studentId: sendTo[0],
|
|
888
879
|
teacherName: profile.displayName
|
|
889
880
|
});
|
|
@@ -901,11 +892,11 @@ var useCreateNotification = () => {
|
|
|
901
892
|
const result = await createNotification({
|
|
902
893
|
type,
|
|
903
894
|
userId: user.auth.uid,
|
|
904
|
-
profile: _nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
895
|
+
profile: _nullishCoalesce(_optionalChain([user, 'optionalAccess', _15 => _15.profile]), () => ( {})),
|
|
905
896
|
data
|
|
906
897
|
});
|
|
907
898
|
queryClient.invalidateQueries({
|
|
908
|
-
queryKey: notificationQueryKeys.byId(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
899
|
+
queryKey: notificationQueryKeys.byId(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _16 => _16.auth, 'access', _17 => _17.uid]), () => ( "")))
|
|
909
900
|
});
|
|
910
901
|
return result;
|
|
911
902
|
};
|
|
@@ -915,20 +906,16 @@ var useCreateNotification = () => {
|
|
|
915
906
|
};
|
|
916
907
|
|
|
917
908
|
// src/lib/create-firebase-client.ts
|
|
918
|
-
var _functions = require('firebase/functions');
|
|
919
|
-
var _functions3 = require('@react-native-firebase/functions');
|
|
920
909
|
async function createFsClient({
|
|
921
910
|
db,
|
|
922
911
|
platform,
|
|
923
|
-
|
|
912
|
+
httpsCallable
|
|
924
913
|
}) {
|
|
925
914
|
const dbAsFirestore = db;
|
|
926
915
|
const helpers = platform === "web" ? await Promise.resolve().then(() => _interopRequireWildcard(require("firebase/firestore"))) : await Promise.resolve().then(() => _interopRequireWildcard(require("@react-native-firebase/firestore")));
|
|
927
|
-
const httpsCallable = platform === "web" ? _functions.httpsCallable : _functions3.httpsCallable;
|
|
928
916
|
api.initialize({
|
|
929
917
|
db: dbAsFirestore,
|
|
930
918
|
helpers,
|
|
931
|
-
functions,
|
|
932
919
|
httpsCallable
|
|
933
920
|
});
|
|
934
921
|
return {
|
|
@@ -947,18 +934,18 @@ function SpeakableProvider({
|
|
|
947
934
|
queryClient,
|
|
948
935
|
user,
|
|
949
936
|
permissions,
|
|
950
|
-
|
|
937
|
+
httpsCallable
|
|
951
938
|
}) {
|
|
952
939
|
const [speakableApi, setSpeakableApi] = _react.useState.call(void 0, null);
|
|
953
940
|
_react.useEffect.call(void 0, () => {
|
|
954
941
|
createFsClient({
|
|
955
942
|
db,
|
|
956
|
-
|
|
943
|
+
httpsCallable,
|
|
957
944
|
platform
|
|
958
945
|
}).then((repos) => {
|
|
959
946
|
setSpeakableApi(repos);
|
|
960
947
|
});
|
|
961
|
-
}, [db,
|
|
948
|
+
}, [db, platform, httpsCallable]);
|
|
962
949
|
if (!speakableApi) return null;
|
|
963
950
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
964
951
|
FsCtx.Provider,
|
|
@@ -967,8 +954,7 @@ function SpeakableProvider({
|
|
|
967
954
|
speakableApi,
|
|
968
955
|
queryClient,
|
|
969
956
|
user,
|
|
970
|
-
permissions
|
|
971
|
-
functions
|
|
957
|
+
permissions
|
|
972
958
|
},
|
|
973
959
|
children
|
|
974
960
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -54,15 +54,8 @@ var FirebaseAPI = class _FirebaseAPI {
|
|
|
54
54
|
if (!this.config) throw new Error("Firebase API not initialized");
|
|
55
55
|
return this.config.helpers;
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return this.config.functions;
|
|
60
|
-
}
|
|
61
|
-
get httpsCallable() {
|
|
62
|
-
return this.config.httpsCallable;
|
|
63
|
-
}
|
|
64
|
-
customHttpsCallable(functionName) {
|
|
65
|
-
return this.httpsCallable(this.functions, functionName);
|
|
57
|
+
httpsCallable(functionName) {
|
|
58
|
+
return this.config?.httpsCallable(functionName);
|
|
66
59
|
}
|
|
67
60
|
accessQueryConstraints() {
|
|
68
61
|
const { query, orderBy, limit, startAt, startAfter, endAt, endBefore } = this.helpers;
|
|
@@ -747,17 +740,15 @@ var WEB_BASE_URL = "https://app.speakable.io";
|
|
|
747
740
|
|
|
748
741
|
// src/lib/firebase/firebase-functions.ts
|
|
749
742
|
var SpeakableFirebaseFunctions = {
|
|
750
|
-
updateAssignmentGradebookStatus: api.
|
|
751
|
-
onSetOpened: api.
|
|
752
|
-
updateAlgoliaIndex: api.
|
|
753
|
-
submitAssignmentToGoogleClassroomV2: api.
|
|
754
|
-
|
|
755
|
-
),
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
sendAssessmentScoredEmail: api.customHttpsCallable("sendAssessmentScoredEmail"),
|
|
760
|
-
createNotification: api.customHttpsCallable("createNotificationV2")
|
|
743
|
+
updateAssignmentGradebookStatus: api.httpsCallable("updateAssignmentGradebookStatus"),
|
|
744
|
+
onSetOpened: api.httpsCallable("onSetOpened"),
|
|
745
|
+
updateAlgoliaIndex: api.httpsCallable("updateAlgoliaIndex"),
|
|
746
|
+
submitAssignmentToGoogleClassroomV2: api.httpsCallable("submitAssignmentToGoogleClassroomV2"),
|
|
747
|
+
submitLTIAssignmentScore: api.httpsCallable("submitLTIAssignmentScore"),
|
|
748
|
+
submitAssignmentV2: api.httpsCallable("submitLTIAssignmentScoreV2"),
|
|
749
|
+
submitAssessment: api.httpsCallable("submitAssessment"),
|
|
750
|
+
sendAssessmentScoredEmail: api.httpsCallable("sendAssessmentScoredEmail"),
|
|
751
|
+
createNotification: api.httpsCallable("createNotificationV2")
|
|
761
752
|
};
|
|
762
753
|
|
|
763
754
|
// src/domains/notification/services/send-notification.service.ts
|
|
@@ -915,20 +906,16 @@ var useCreateNotification = () => {
|
|
|
915
906
|
};
|
|
916
907
|
|
|
917
908
|
// src/lib/create-firebase-client.ts
|
|
918
|
-
import { httpsCallable as webHttpsCallable } from "firebase/functions";
|
|
919
|
-
import { httpsCallable as nativeHttpsCallable } from "@react-native-firebase/functions";
|
|
920
909
|
async function createFsClient({
|
|
921
910
|
db,
|
|
922
911
|
platform,
|
|
923
|
-
|
|
912
|
+
httpsCallable
|
|
924
913
|
}) {
|
|
925
914
|
const dbAsFirestore = db;
|
|
926
915
|
const helpers = platform === "web" ? await import("firebase/firestore") : await import("@react-native-firebase/firestore");
|
|
927
|
-
const httpsCallable = platform === "web" ? webHttpsCallable : nativeHttpsCallable;
|
|
928
916
|
api.initialize({
|
|
929
917
|
db: dbAsFirestore,
|
|
930
918
|
helpers,
|
|
931
|
-
functions,
|
|
932
919
|
httpsCallable
|
|
933
920
|
});
|
|
934
921
|
return {
|
|
@@ -947,18 +934,18 @@ function SpeakableProvider({
|
|
|
947
934
|
queryClient,
|
|
948
935
|
user,
|
|
949
936
|
permissions,
|
|
950
|
-
|
|
937
|
+
httpsCallable
|
|
951
938
|
}) {
|
|
952
939
|
const [speakableApi, setSpeakableApi] = useState(null);
|
|
953
940
|
useEffect(() => {
|
|
954
941
|
createFsClient({
|
|
955
942
|
db,
|
|
956
|
-
|
|
943
|
+
httpsCallable,
|
|
957
944
|
platform
|
|
958
945
|
}).then((repos) => {
|
|
959
946
|
setSpeakableApi(repos);
|
|
960
947
|
});
|
|
961
|
-
}, [db,
|
|
948
|
+
}, [db, platform, httpsCallable]);
|
|
962
949
|
if (!speakableApi) return null;
|
|
963
950
|
return /* @__PURE__ */ jsx(
|
|
964
951
|
FsCtx.Provider,
|
|
@@ -967,8 +954,7 @@ function SpeakableProvider({
|
|
|
967
954
|
speakableApi,
|
|
968
955
|
queryClient,
|
|
969
956
|
user,
|
|
970
|
-
permissions
|
|
971
|
-
functions
|
|
957
|
+
permissions
|
|
972
958
|
},
|
|
973
959
|
children
|
|
974
960
|
}
|