@speakableio/core 0.1.7 → 0.1.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.
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 = (FirebaseFirestoreTypes.Module | Firestore) & {
12
- functions: FirebaseFunctions;
13
- };
8
+ type FirebaseInstance = FirebaseFirestoreTypes.Module | Firestore;
14
9
  type CustomTimestamp = Timestamp | Timestamp$1;
15
- type FirebaseFunctions = Functions | FirebaseFunctionsTypes.Module;
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<_firebase_functions.HttpsCallableResult<unknown> | {
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, functions, }: {
732
+ declare function createFsClient({ db, platform, httpsCallable, }: {
741
733
  db: FirebaseInstance;
742
734
  platform: 'web' | 'native';
743
- functions: FirebaseFunctions;
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, functions, }: {
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 = (FirebaseFirestoreTypes.Module | Firestore) & {
12
- functions: FirebaseFunctions;
13
- };
8
+ type FirebaseInstance = FirebaseFirestoreTypes.Module | Firestore;
14
9
  type CustomTimestamp = Timestamp | Timestamp$1;
15
- type FirebaseFunctions = Functions | FirebaseFunctionsTypes.Module;
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<_firebase_functions.HttpsCallableResult<unknown> | {
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, functions, }: {
732
+ declare function createFsClient({ db, platform, httpsCallable, }: {
741
733
  db: FirebaseInstance;
742
734
  platform: 'web' | 'native';
743
- functions: FirebaseFunctions;
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, functions, }: {
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,16 +54,9 @@ 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
- get functions() {
57
+ httpsCallable(functionName) {
58
58
  if (!this.config) throw new Error("Firebase API not initialized");
59
- return this.config.functions;
60
- }
61
- get httpsCallable() {
62
- if (!this.config) throw new Error("Firebase API httpsCallable not initialized");
63
- return this.config.httpsCallable;
64
- }
65
- customHttpsCallable(functionName) {
66
- return this.httpsCallable(this.functions, functionName);
59
+ return this.config.httpsCallable(functionName);
67
60
  }
68
61
  accessQueryConstraints() {
69
62
  const { query, orderBy, limit, startAt, startAfter, endAt, endBefore } = this.helpers;
@@ -748,17 +741,15 @@ var WEB_BASE_URL = "https://app.speakable.io";
748
741
 
749
742
  // src/lib/firebase/firebase-functions.ts
750
743
  var SpeakableFirebaseFunctions = {
751
- updateAssignmentGradebookStatus: api.customHttpsCallable("updateAssignmentGradebookStatus"),
752
- onSetOpened: api.customHttpsCallable("onSetOpened"),
753
- updateAlgoliaIndex: api.customHttpsCallable("updateAlgoliaIndex"),
754
- submitAssignmentToGoogleClassroomV2: api.customHttpsCallable(
755
- "submitAssignmentToGoogleClassroomV2"
756
- ),
757
- submitLTIAssignmentScore: api.customHttpsCallable("submitLTIAssignmentScore"),
758
- submitAssignmentV2: api.customHttpsCallable("submitLTIAssignmentScoreV2"),
759
- submitAssessment: api.customHttpsCallable("submitAssessment"),
760
- sendAssessmentScoredEmail: api.customHttpsCallable("sendAssessmentScoredEmail"),
761
- createNotification: api.customHttpsCallable("createNotificationV2")
744
+ updateAssignmentGradebookStatus: api.httpsCallable("updateAssignmentGradebookStatus"),
745
+ onSetOpened: api.httpsCallable("onSetOpened"),
746
+ updateAlgoliaIndex: api.httpsCallable("updateAlgoliaIndex"),
747
+ submitAssignmentToGoogleClassroomV2: api.httpsCallable("submitAssignmentToGoogleClassroomV2"),
748
+ submitLTIAssignmentScore: api.httpsCallable("submitLTIAssignmentScore"),
749
+ submitAssignmentV2: api.httpsCallable("submitLTIAssignmentScoreV2"),
750
+ submitAssessment: api.httpsCallable("submitAssessment"),
751
+ sendAssessmentScoredEmail: api.httpsCallable("sendAssessmentScoredEmail"),
752
+ createNotification: api.httpsCallable("createNotificationV2")
762
753
  };
763
754
 
764
755
  // src/domains/notification/services/send-notification.service.ts
@@ -916,20 +907,16 @@ var useCreateNotification = () => {
916
907
  };
917
908
 
918
909
  // src/lib/create-firebase-client.ts
919
- var _functions = require('firebase/functions');
920
- var _functions3 = require('@react-native-firebase/functions');
921
910
  async function createFsClient({
922
911
  db,
923
912
  platform,
924
- functions
913
+ httpsCallable
925
914
  }) {
926
915
  const dbAsFirestore = db;
927
916
  const helpers = platform === "web" ? await Promise.resolve().then(() => _interopRequireWildcard(require("firebase/firestore"))) : await Promise.resolve().then(() => _interopRequireWildcard(require("@react-native-firebase/firestore")));
928
- const httpsCallable = platform === "web" ? _functions.httpsCallable : _functions3.httpsCallable;
929
917
  api.initialize({
930
918
  db: dbAsFirestore,
931
919
  helpers,
932
- functions,
933
920
  httpsCallable
934
921
  });
935
922
  return {
@@ -948,18 +935,18 @@ function SpeakableProvider({
948
935
  queryClient,
949
936
  user,
950
937
  permissions,
951
- functions
938
+ httpsCallable
952
939
  }) {
953
940
  const [speakableApi, setSpeakableApi] = _react.useState.call(void 0, null);
954
941
  _react.useEffect.call(void 0, () => {
955
942
  createFsClient({
956
943
  db,
957
- functions,
944
+ httpsCallable,
958
945
  platform
959
946
  }).then((repos) => {
960
947
  setSpeakableApi(repos);
961
948
  });
962
- }, [db, functions, platform]);
949
+ }, [db, platform, httpsCallable]);
963
950
  if (!speakableApi) return null;
964
951
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
965
952
  FsCtx.Provider,
@@ -968,8 +955,7 @@ function SpeakableProvider({
968
955
  speakableApi,
969
956
  queryClient,
970
957
  user,
971
- permissions,
972
- functions
958
+ permissions
973
959
  },
974
960
  children
975
961
  }
package/dist/index.mjs CHANGED
@@ -54,16 +54,9 @@ 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
- get functions() {
57
+ httpsCallable(functionName) {
58
58
  if (!this.config) throw new Error("Firebase API not initialized");
59
- return this.config.functions;
60
- }
61
- get httpsCallable() {
62
- if (!this.config) throw new Error("Firebase API httpsCallable not initialized");
63
- return this.config.httpsCallable;
64
- }
65
- customHttpsCallable(functionName) {
66
- return this.httpsCallable(this.functions, functionName);
59
+ return this.config.httpsCallable(functionName);
67
60
  }
68
61
  accessQueryConstraints() {
69
62
  const { query, orderBy, limit, startAt, startAfter, endAt, endBefore } = this.helpers;
@@ -748,17 +741,15 @@ var WEB_BASE_URL = "https://app.speakable.io";
748
741
 
749
742
  // src/lib/firebase/firebase-functions.ts
750
743
  var SpeakableFirebaseFunctions = {
751
- updateAssignmentGradebookStatus: api.customHttpsCallable("updateAssignmentGradebookStatus"),
752
- onSetOpened: api.customHttpsCallable("onSetOpened"),
753
- updateAlgoliaIndex: api.customHttpsCallable("updateAlgoliaIndex"),
754
- submitAssignmentToGoogleClassroomV2: api.customHttpsCallable(
755
- "submitAssignmentToGoogleClassroomV2"
756
- ),
757
- submitLTIAssignmentScore: api.customHttpsCallable("submitLTIAssignmentScore"),
758
- submitAssignmentV2: api.customHttpsCallable("submitLTIAssignmentScoreV2"),
759
- submitAssessment: api.customHttpsCallable("submitAssessment"),
760
- sendAssessmentScoredEmail: api.customHttpsCallable("sendAssessmentScoredEmail"),
761
- createNotification: api.customHttpsCallable("createNotificationV2")
744
+ updateAssignmentGradebookStatus: api.httpsCallable("updateAssignmentGradebookStatus"),
745
+ onSetOpened: api.httpsCallable("onSetOpened"),
746
+ updateAlgoliaIndex: api.httpsCallable("updateAlgoliaIndex"),
747
+ submitAssignmentToGoogleClassroomV2: api.httpsCallable("submitAssignmentToGoogleClassroomV2"),
748
+ submitLTIAssignmentScore: api.httpsCallable("submitLTIAssignmentScore"),
749
+ submitAssignmentV2: api.httpsCallable("submitLTIAssignmentScoreV2"),
750
+ submitAssessment: api.httpsCallable("submitAssessment"),
751
+ sendAssessmentScoredEmail: api.httpsCallable("sendAssessmentScoredEmail"),
752
+ createNotification: api.httpsCallable("createNotificationV2")
762
753
  };
763
754
 
764
755
  // src/domains/notification/services/send-notification.service.ts
@@ -916,20 +907,16 @@ var useCreateNotification = () => {
916
907
  };
917
908
 
918
909
  // src/lib/create-firebase-client.ts
919
- import { httpsCallable as webHttpsCallable } from "firebase/functions";
920
- import { httpsCallable as nativeHttpsCallable } from "@react-native-firebase/functions";
921
910
  async function createFsClient({
922
911
  db,
923
912
  platform,
924
- functions
913
+ httpsCallable
925
914
  }) {
926
915
  const dbAsFirestore = db;
927
916
  const helpers = platform === "web" ? await import("firebase/firestore") : await import("@react-native-firebase/firestore");
928
- const httpsCallable = platform === "web" ? webHttpsCallable : nativeHttpsCallable;
929
917
  api.initialize({
930
918
  db: dbAsFirestore,
931
919
  helpers,
932
- functions,
933
920
  httpsCallable
934
921
  });
935
922
  return {
@@ -948,18 +935,18 @@ function SpeakableProvider({
948
935
  queryClient,
949
936
  user,
950
937
  permissions,
951
- functions
938
+ httpsCallable
952
939
  }) {
953
940
  const [speakableApi, setSpeakableApi] = useState(null);
954
941
  useEffect(() => {
955
942
  createFsClient({
956
943
  db,
957
- functions,
944
+ httpsCallable,
958
945
  platform
959
946
  }).then((repos) => {
960
947
  setSpeakableApi(repos);
961
948
  });
962
- }, [db, functions, platform]);
949
+ }, [db, platform, httpsCallable]);
963
950
  if (!speakableApi) return null;
964
951
  return /* @__PURE__ */ jsx(
965
952
  FsCtx.Provider,
@@ -968,8 +955,7 @@ function SpeakableProvider({
968
955
  speakableApi,
969
956
  queryClient,
970
957
  user,
971
- permissions,
972
- functions
958
+ permissions
973
959
  },
974
960
  children
975
961
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speakableio/core",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Speakable-io/speakable-core.git"