Skip to content

Commit a9941d3

Browse files
committed
chore: modernize \n- replace tslint with biome for linting and formatting- update dependencies- bump node version
1 parent c68dfc1 commit a9941d3

File tree

11 files changed

+5454
-6110
lines changed

11 files changed

+5454
-6110
lines changed

extension.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ resources:
3535
properties:
3636
location: us-central1
3737
httpsTrigger: {}
38-
runtime: "nodejs14"
38+
runtime: "nodejs20"
3939

4040
# Learn about the `params` field in the docs
4141
params:

functions/__tests__/bundle.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { buildQuery } from "../src/build_bundle";
21
import * as admin from "firebase-admin";
2+
import { buildQuery } from "../src/build_bundle";
33

44
describe("buildQuery", () => {
55
let db: admin.firestore.Firestore;
@@ -22,7 +22,7 @@ describe("buildQuery", () => {
2222
collectionGroupQuery: true,
2323
},
2424
{},
25-
{}
25+
{},
2626
),
2727
db.collectionGroup("test-coll") as admin.firestore.Query,
2828
],
@@ -39,7 +39,7 @@ describe("buildQuery", () => {
3939
],
4040
},
4141
{},
42-
{}
42+
{},
4343
),
4444
db
4545
.collection("test-coll")
@@ -62,7 +62,7 @@ describe("buildQuery", () => {
6262
],
6363
},
6464
{},
65-
{}
65+
{},
6666
),
6767
db
6868
.collection("test-coll")
@@ -94,7 +94,7 @@ describe("buildQuery", () => {
9494
field: "field1",
9595
limit: 10,
9696
contains: ["a", "d", "e"],
97-
}
97+
},
9898
),
9999
db
100100
.collection("test-coll")
@@ -126,7 +126,7 @@ describe("buildQuery", () => {
126126
otherField: "otherField",
127127
floatValue: 3.0,
128128
value: false,
129-
}
129+
},
130130
),
131131
db
132132
.collection("test-coll")

functions/__tests__/functions.test.ts

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as admin from "firebase-admin";
2-
import axios from "axios";
32

43
process.env.FIRESTORE_EMULATOR_HOST = "localhost:8080";
54
process.env.FIREBASE_FIRESTORE_EMULATOR_ADDRESS = "localhost:8080";
@@ -30,7 +29,8 @@ describe("functions", () => {
3029
it("successfully returns a bundle with queries, documents and params combined", async () => {
3130
const bundleName = "documents-queries-params";
3231
const url = extUrl(bundleName);
33-
const { data: bundle } = await axios(url);
32+
const response = await fetch(url);
33+
const bundle = await response.arrayBuffer();
3434

3535
const [metadata, documentMetadata, document] =
3636
extractObjectfromBuffer(bundle);
@@ -49,7 +49,8 @@ describe("functions", () => {
4949
it("successfully returns a bundle using a query with a collection", async () => {
5050
const bundleName = "query-with-a-collection";
5151
const url = extUrl(bundleName);
52-
const { data: bundle } = await axios(url);
52+
const response = await fetch(url);
53+
const bundle = await response.arrayBuffer();
5354

5455
const [metadata, documentMetadata, document] =
5556
extractObjectfromBuffer(bundle);
@@ -68,7 +69,8 @@ describe("functions", () => {
6869
it("successfully returns a bundle using a query with a collection and condition", async () => {
6970
const bundleName = "query-with-a-collection-and-condition";
7071
const url = extUrl(bundleName);
71-
const { data: bundle } = await axios(url);
72+
const response = await fetch(url);
73+
const bundle = await response.arrayBuffer();
7274

7375
const [metadata, documentMetadata, document] =
7476
extractObjectfromBuffer(bundle);
@@ -87,7 +89,8 @@ describe("functions", () => {
8789
it("successfully returns a bundle using a query with a collection and where clause", async () => {
8890
const bundleName = "query-with-a-collection-and-condition";
8991
const url = extUrl(bundleName);
90-
const { data: bundle } = await axios(url);
92+
const response = await fetch(url);
93+
const bundle = await response.arrayBuffer();
9194

9295
const [metadata, documentMetadata, document] =
9396
extractObjectfromBuffer(bundle);
@@ -106,7 +109,8 @@ describe("functions", () => {
106109
xit("successfully returns a bundle using a query with a collection and multiple where clauses", async () => {
107110
const bundleName = "query-with-a-collection-and-multiple-where-conditions";
108111
const url = extUrl(bundleName);
109-
const { data: bundle } = await axios(url);
112+
const response = await fetch(url);
113+
const bundle = await response.arrayBuffer();
110114

111115
const [metadata, documentMetadata, document] =
112116
extractObjectfromBuffer(bundle);
@@ -125,7 +129,8 @@ describe("functions", () => {
125129
it("successfully returns a bundle using a document", async () => {
126130
const bundleName = "single-document";
127131
const url = extUrl(bundleName);
128-
const { data: bundle } = await axios(url);
132+
const response = await fetch(url);
133+
const bundle = await response.arrayBuffer();
129134

130135
const [metadata, documentMetadata, document] =
131136
extractObjectfromBuffer(bundle);
@@ -136,19 +141,20 @@ describe("functions", () => {
136141

137142
/*** check document metadata */
138143
expect(documentMetadata.documentMetadata.name).toEqual(
139-
"projects/demo-experimental/databases/(default)/documents/documents/document1"
144+
"projects/demo-experimental/databases/(default)/documents/documents/document1",
140145
);
141146

142147
/*** check document */
143148
expect(document.document.name).toEqual(
144-
"projects/demo-experimental/databases/(default)/documents/documents/document1"
149+
"projects/demo-experimental/databases/(default)/documents/documents/document1",
145150
);
146151
});
147152

148153
it("successfully returns a bundle using multiple documents", async () => {
149154
const bundleName = "multiple-documents";
150155
const url = extUrl(bundleName);
151-
const { data: bundle } = await axios(url);
156+
const response = await fetch(url);
157+
const bundle = await response.arrayBuffer();
152158

153159
const [metadata, documentMetadata, document] =
154160
extractObjectfromBuffer(bundle);
@@ -172,7 +178,8 @@ describe("functions", () => {
172178
it("successfully returns a bundle using params", async () => {
173179
const bundleName = "query-with-param";
174180
const url = extUrl(bundleName) + "?name=document2";
175-
const { data: bundle } = await axios(url);
181+
const response = await fetch(url);
182+
const bundle = await response.arrayBuffer();
176183

177184
const [metadata, documentMetadata, document] =
178185
extractObjectfromBuffer(bundle);
@@ -191,7 +198,8 @@ describe("functions", () => {
191198
it("successfully returns a bundle using clientCache", async () => {
192199
const bundleName = "with-client-cache";
193200
const url = extUrl(bundleName);
194-
const { data: bundle } = await axios(url);
201+
const response = await fetch(url);
202+
const bundle = await response.arrayBuffer();
195203

196204
const [metadata, documentMetadata, document] =
197205
extractObjectfromBuffer(bundle);
@@ -204,7 +212,8 @@ describe("functions", () => {
204212
xit("successfully returns a bundle using serverCache", async () => {
205213
const bundleName = "with-server-cache";
206214
const url = extUrl(bundleName);
207-
const { data: bundle } = await axios(url);
215+
const response = await fetch(url);
216+
const bundle = await response.arrayBuffer();
208217

209218
const [metadata, documentMetadata, document] =
210219
extractObjectfromBuffer(bundle);
@@ -217,7 +226,8 @@ describe("functions", () => {
217226
xit("successfully returns a bundle using fileCache", async () => {
218227
const bundleName = "with-file-cache";
219228
const url = extUrl(bundleName);
220-
const { data: bundle } = await axios(url);
229+
const response = await fetch(url);
230+
const bundle = await response.arrayBuffer();
221231

222232
const [metadata, documentMetadata, document] =
223233
extractObjectfromBuffer(bundle);
@@ -230,7 +240,8 @@ describe("functions", () => {
230240
xit("successfully returns a request through a webiste hosted by Firebase", async () => {
231241
const bundleName = "documents-queries-params";
232242
const url = extHostedUrl(bundleName);
233-
const { data: bundle } = await axios(url);
243+
const response = await fetch(url);
244+
const bundle = await response.arrayBuffer();
234245

235246
const [metadata, documentMetadata, document] =
236247
extractObjectfromBuffer(bundle);
@@ -250,12 +261,7 @@ describe("functions", () => {
250261
const bundleName = "unknown-bundle";
251262
const url = extHostedUrl(bundleName);
252263

253-
return axios(url)
254-
.then(() => {
255-
fail("should not succeed");
256-
})
257-
.catch((ex) => {
258-
expect(ex.response.status).toEqual(404);
259-
});
264+
const response = await fetch(url);
265+
expect(response.status).toEqual(404);
260266
});
261267
});

functions/biome.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.1.0/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"ignoreUnknown": false,
10+
"includes": ["src/**/*.ts", "__tests__/**/*.ts"]
11+
},
12+
"formatter": {
13+
"enabled": true,
14+
"indentStyle": "space",
15+
"indentWidth": 2,
16+
"lineWidth": 80
17+
},
18+
"linter": {
19+
"enabled": true,
20+
"rules": {
21+
"recommended": true
22+
}
23+
},
24+
"javascript": {
25+
"formatter": {
26+
"quoteStyle": "double"
27+
}
28+
},
29+
"assist": {
30+
"enabled": true
31+
}
32+
}

functions/jest.config.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
const packageJson = require("./package.json");
2-
31
module.exports = {
4-
name: packageJson.name,
5-
displayName: packageJson.name,
62
rootDir: "./",
73
preset: "ts-jest",
8-
globals: {
9-
"ts-jest": {
10-
tsConfig: "<rootDir>/__tests__/tsconfig.json",
11-
},
4+
transform: {
5+
"^.+\\.ts$": ["ts-jest", {
6+
tsconfig: "<rootDir>/__tests__/tsconfig.json",
7+
}],
128
},
139
testMatch: ["**/__tests__/*.test.ts"],
1410
testEnvironment: "node",

0 commit comments

Comments
 (0)