Skip to content

Commit

Permalink
Update Firebase packages (#493)
Browse files Browse the repository at this point in the history
* TOOL: updates @angular/fire, firebase, and firebase-tools packages

* FEATURE: updates typing in Batch class and FirestoreService after package updates

* TOOL: updates rxfire to 6.0.5

* TOOL: updates firebase-admin package

* TEST: adds TextDecoder fix from Github issue thread to fix breaking tests

* TEST: missed adding fix to one test
  • Loading branch information
johnnycopes committed Dec 17, 2023
1 parent 25bca1d commit 03a4f9a
Show file tree
Hide file tree
Showing 8 changed files with 4,860 additions and 4,648 deletions.
24 changes: 15 additions & 9 deletions libs/firebase/data-access/src/lib/firestore/batch.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { DocumentReference, WriteBatch } from '@angular/fire/firestore';
import {
DocumentReference,
FieldValue,
WriteBatch,
} from '@angular/fire/firestore';

export interface BatchSet<T> {
endpoint: string;
id: string;
data: T;
}

export type BatchUpdate = BatchSet<{ [fieldPath: string]: unknown }>;
export type BatchUpdate = BatchSet<{
[x: string]: FieldValue | Partial<unknown> | undefined;
}>;

export class Batch {
constructor(
Expand All @@ -19,7 +25,7 @@ export class Batch {

set<T>({ endpoint, id, data }: BatchSet<T>): Batch {
const docRef = this._getDocRef<T>(endpoint, id);
this._batch.set<T>(docRef, data);
this._batch.set(docRef, data);
return this;
}

Expand All @@ -28,19 +34,19 @@ export class Batch {
return this;
}

update({ endpoint, id, data }: BatchUpdate): Batch {
const docRef = this._getDocRef(endpoint, id);
update<T>({ endpoint, id, data }: BatchUpdate): Batch {
const docRef = this._getDocRef<T>(endpoint, id);
this._batch.update(docRef, data);
return this;
}

updateMultiple(updates: BatchUpdate[]): Batch {
updates.forEach((update) => this.update(update));
updateMultiple<T>(updates: BatchUpdate[]): Batch {
updates.forEach((update) => this.update<T>(update));
return this;
}

delete(endpoint: string, id: string): Batch {
const docRef = this._getDocRef(endpoint, id);
delete<T>(endpoint: string, id: string): Batch {
const docRef = this._getDocRef<T>(endpoint, id);
this._batch.delete(docRef);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
DocumentReference,
Firestore,
Transaction,
UpdateData,
WriteBatch,
arrayRemove,
arrayUnion,
Expand Down Expand Up @@ -77,7 +76,7 @@ export class FirestoreService {
data: Partial<T>
): Promise<void> {
const doc = this._getDocRef<T>(endpoint, id);
return await updateDoc<T>(doc, data as UpdateData<T>);
return await updateDoc(doc, data);
}

async delete<T>(endpoint: string, id: string): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// TODO: remove this chunk after newer version of Jest is installed
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { TextEncoder, TextDecoder } = require('util');
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;

import { TAG_DTOS } from '@atocha/menu-matriarch/tags/data-access';
import { INGREDIENT_DTOS } from '@atocha/menu-matriarch/ingredients/data-access';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// TODO: remove this chunk after newer version of Jest is installed
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { TextEncoder, TextDecoder } = require('util');
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;

import { mapIngredientTypeDtoToIngredientType } from './map-ingredient-type-dto-to-ingredient-type';
import { INGREDIENT_DTOS, INGREDIENT_TYPE_DTOS } from '../mock-data';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// TODO: remove this chunk after newer version of Jest is installed
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { TextEncoder, TextDecoder } = require('util');
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;

import { PIZZA, SALAD } from '@atocha/menu-matriarch/dishes/data-access';
import { TAG_DTOS } from '@atocha/menu-matriarch/tags/data-access';
import { mapMealDtoToMeal } from './map-meal-dto-to-meal';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// TODO: remove this chunk after newer version of Jest is installed
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { TextEncoder, TextDecoder } = require('util');
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;

import { PIZZA, SALAD } from '@atocha/menu-matriarch/dishes/data-access';
import { mapMenuDtoToMenu } from './map-menu-dto-to-menu';
import { MENU_DTO } from '../mock-data';
Expand Down

0 comments on commit 03a4f9a

Please sign in to comment.