@speakableio/core 0.1.27 → 0.1.29

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.
@@ -2,12 +2,30 @@ 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 * as firebase_firestore from 'firebase/firestore';
6
- import { Firestore, Timestamp as Timestamp$1, FieldValue } from 'firebase/firestore';
7
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, Timestamp as Timestamp$1, FieldValue } from 'firebase/firestore';
8
7
 
9
8
  type FirebaseInstance = FirebaseFirestoreTypes.Module | Firestore;
10
- type FirestoreHelpers = typeof firebase_firestore;
9
+ interface FirestoreHelpers {
10
+ getDoc: typeof getDoc;
11
+ getDocs: typeof getDocs;
12
+ addDoc: typeof addDoc;
13
+ setDoc: typeof setDoc;
14
+ updateDoc: typeof updateDoc;
15
+ deleteDoc: typeof deleteDoc;
16
+ runTransaction: typeof runTransaction;
17
+ writeBatch: typeof writeBatch;
18
+ doc: typeof doc;
19
+ collection: typeof collection;
20
+ query: typeof query;
21
+ serverTimestamp: typeof serverTimestamp;
22
+ orderBy: typeof orderBy;
23
+ limit: typeof limit;
24
+ startAt: typeof startAt;
25
+ startAfter: typeof startAfter;
26
+ endAt: typeof endAt;
27
+ endBefore: typeof endBefore;
28
+ }
11
29
  type CustomTimestamp = Timestamp | Timestamp$1;
12
30
  type CallableFunction<T = any, R = any> = (data: T) => Promise<R>;
13
31
 
@@ -95,31 +95,31 @@ var FirebaseAPI = class _FirebaseAPI {
95
95
  (_a = this.config) == null ? void 0 : _a.logEvent(name, data);
96
96
  }
97
97
  accessQueryConstraints() {
98
- const { query, orderBy, limit, startAt, startAfter, endAt, endBefore } = this.helpers;
98
+ const { query: query2, orderBy: orderBy2, limit: limit2, startAt: startAt2, startAfter: startAfter2, endAt: endAt2, endBefore: endBefore2 } = this.helpers;
99
99
  return {
100
- query,
101
- orderBy,
102
- limit,
103
- startAt,
104
- startAfter,
105
- endAt,
106
- endBefore
100
+ query: query2,
101
+ orderBy: orderBy2,
102
+ limit: limit2,
103
+ startAt: startAt2,
104
+ startAfter: startAfter2,
105
+ endAt: endAt2,
106
+ endBefore: endBefore2
107
107
  };
108
108
  }
109
109
  accessHelpers() {
110
- const { doc, collection, writeBatch, serverTimestamp, setDoc } = this.helpers;
110
+ const { doc: doc2, collection: collection2, writeBatch: writeBatch2, serverTimestamp: serverTimestamp2, setDoc: setDoc2 } = this.helpers;
111
111
  return {
112
- doc: (path) => doc(this.db, path),
113
- collection: (path) => collection(this.db, path),
114
- writeBatch: () => writeBatch(this.db),
115
- serverTimestamp,
116
- setDoc
112
+ doc: (path) => doc2(this.db, path),
113
+ collection: (path) => collection2(this.db, path),
114
+ writeBatch: () => writeBatch2(this.db),
115
+ serverTimestamp: serverTimestamp2,
116
+ setDoc: setDoc2
117
117
  };
118
118
  }
119
119
  async getDoc(path) {
120
- const { getDoc, doc } = this.helpers;
121
- const docRef = doc(this.db, path);
122
- const docSnap = await getDoc(docRef);
120
+ const { getDoc: getDoc2, doc: doc2 } = this.helpers;
121
+ const docRef = doc2(this.db, path);
122
+ const docSnap = await getDoc2(docRef);
123
123
  const data = docSnap.exists() ? {
124
124
  id: docSnap.id,
125
125
  ...docSnap.data()
@@ -130,13 +130,13 @@ var FirebaseAPI = class _FirebaseAPI {
130
130
  };
131
131
  }
132
132
  async getDocs(path, ...queryConstraints) {
133
- const { getDocs, query, collection } = this.helpers;
134
- const collectionRef = collection(this.db, path);
135
- const q = queryConstraints.length > 0 ? query(collectionRef, ...queryConstraints) : collectionRef;
136
- const querySnapshot = await getDocs(q);
137
- const data = querySnapshot.docs.map((doc) => ({
138
- id: doc.id,
139
- data: doc.data()
133
+ const { getDocs: getDocs2, query: query2, collection: collection2 } = this.helpers;
134
+ const collectionRef = collection2(this.db, path);
135
+ const q = queryConstraints.length > 0 ? query2(collectionRef, ...queryConstraints) : collectionRef;
136
+ const querySnapshot = await getDocs2(q);
137
+ const data = querySnapshot.docs.map((doc2) => ({
138
+ id: doc2.id,
139
+ data: doc2.data()
140
140
  }));
141
141
  return {
142
142
  data,
@@ -144,42 +144,42 @@ var FirebaseAPI = class _FirebaseAPI {
144
144
  };
145
145
  }
146
146
  async addDoc(path, data) {
147
- const { addDoc, collection } = this.helpers;
148
- const collectionRef = collection(this.db, path);
149
- const docRef = await addDoc(collectionRef, data);
147
+ const { addDoc: addDoc2, collection: collection2 } = this.helpers;
148
+ const collectionRef = collection2(this.db, path);
149
+ const docRef = await addDoc2(collectionRef, data);
150
150
  return {
151
151
  id: docRef.id,
152
152
  ...data
153
153
  };
154
154
  }
155
155
  async setDoc(path, data, options = {}) {
156
- const { setDoc, doc } = this.helpers;
157
- const docRef = doc(this.db, path);
158
- await setDoc(docRef, data, options);
156
+ const { setDoc: setDoc2, doc: doc2 } = this.helpers;
157
+ const docRef = doc2(this.db, path);
158
+ await setDoc2(docRef, data, options);
159
159
  }
160
160
  async updateDoc(path, data) {
161
- const { updateDoc, doc } = this.helpers;
162
- const docRef = doc(this.db, path);
163
- await updateDoc(docRef, data);
161
+ const { updateDoc: updateDoc2, doc: doc2 } = this.helpers;
162
+ const docRef = doc2(this.db, path);
163
+ await updateDoc2(docRef, data);
164
164
  }
165
165
  async deleteDoc(path) {
166
- const { deleteDoc, doc } = this.helpers;
167
- const docRef = doc(this.db, path);
168
- await deleteDoc(docRef);
166
+ const { deleteDoc: deleteDoc2, doc: doc2 } = this.helpers;
167
+ const docRef = doc2(this.db, path);
168
+ await deleteDoc2(docRef);
169
169
  }
170
170
  async runTransaction(updateFunction) {
171
- const { runTransaction } = this.helpers;
172
- return runTransaction(this.db, updateFunction);
171
+ const { runTransaction: runTransaction2 } = this.helpers;
172
+ return runTransaction2(this.db, updateFunction);
173
173
  }
174
174
  async runBatch(operations) {
175
- const { writeBatch } = this.helpers;
176
- const batch = writeBatch(this.db);
175
+ const { writeBatch: writeBatch2 } = this.helpers;
176
+ const batch = writeBatch2(this.db);
177
177
  await Promise.all(operations.map((op) => op()));
178
178
  await batch.commit();
179
179
  }
180
180
  writeBatch() {
181
- const { writeBatch } = this.helpers;
182
- const batch = writeBatch(this.db);
181
+ const { writeBatch: writeBatch2 } = this.helpers;
182
+ const batch = writeBatch2(this.db);
183
183
  return batch;
184
184
  }
185
185
  };
@@ -599,12 +599,12 @@ async function _createCard({ data }) {
599
599
  }
600
600
  var createCard = withErrorHandler(_createCard, "createCard");
601
601
  async function _createCards({ cards }) {
602
- const { writeBatch, doc } = api.accessHelpers();
603
- const batch = writeBatch();
602
+ const { writeBatch: writeBatch2, doc: doc2 } = api.accessHelpers();
603
+ const batch = writeBatch2();
604
604
  const cardsWithId = [];
605
605
  for (const card of cards) {
606
606
  const cardId = v4();
607
- const ref = doc(refsCardsFiresotre.card(cardId));
607
+ const ref = doc2(refsCardsFiresotre.card(cardId));
608
608
  const newCardObject = {
609
609
  ...card,
610
610
  id: cardId
@@ -640,7 +640,7 @@ function useCards({
640
640
  queryFn: () => getCard({ cardId })
641
641
  }))
642
642
  });
643
- const cards = queries.map((query) => query.data).filter(Boolean);
643
+ const cards = queries.map((query2) => query2.data).filter(Boolean);
644
644
  const cardsObject = useMemo(() => {
645
645
  if (!asObject) return null;
646
646
  return cards.reduce((acc, card) => {
@@ -1270,15 +1270,15 @@ var logStartAssignment = (data = {}) => {
1270
1270
 
1271
1271
  // src/domains/assignment/utils/create-default-score.ts
1272
1272
  var defaultScore = (props) => {
1273
- const { serverTimestamp } = api.accessHelpers();
1273
+ const { serverTimestamp: serverTimestamp2 } = api.accessHelpers();
1274
1274
  const score = {
1275
1275
  progress: 0,
1276
1276
  score: 0,
1277
- startDate: serverTimestamp(),
1277
+ startDate: serverTimestamp2(),
1278
1278
  status: "IN_PROGRESS",
1279
1279
  submitted: false,
1280
1280
  cards: {},
1281
- lastPlayed: serverTimestamp(),
1281
+ lastPlayed: serverTimestamp2(),
1282
1282
  owners: props.owners,
1283
1283
  userId: props.userId
1284
1284
  };
@@ -1533,12 +1533,12 @@ async function _submitAssignmentScore({
1533
1533
  status,
1534
1534
  studentName
1535
1535
  }) {
1536
- const { serverTimestamp } = api.accessHelpers();
1536
+ const { serverTimestamp: serverTimestamp2 } = api.accessHelpers();
1537
1537
  const path = refsAssignmentFiresotre.assignmentScores({ id: assignment.id, userId });
1538
1538
  const fieldsUpdated = {
1539
1539
  submitted: true,
1540
1540
  progress: 100,
1541
- submissionDate: serverTimestamp(),
1541
+ submissionDate: serverTimestamp2(),
1542
1542
  status
1543
1543
  };
1544
1544
  if (assignment.isAssessment) {
@@ -1592,14 +1592,14 @@ async function submitPracticeScore({
1592
1592
  userId,
1593
1593
  scores
1594
1594
  }) {
1595
- const { serverTimestamp } = api.accessHelpers();
1595
+ const { serverTimestamp: serverTimestamp2 } = api.accessHelpers();
1596
1596
  const date = dayjs4().format("YYYY-MM-DD-HH-mm");
1597
1597
  const ref = refsScoresPractice.practiceScoreHistoryRefDoc({ setId, userId, date });
1598
1598
  const fieldsUpdated = {
1599
1599
  ...scores,
1600
1600
  submitted: true,
1601
1601
  progress: 100,
1602
- submissionDate: serverTimestamp(),
1602
+ submissionDate: serverTimestamp2(),
1603
1603
  status: "SUBMITTED"
1604
1604
  };
1605
1605
  await api.setDoc(ref, { ...fieldsUpdated });
@@ -1906,10 +1906,10 @@ function useActivityTracker({ userId }) {
1906
1906
  language = ""
1907
1907
  }) => {
1908
1908
  if (userId) {
1909
- const { doc, serverTimestamp, setDoc } = api.accessHelpers();
1910
- const activityRef = doc(`users/${userId}/activity${id}`);
1911
- const timestamp = serverTimestamp();
1912
- await setDoc(activityRef, {
1909
+ const { doc: doc2, serverTimestamp: serverTimestamp2, setDoc: setDoc2 } = api.accessHelpers();
1910
+ const activityRef = doc2(`users/${userId}/activity${id}`);
1911
+ const timestamp = serverTimestamp2();
1912
+ await setDoc2(activityRef, {
1913
1913
  name: activityName,
1914
1914
  type: activityType,
1915
1915
  lastSeen: timestamp,
@@ -2050,7 +2050,7 @@ function useActivity({
2050
2050
  const card = cardsObject == null ? void 0 : cardsObject[cardId];
2051
2051
  const scoresObject = queryClient.getQueryData(scoreQueryKeys.byId(activityId));
2052
2052
  const cardScore = (_a2 = scoresObject == null ? void 0 : scoresObject.cards) == null ? void 0 : _a2[cardId];
2053
- const serverTimestamp = api.helpers.serverTimestamp;
2053
+ const serverTimestamp2 = api.helpers.serverTimestamp;
2054
2054
  addGradingStandardLog(
2055
2055
  {
2056
2056
  assignmentId: (_b2 = activeAssignment == null ? void 0 : activeAssignment.id) != null ? _b2 : "",
@@ -2065,7 +2065,7 @@ function useActivity({
2065
2065
  prompt: (_h = card == null ? void 0 : card.prompt) != null ? _h : "",
2066
2066
  responseType: (card == null ? void 0 : card.type) === "RESPOND_WRITE" /* RESPOND_WRITE */ ? "written" : "spoken",
2067
2067
  type,
2068
- dateMade: serverTimestamp()
2068
+ dateMade: serverTimestamp2()
2069
2069
  },
2070
2070
  userId
2071
2071
  );
@@ -2183,7 +2183,26 @@ var submitLTIScore = async ({
2183
2183
  };
2184
2184
 
2185
2185
  // src/lib/create-firebase-client-native.ts
2186
- import firestore from "@react-native-firebase/firestore";
2186
+ import {
2187
+ getDoc,
2188
+ getDocs,
2189
+ addDoc,
2190
+ setDoc,
2191
+ updateDoc,
2192
+ deleteDoc,
2193
+ runTransaction,
2194
+ writeBatch,
2195
+ doc,
2196
+ collection,
2197
+ query,
2198
+ serverTimestamp,
2199
+ orderBy,
2200
+ limit,
2201
+ startAt,
2202
+ startAfter,
2203
+ endAt,
2204
+ endBefore
2205
+ } from "@react-native-firebase/firestore";
2187
2206
 
2188
2207
  // src/lib/create-firebase-client.ts
2189
2208
  function createFsClientBase({
@@ -2215,7 +2234,26 @@ var createFsClientNative = ({
2215
2234
  db,
2216
2235
  httpsCallable,
2217
2236
  logEvent,
2218
- helpers: firestore
2237
+ helpers: {
2238
+ getDoc,
2239
+ getDocs,
2240
+ addDoc,
2241
+ setDoc,
2242
+ updateDoc,
2243
+ deleteDoc,
2244
+ runTransaction,
2245
+ writeBatch,
2246
+ doc,
2247
+ collection,
2248
+ query,
2249
+ serverTimestamp,
2250
+ orderBy,
2251
+ limit,
2252
+ startAt,
2253
+ startAfter,
2254
+ endAt,
2255
+ endBefore
2256
+ }
2219
2257
  });
2220
2258
  };
2221
2259
  export {