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