@rebasepro/firebase 0.30.0 → 0.31.0-canary.g902a0ce

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.
package/README.md CHANGED
@@ -25,6 +25,18 @@ This package provides the full Firebase integration layer for Rebase. It include
25
25
 
26
26
  ## Key Exports
27
27
 
28
+ ### Collections
29
+
30
+ | Export | Description |
31
+ |---|---|
32
+ | `defineFirestoreCollection` | The way to declare a Firestore collection: `fields` (every Firestore property key, plus `required: true` and, on a reference, `target: "<collection slug>"` on any data source), `path`, `dataSource`, `subcollections`, `admin`. The document type is inferred from the fields |
33
+ | `FIRESTORE_CAPABILITIES` / `registerFirestoreCapabilities` | What the admin may offer on a Firestore collection (subcollections, no relations, no LIKE filters). Registered when the package is evaluated |
34
+
35
+ A `reference` field whose `target` lives on another data source (a Postgres
36
+ table's collection) is stored in the document as the target's id, a string,
37
+ and previewed and picked through that data source. A reference within the same
38
+ Firestore database is stored as a `DocumentReference`, as before.
39
+
28
40
  ### Components
29
41
 
30
42
  | Export | Description |
@@ -39,6 +51,7 @@ This package provides the full Firebase integration layer for Rebase. It include
39
51
  |---|---|
40
52
  | `useInitialiseFirebase` | Initializes the Firebase app from config |
41
53
  | `useFirebaseAuthController` | Manages Firebase Auth state (sign-in, sign-out, user) |
54
+ | `useFirestoreDataSource` | The memoised `<Rebase dataSources>` entry for a Firestore source: `useFirestoreDataSource({ key: "firestore", firebaseApp })` |
42
55
  | `useFirestoreDriver` | Creates a Firestore-backed `DataDriver` for CRUD and realtime listeners |
43
56
  | `useFirebaseStorageSource` | Provides file upload/download via Firebase Storage |
44
57
  | `useAppCheck` | Enables Firebase App Check verification |
@@ -0,0 +1,31 @@
1
+ import type { DataSourceCapabilities } from "@rebasepro/types";
2
+ /**
3
+ * What the Firestore engine can do, as the admin asks it: which editor tabs a
4
+ * collection gets (subcollections, never relations), which filter operators a
5
+ * column offers, whether a reference property exists.
6
+ *
7
+ * Firestore's own declaration, owned by the package that drives it. The admin
8
+ * reads capabilities through `getDataSourceCapabilities(engine)`, and this
9
+ * package registers this object under `firestore` before any of its
10
+ * collections can be rendered (see {@link registerFirestoreCapabilities}) — so
11
+ * the admin's answer for a Firestore collection never depends on a copy kept in
12
+ * `@rebasepro/types`.
13
+ *
14
+ * @group Firebase
15
+ */
16
+ export declare const FIRESTORE_CAPABILITIES: DataSourceCapabilities;
17
+ /**
18
+ * Register {@link FIRESTORE_CAPABILITIES} under the `firestore` engine.
19
+ *
20
+ * Runs when this module is evaluated — which importing `defineFirestoreCollection`
21
+ * or anything else from `@rebasepro/firebase` does — and again from
22
+ * `useFirestoreDataSource`, for a bundle that evaluated a second copy of the
23
+ * types package after this one. Without it, `getDataSourceCapabilities("firestore")`
24
+ * would answer with the permissive default: relation tabs, and "Contains"
25
+ * filters the driver refuses at query time.
26
+ *
27
+ * Idempotent: the registry is a map on a global symbol, keyed by engine.
28
+ *
29
+ * @group Firebase
30
+ */
31
+ export declare function registerFirestoreCapabilities(): void;
@@ -0,0 +1,87 @@
1
+ import "../capabilities.js";
2
+ import type { ResourceRef, User } from "@rebasepro/types";
3
+ import type { AnyCollectionConfig, FirebaseCollectionConfig, StrictProperties } from "@rebasepro/cms-types";
4
+ import { FirestoreDocumentOf, FirestoreField, FirestoreFields, FirestoreFieldsAsProperties } from "./fields.js";
5
+ /**
6
+ * A Firestore collection as the admin mounts it: engine `firestore`, its
7
+ * documents read and written in the browser by the Firestore driver of the
8
+ * data source its `dataSource` names (`transport: "direct"`), never through
9
+ * the Rebase backend.
10
+ *
11
+ * What {@link defineFirestoreCollection} returns.
12
+ *
13
+ * @group Firebase
14
+ */
15
+ export type FirestoreCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = FirebaseCollectionConfig<M, USER>;
16
+ /**
17
+ * Everything a Firestore collection declares besides its fields: `slug`,
18
+ * `name`, `path` (where its documents live, when that is not the slug),
19
+ * `dataSource`, `databaseId`, `subcollections`, `callbacks`, and the `admin`
20
+ * block (views, Kanban, icon, group, entity actions…), with `M` the document
21
+ * type the fields describe.
22
+ *
23
+ * @group Firebase
24
+ */
25
+ export type FirestoreCollectionOptions<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = Omit<FirebaseCollectionConfig<M, USER>, "properties" | "engine" | "dataSource" | "subcollections"> & {
26
+ /**
27
+ * The key of the `<Rebase dataSources>` entry that serves this
28
+ * collection — the `key` given to `useFirestoreDataSource`. Leave it
29
+ * out only when Firestore *is* the default data source
30
+ * (`RebaseFirebaseApp`).
31
+ */
32
+ dataSource?: ResourceRef;
33
+ /**
34
+ * The collections nested under each document, shown as tabs of the
35
+ * document and stored at `<path>/<id>/<child path>`. Each is
36
+ * declared with `defineFirestoreCollection` too.
37
+ */
38
+ subcollections?: () => AnyCollectionConfig[];
39
+ };
40
+ /**
41
+ * Declare a Firestore collection for the admin — the one way to declare one.
42
+ *
43
+ * `fields` are the collection's properties in Firestore's terms: every key a
44
+ * Firestore-capable property accepts, plus `required: true` for
45
+ * `validation.required` and, on a reference, `target: "<collection slug>"` for
46
+ * the collection it points at. A target may live on any data source: a
47
+ * reference from this collection to a Postgres table's collection is routed
48
+ * to the Postgres source when it is previewed or picked, and is stored in the
49
+ * document as the target's id (a string), so it can be queried with `==`.
50
+ *
51
+ * The document type is inferred from `fields` the way `defineCollection`
52
+ * infers it from `properties`, so `admin.display`, `admin.propertiesOrder`
53
+ * and callback values are checked against the collection's own keys.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const firestoreEvents = defineFirestoreCollection({
58
+ * slug: "fs_events",
59
+ * path: "events",
60
+ * name: "Live Events (Firestore)",
61
+ * dataSource: "firestore",
62
+ * fields: {
63
+ * type: { name: "Event Type", type: "string", required: true },
64
+ * payload: { name: "Payload", type: "map" },
65
+ * customerId: { name: "Customer", type: "reference", target: "customers" }
66
+ * },
67
+ * subcollections: () => [eventTracesFirestoreCollection]
68
+ * });
69
+ * ```
70
+ *
71
+ * @group Firebase
72
+ */
73
+ export declare function defineFirestoreCollection<
74
+ /**
75
+ * The fields, **constrained**: what checks each one against its kind and
76
+ * types the callbacks inside it.
77
+ */
78
+ const F extends FirestoreFields = FirestoreFields,
79
+ /**
80
+ * The fields again, **unconstrained**, so one bad field does not widen
81
+ * the key set every other check reads (see `defineCollection`).
82
+ */
83
+ const KEYS = FirestoreFields, USER extends User = User>(collection: FirestoreCollectionOptions<FirestoreDocumentOf<KEYS>, USER> & {
84
+ fields: StrictProperties<F, FirestoreField> & KEYS;
85
+ }): FirestoreCollection<FirestoreDocumentOf<KEYS>, USER> & {
86
+ properties: FirestoreFieldsAsProperties<KEYS>;
87
+ };
@@ -0,0 +1,159 @@
1
+ import type { FirebaseProperties, FirebaseProperty, InferEntityType, Property } from "@rebasepro/cms-types";
2
+ /**
3
+ * The keys a Firestore field adds to the property it describes. Each is a
4
+ * shorter way to write something the property model already has.
5
+ *
6
+ * @group Firebase
7
+ */
8
+ export interface FirestoreFieldShorthands {
9
+ /**
10
+ * The field must have a value: `validation.required`, written once. Writing
11
+ * both with different values is refused.
12
+ */
13
+ required?: boolean;
14
+ }
15
+ /** The Firestore property of one `type`. */
16
+ type KindOf<T> = Extract<FirebaseProperty, {
17
+ type: T;
18
+ }>;
19
+ /**
20
+ * A reference field: the reference property as Firestore allows it, with
21
+ * `target` in place of `path`.
22
+ * @group Firebase
23
+ */
24
+ export interface FirestoreReferenceField extends Omit<KindOf<"reference">, "path">, FirestoreFieldShorthands {
25
+ /**
26
+ * The slug of the collection this field points at — on any data source.
27
+ * A target on another source (a Postgres table's collection) is stored in
28
+ * the document as the target's id, a string, never as a Firestore
29
+ * `DocumentReference`; a target in the same Firestore database is stored
30
+ * as a `DocumentReference`, as before.
31
+ */
32
+ target?: string;
33
+ }
34
+ /**
35
+ * A map field, whose nested `properties` are fields too.
36
+ * @group Firebase
37
+ */
38
+ export interface FirestoreMapField extends Omit<KindOf<"map">, "properties">, FirestoreFieldShorthands {
39
+ /** The fields of the map, by key. */
40
+ properties?: FirestoreFields;
41
+ }
42
+ /**
43
+ * An array field, whose `of` and `oneOf` blocks are fields too.
44
+ * @group Firebase
45
+ */
46
+ export interface FirestoreArrayField extends Omit<KindOf<"array">, "of" | "oneOf">, FirestoreFieldShorthands {
47
+ /** The field every element of the array is, or one per position. */
48
+ of?: FirestoreField | readonly FirestoreField[];
49
+ /** Typed blocks: each element names its block type in `typeField`. */
50
+ oneOf?: FirestoreFieldBlocks;
51
+ }
52
+ /** Each kind that does not nest, with the shorthands. */
53
+ type ScalarField<P> = P extends unknown ? P & FirestoreFieldShorthands : never;
54
+ /**
55
+ * One field of a Firestore collection: any property Firestore can store —
56
+ * `string`, `number`, `boolean`, `date`, `geopoint`, `map`, `array`,
57
+ * `reference`, `binary` — with every key that kind accepts (validation, enum
58
+ * values with labels and colours, storage, conditions, `admin` presentation
59
+ * options), plus the {@link FirestoreFieldShorthands}.
60
+ *
61
+ * @group Firebase
62
+ */
63
+ export type FirestoreField = ScalarField<Exclude<FirebaseProperty, {
64
+ type: "reference" | "map" | "array";
65
+ }>> | FirestoreReferenceField | FirestoreMapField | FirestoreArrayField;
66
+ /**
67
+ * A Firestore collection's fields, by key.
68
+ * @group Firebase
69
+ */
70
+ export interface FirestoreFields {
71
+ [key: string]: FirestoreField;
72
+ }
73
+ /**
74
+ * The block types of an array of typed blocks (`array.oneOf`).
75
+ * @group Firebase
76
+ */
77
+ export interface FirestoreFieldBlocks {
78
+ /** One field per block type, keyed by the value of `typeField`. */
79
+ properties: FirestoreFields;
80
+ /** The order the block types are offered in. */
81
+ propertiesOrder?: string[];
82
+ /** The key holding a block's type. Defaults to `type`. */
83
+ typeField?: string;
84
+ /** The key holding a block's value. Defaults to `value`. */
85
+ valueField?: string;
86
+ }
87
+ /** `required: true`, as the property model says it. */
88
+ type RequiredPart<F> = F extends {
89
+ required: true;
90
+ } ? {
91
+ validation: {
92
+ required: true;
93
+ };
94
+ } : unknown;
95
+ /**
96
+ * The property a field normalises to, as a type: the shorthands written out,
97
+ * nested fields normalised the same way. What `defineFirestoreCollection`
98
+ * returns under `properties`, and what the document type is inferred from.
99
+ *
100
+ * @group Firebase
101
+ */
102
+ export type FirestoreFieldAsProperty<F> = Omit<F, "required" | "target" | "properties" | "of" | "oneOf"> & RequiredPart<F> & (F extends {
103
+ target: string;
104
+ } ? {
105
+ path: string;
106
+ } : unknown) & (F extends {
107
+ properties: infer NP;
108
+ } ? {
109
+ properties: FirestoreFieldsAsProperties<NP>;
110
+ } : unknown) & (F extends {
111
+ of: infer O;
112
+ } ? {
113
+ of: O extends readonly unknown[] ? {
114
+ -readonly [I in keyof O]: FirestoreFieldAsProperty<O[I]>;
115
+ } : FirestoreFieldAsProperty<O>;
116
+ } : unknown) & (F extends {
117
+ oneOf: infer B;
118
+ } ? {
119
+ oneOf: Omit<B, "properties"> & (B extends {
120
+ properties: infer BP;
121
+ } ? {
122
+ properties: FirestoreFieldsAsProperties<BP>;
123
+ } : unknown);
124
+ } : unknown);
125
+ /**
126
+ * {@link FirestoreFieldAsProperty} over a whole field map.
127
+ * @group Firebase
128
+ */
129
+ export type FirestoreFieldsAsProperties<FS> = {
130
+ -readonly [K in keyof FS]: FirestoreFieldAsProperty<FS[K]>;
131
+ };
132
+ /**
133
+ * The document type a collection's fields describe — what `defineCollection`
134
+ * infers from `properties`, through the same `InferEntityType`. A field with
135
+ * `required: true` (or `validation.required: true`) is a required key; a
136
+ * reference is an `EntityReference`, a date a `Date`, a map its own document.
137
+ *
138
+ * Tolerant of a field map with an error in it: a field that does not
139
+ * normalise to a property widens to any property instead of collapsing the
140
+ * whole type, so the rest of the collection is still checked against the real
141
+ * key set.
142
+ *
143
+ * @group Firebase
144
+ */
145
+ export type FirestoreDocumentOf<FS> = InferEntityType<{
146
+ [K in keyof FirestoreFieldsAsProperties<FS>]: FirestoreFieldsAsProperties<FS>[K] extends Property ? FirestoreFieldsAsProperties<FS>[K] : Property;
147
+ }>;
148
+ /**
149
+ * Turn a collection's fields into the property model the admin and the
150
+ * Firestore driver read: `required` becomes `validation.required`, a
151
+ * reference's `target` becomes its `path`, nested fields are normalised the
152
+ * same way. Every other key is kept as written.
153
+ *
154
+ * @param fields the fields, by key
155
+ * @param where who is asking, for the error messages — the collection's slug
156
+ * @group Firebase
157
+ */
158
+ export declare function normalizeFirestoreFields(fields: FirestoreFields, where: string): FirebaseProperties;
159
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./fields.js";
2
+ export * from "./defineFirestoreCollection.js";
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import { CollectionConfig } from "@rebasepro/types";
3
- import { AnalyticsEvent, AppView, AppViewsBuilder, CollectionConfigsBuilder, RebasePlugin, Locale, PropertyConfig } from "@rebasepro/cms-types";
2
+ import { AnalyticsEvent, AppView, AppViewsBuilder, CollectionConfigsBuilder, RebasePlugin, Locale, PropertyConfig, CollectionConfig } from "@rebasepro/cms-types";
4
3
  import { FirebaseAccessGate } from "../hooks/useFirebaseAccessGate.js";
5
4
  import { FirebaseApp } from "firebase/app";
6
5
  import { FirebaseLoginViewProps } from "./FirebaseLoginView.js";
@@ -3,6 +3,7 @@ export * from "./useFirebaseStorageSource.js";
3
3
  export * from "./useInitialiseFirebase.js";
4
4
  export * from "./useAppCheck.js";
5
5
  export * from "./useFirestoreDriver.js";
6
+ export * from "./useFirestoreDataSource.js";
6
7
  export * from "./useFirebaseRealTimeDBDelegate.js";
7
8
  export * from "./useRecaptcha.js";
8
9
  export * from "./useBuildUserManagement.js";
@@ -1,5 +1,5 @@
1
- import { RebaseData, StorageSource, User } from "@rebasepro/types";
2
- import { AuthController } from "@rebasepro/cms-types";
1
+ import { StorageSource, User } from "@rebasepro/types";
2
+ import { AuthController, RebaseData } from "@rebasepro/cms-types";
3
3
  /**
4
4
  * Client-side gate that decides whether a Firebase-authenticated user
5
5
  * is allowed to access the CMS UI.
@@ -0,0 +1,69 @@
1
+ import type { FirebaseApp } from "firebase/app";
2
+ import type { DataSourceDefinition } from "@rebasepro/types";
3
+ import { FirestoreDataDriver, FirestoreIndexesBuilder } from "./useFirestoreDriver.js";
4
+ import type { FirestoreTextSearchControllerBuilder } from "../types/text_search.js";
5
+ /**
6
+ * Options of {@link useFirestoreDataSource}.
7
+ * @group Firebase
8
+ */
9
+ export interface FirestoreDataSourceOptions {
10
+ /**
11
+ * The data source's key: what a Firestore collection's `dataSource` names.
12
+ * `DEFAULT_DATA_SOURCE_KEY` makes Firestore the default source, as
13
+ * `RebaseFirebaseApp` does.
14
+ */
15
+ key: string;
16
+ /** The initialised Firebase app. The driver reports itself not initialised until it is set. */
17
+ firebaseApp?: FirebaseApp;
18
+ /**
19
+ * The Firestore database this source reads and writes, when it is not the
20
+ * app's default one. A collection's own `databaseId` still wins.
21
+ */
22
+ databaseId?: string;
23
+ /** A label for the source, shown where the admin names data sources. */
24
+ label?: string;
25
+ /**
26
+ * Builds the controller that answers text searches with the ids of the
27
+ * matching documents (Algolia, Typesense, Pinecone, Rebase search…).
28
+ */
29
+ textSearchControllerBuilder?: FirestoreTextSearchControllerBuilder;
30
+ /**
31
+ * Search in the browser over the documents themselves when no controller
32
+ * covers a collection. Reads every document of the collection: fine for a
33
+ * small one, slow and costly for a large one.
34
+ */
35
+ localTextSearchEnabled?: boolean;
36
+ /**
37
+ * The composite indexes the database has, so the admin offers only the
38
+ * filter and sort combinations Firestore can answer.
39
+ */
40
+ firestoreIndexesBuilder?: FirestoreIndexesBuilder;
41
+ }
42
+ /**
43
+ * The `<Rebase dataSources>` entry {@link useFirestoreDataSource} returns: a
44
+ * direct Firestore source and its driver.
45
+ * @group Firebase
46
+ */
47
+ export type FirestoreDataSource = DataSourceDefinition & {
48
+ engine: "firestore";
49
+ transport: "direct";
50
+ driver: FirestoreDataDriver;
51
+ };
52
+ /**
53
+ * A Firestore data source for `<Rebase dataSources={[…]}>`: the browser reads
54
+ * and writes the collections whose `dataSource` is `key` straight from
55
+ * Firestore, beside the Postgres tables the Rebase client serves.
56
+ *
57
+ * The entry is the same object on every render while the options are, so it
58
+ * can be written inline in `dataSources` without rebuilding the data layer.
59
+ * It also registers Firestore's capabilities, so its collections never get
60
+ * relation tabs or filters Firestore cannot run.
61
+ *
62
+ * @example
63
+ * ```tsx
64
+ * const firestoreSource = useFirestoreDataSource({ key: "firestore", firebaseApp });
65
+ * return <Rebase client={rebaseClient} dataSources={[firestoreSource]}>…</Rebase>;
66
+ * ```
67
+ * @group Firebase
68
+ */
69
+ export declare function useFirestoreDataSource({ key, firebaseApp, databaseId, label, textSearchControllerBuilder, localTextSearchEnabled, firestoreIndexesBuilder }: FirestoreDataSourceOptions): FirestoreDataSource;
@@ -1,5 +1,5 @@
1
- import { DataDriver, CollectionConfig, LogicalCondition } from "@rebasepro/types";
2
- import { FilterCombination } from "@rebasepro/cms-types";
1
+ import { DataDriver, LogicalCondition } from "@rebasepro/types";
2
+ import { FilterCombination, CollectionConfig } from "@rebasepro/cms-types";
3
3
  import { Firestore, QueryFilterConstraint } from "firebase/firestore";
4
4
  import { FirebaseApp } from "firebase/app";
5
5
  import { FirestoreTextSearchControllerBuilder } from "../types/text_search.js";
@@ -24,6 +24,22 @@ export interface FirestoreDataDriverProps {
24
24
  * for multiple fields in the CMS.
25
25
  */
26
26
  firestoreIndexesBuilder?: FirestoreIndexesBuilder;
27
+ /**
28
+ * The key of the `<Rebase dataSources>` entry this driver serves — what a
29
+ * collection's `dataSource` names. With it the driver tells a reference to
30
+ * a record of its own Firestore database (written as a
31
+ * `DocumentReference`) from one to a record of another data source
32
+ * (written as the record's id, see {@link rebaseToFirestoreModel}), and
33
+ * stamps it on every reference it reads back. `useFirestoreDataSource`
34
+ * passes its `key`.
35
+ */
36
+ dataSourceKey?: string;
37
+ /**
38
+ * The Firestore database read and written when a call does not name one
39
+ * (a collection's `databaseId` does). Defaults to the app's default
40
+ * database.
41
+ */
42
+ databaseId?: string;
27
43
  }
28
44
  export type FirestoreIndexesBuilder = (params: {
29
45
  path: string;
@@ -92,23 +108,72 @@ export declare function listenToSearchResults({ ids, limit, offset, listenOne, o
92
108
  * one — Firestore has no negation of a conjunction, and `!=` on each leaf
93
109
  * matches a different set of documents.
94
110
  */
95
- export declare function firestoreLogicalCondition(logical: LogicalCondition | undefined, firestore: Firestore): QueryFilterConstraint | undefined;
111
+ export declare function firestoreLogicalCondition(logical: LogicalCondition | undefined, firestore: Firestore, options?: FirestoreModelOptions): QueryFilterConstraint | undefined;
96
112
  /**
97
113
  * Use this hook to build a {@link DataDriver} based on Firestore
98
114
  * @param firebaseApp
99
115
  * @param textSearchControllerBuilder
100
116
  * @group Firebase
101
117
  */
102
- export declare function useFirestoreDriver({ firebaseApp, textSearchControllerBuilder, firestoreIndexesBuilder, localTextSearchEnabled }: FirestoreDataDriverProps): FirestoreDataDriver;
118
+ export declare function useFirestoreDriver({ firebaseApp, textSearchControllerBuilder, firestoreIndexesBuilder, localTextSearchEnabled, dataSourceKey, databaseId: defaultDatabaseId }: FirestoreDataDriverProps): FirestoreDataDriver;
119
+ /**
120
+ * How the model converters treat references, for one data source.
121
+ *
122
+ * @group Firestore
123
+ */
124
+ export interface FirestoreModelOptions {
125
+ /**
126
+ * The key of the data source the converted values belong to — the
127
+ * `<Rebase dataSources>` entry the driver serves.
128
+ *
129
+ * With it, a reference whose `driver` names *another* data source (a
130
+ * Postgres table's record, picked in a Firestore form) is written as the
131
+ * referenced id, and every `DocumentReference` read back carries this key
132
+ * as its `driver`. Without it, every reference is written as a
133
+ * `DocumentReference`, as before the data source was known.
134
+ */
135
+ dataSourceKey?: string;
136
+ }
103
137
  /**
104
138
  * Recursive function that converts Firestore data types into CMS or plain
105
139
  * JS types.
106
140
  * Rebase uses Javascript dates internally instead of Firestore timestamps.
107
141
  * This makes it easier to interact with the rest of the libraries and
108
142
  * bindings.
109
- * Also, Firestore references are replaced with {@link EntityReference}
143
+ *
144
+ * Firestore references are replaced with {@link EntityReference}s carrying
145
+ * the stored path, the Firestore database, and — when `options` names the
146
+ * driver's data source — that key as their `driver`.
147
+ *
148
+ * A reference to a record of another data source is stored as the record's
149
+ * id (see {@link rebaseToFirestoreModel}) and comes back as that id: the
150
+ * document holds no more than that. The admin turns it back into a reference
151
+ * from the field's `target`, which it knows and this function does not.
110
152
  * @param data
153
+ * @param options
154
+ * @group Firestore
155
+ */
156
+ export declare function firestoreToRebaseModel(data: unknown, options?: FirestoreModelOptions): unknown;
157
+ /**
158
+ * Convert values as the admin holds them into what Firestore stores: a
159
+ * `Date` as a `Timestamp`, a `GeoPoint` as Firestore's, a vector as a
160
+ * `VectorValue`, `undefined` as a field deletion.
161
+ *
162
+ * References are stored by where they point:
163
+ *
164
+ * - to a document of this Firestore — a reference with no `driver`, or one
165
+ * naming this data source — as a `DocumentReference`, exactly as before;
166
+ * - to a record of **another** data source (its `driver` names a different
167
+ * key than `options.dataSourceKey`) as the record's id, a plain string. A
168
+ * `DocumentReference` there would point at a document that does not exist,
169
+ * and a query for the record would never match it.
170
+ *
171
+ * @param data the values
172
+ * @param firestore the Firestore the references point into
173
+ * @param options which data source the values belong to; `inArray` is
174
+ * internal (an element of an array cannot hold a field deletion)
111
175
  * @group Firestore
112
176
  */
113
- export declare function firestoreToRebaseModel(data: unknown): unknown;
114
- export declare function rebaseToFirestoreModel(data: unknown, firestore: Firestore, inArray?: boolean): unknown;
177
+ export declare function rebaseToFirestoreModel(data: unknown, firestore: Firestore, options?: FirestoreModelOptions & {
178
+ inArray?: boolean;
179
+ }): unknown;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export * from "./capabilities.js";
2
+ export * from "./collections/index.js";
1
3
  export * from "./hooks/index.js";
2
4
  export * from "./types/index.js";
3
5
  export * from "./utils/index.js";