firebase / firebase/firebase-js-sdk
FR: Export types for REST API
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
### [REQUIRED] Describe your environment
* Operating System version: N/A
* Browser version: N/A
* Firebase SDK version: 10
* Firebase Product: auth, firestore
### [REQUIRED] Describe the problem
#### Steps to reproduce:
I am building a web app that I would like to operate, server side, on behalf of the user - respecting Firebase security rules.
The only option for this, as far as I can see, is to use the REST API, as confirmed here:
https://stackoverflow.com/questions/72239419/using-firebase-security-rules-from-a-web-server/72240567#72240567
I have this working but it would be a great benefit to have access to the types for the API data structures.
I see that the types for the Firestore REST API are already contained in firebase-js-sdk, and I can use them if I import it as follows:
```ts
import type {
StructuredQuery,
FieldFilter,
Filter,
FieldFilterOp,
} from '@firebase/firestore/dist/firestore/src/protos/firestore_proto_api';
```
However, I am fairly certain this file has not been designed to be imported like this and would be brittle, e.g. if it were to be moved.
I can, of course, copy the types in to my project, but it would be useful if these types were made available as an export, potentially via `@firebase/firestore-types` or creating a new `@firebase/firestore-rest-types`?
The auth types, on the other hand, I have not been able to find - e.g. the [response from "Get user data"](https://firebase.google.com/docs/reference/rest/auth#section-get-account-info). Any idea if these live somewhere?
The Operator and Direction enums from @firebase/firestore/dist/firestore/src/core/target would also be useful, as they provide a mapping between this SDK and the REST API's equivalent values.
Slightly related - I have written a library in order to connect to the REST API that would perhaps be better served as an open source project, perhaps even added to firebase-js-sdk. If you would be open to a contribution like this, please let me know.
#### Relevant Code:
https://github.com/firebase/firebase-js-sdk/blob/a69220b519185239c364f7a5b3d5983e9c87d7c1/packages/firestore/src/protos/firestore_proto_api.ts
Contributor guide
Assessment
This issue has not been assessed yet.