Skip to content

Commit

Permalink
Merge pull request #76 from YutaUra/renovate/firebase-admin-12.x
Browse files Browse the repository at this point in the history
Update dependency firebase-admin to v12
  • Loading branch information
YutaUra authored Sep 9, 2024
2 parents e0ef774 + 91af5d5 commit 53d42b7
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 592 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-cars-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firestore-emulator/server": minor
---

firebase-admin v12
4 changes: 2 additions & 2 deletions examples/firebase-admin-vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"type:check": "tsc --noEmit"
},
"dependencies": {
"vitest-environment-firestore-emulator": "workspace:*",
"date-fns": "3.6.0",
"firebase-admin": "11.11.1",
"vitest-environment-firestore-emulator": "workspace:*",
"firebase-admin": "12.4.0",
"firebase-tools": "13.15.4"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/firebase-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"@firestore-emulator/jest": "workspace:*",
"date-fns": "3.6.0",
"firebase-admin": "11.11.1",
"firebase-admin": "12.4.0",
"firebase-tools": "13.15.4"
},
"devDependencies": {
Expand Down
38 changes: 33 additions & 5 deletions packages/server/src/server/FirestoreServiceV1Impl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ export class FirestoreServiceV1Impl extends UnimplementedFirestoreService {
>,
): void {
const date = TimestampFromNow()
const tx = call.request.has_new_transaction
? Uint8Array.from([17, 2, 0, 0, 0, 0, 0, 0, 0])
: null
if (tx) {
call.write(
BatchGetDocumentsResponse.fromObject({
transaction: tx,
}),
)
}
call.request.documents.forEach((documentPath) => {
const document = this.#state.getDocument(documentPath)
call.write(
Expand All @@ -105,8 +115,15 @@ export class FirestoreServiceV1Impl extends UnimplementedFirestoreService {
_call: ServerUnaryCall<BeginTransactionRequest, BeginTransactionResponse>,
callback: sendUnaryData<BeginTransactionResponse>,
): void {
callback(null, BeginTransactionResponse.fromObject({}))
callback(
null,
BeginTransactionResponse.fromObject({
// dummy transaction id
transaction: Uint8Array.from([17, 2, 0, 0, 0, 0, 0, 0, 0]),
}),
)
}

override Commit(
call: ServerUnaryCall<CommitRequest, CommitResponse>,
callback: sendUnaryData<CommitResponse>,
Expand Down Expand Up @@ -162,17 +179,28 @@ export class FirestoreServiceV1Impl extends UnimplementedFirestoreService {
call.request.structured_query,
)

results.forEach((result, i, arr) => {
if (results.length > 0) {
results.forEach((result, i, arr) => {
call.write(
RunQueryResponse.fromObject({
document: result.toV1DocumentObject(),
done: i === arr.length - 1,
read_time: TimestampFromDate(date),
skipped_results: 0,
transaction: call.request.transaction,
}),
)
})
} else {
call.write(
RunQueryResponse.fromObject({
document: result.toV1DocumentObject(),
done: i === arr.length - 1,
done: true,
read_time: TimestampFromDate(date),
skipped_results: 0,
transaction: call.request.transaction,
}),
)
})
}

call.end()
}
Expand Down
1 change: 0 additions & 1 deletion packages/server/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class FirestoreServer {
reject(err)
return
}
this.server.start()
resolve(undefined)
},
)
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
type FirestoreState,
} from '@firestore-emulator/server'
import { findFreePorts } from 'find-free-ports'
import type { Environment } from 'vitest'
import type { Environment } from 'vitest/environments'
import { builtinEnvironments } from 'vitest/environments'

declare global {
Expand Down Expand Up @@ -55,4 +55,4 @@ export default {
throw new Error('Could not find a free port')
},
transformMode: 'ssr',
} as Environment
} satisfies Environment
Loading

0 comments on commit 53d42b7

Please sign in to comment.