@data-weave/backend-firestore 0.4.2 → 0.4.3

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.
@@ -0,0 +1,117 @@
1
+ import { WithoutId } from '@data-weave/datamanager';
2
+ import type FirestoreTypes from '@firebase/firestore';
3
+ import type { FieldPath, WithFieldValue as FirestoreWithFieldValue, QueryConstraint } from '@firebase/firestore';
4
+ import type { HttpsCallable, HttpsCallableOptions } from '@firebase/functions-types';
5
+ import { FieldValue, Transaction } from '@google-cloud/firestore';
6
+ export type DocumentData = FirestoreTypes.DocumentData;
7
+ export { FieldValue, FirestoreTypes, Transaction };
8
+ /**
9
+ * Same as Partial but all fields are required to be included
10
+ */
11
+ type OptionallyUndefined<T> = {
12
+ [P in keyof T]: T[P] | undefined;
13
+ };
14
+ export declare interface InternalFirestoreDataConverter<T extends DocumentData, SerializedT extends DocumentData = DocumentData> {
15
+ toFirestore(modelObject: Partial<WithFieldValue<WithoutId<T>>>, options?: FirestoreTypes.SetOptions): WithFieldValue<WithoutId<SerializedT>>;
16
+ fromFirestore(snapshot: FirestoreTypes.QueryDocumentSnapshot<T, SerializedT>, options?: FirestoreTypes.SnapshotOptions): T;
17
+ }
18
+ export type WithTimestamps<T> = {
19
+ [K in keyof T]: T[K] extends Date ? FirestoreTypes.Timestamp : T[K] extends Date | null ? FirestoreTypes.Timestamp | null : T[K] extends Date | undefined ? FirestoreTypes.Timestamp | undefined : T[K] extends Date | null | undefined ? FirestoreTypes.Timestamp | null | undefined : T[K] extends object ? T[K] extends any[] ? T[K] extends (infer U)[] ? WithTimestamps<U>[] : T[K] : WithTimestamps<T[K]> : T[K];
20
+ };
21
+ /**
22
+ * Converts data between model and serialized data. Differs from InternalFirestoreDataConverter
23
+ * by using `OptionallyUndefined` and `Required` to ensure that all fields are included in de/serialization
24
+ * even if some model defined properties are optional.
25
+ */
26
+ export declare interface FirestoreDataConverter<ModelObject, SerializedModelObject = ModelObject> {
27
+ toFirestore(modelObject: WithoutId<ModelObject>, options?: FirestoreTypes.SetOptions): OptionallyUndefined<Required<WithoutId<WithFieldValue<SerializedModelObject>>>>;
28
+ fromFirestore(snapshot: FirestoreTypes.QueryDocumentSnapshot<WithTimestamps<SerializedModelObject>>, options?: FirestoreTypes.SnapshotOptions): ModelObject;
29
+ }
30
+ export type FirestoreQuery<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData> = (reference: FirestoreTypes.Query<AppModelType, DbModelType>, filter: any) => FirestoreTypes.Query<AppModelType, DbModelType>;
31
+ export type FirestoreWhere = (field: string | FieldPath, op: string, value: unknown) => any;
32
+ export type FirestoreReadMode = 'realtime' | 'static';
33
+ export interface FirestoreReadOptions {
34
+ readonly transaction?: FirestoreTypes.Transaction;
35
+ }
36
+ export interface FirestoreWriteOptions {
37
+ readonly transaction?: FirestoreTypes.Transaction;
38
+ readonly batcher?: FirestoreTypes.WriteBatch;
39
+ }
40
+ export interface FirebaseCreateOptions extends FirestoreWriteOptions {
41
+ id?: string;
42
+ merge?: boolean;
43
+ }
44
+ export declare type WithFieldValue<T> = {
45
+ [K in keyof T]: FirestoreWithFieldValue<T[K]> | FirestoreTypes.FieldValue;
46
+ };
47
+ type GenNode<K extends string, IsRoot extends boolean> = IsRoot extends true ? `${K}` : `.${K}`;
48
+ export type FilterableFields<T extends object, IsRoot extends boolean = true, K extends keyof T = keyof T> = K extends string ? T[K] extends FirestoreTypes.Timestamp ? `${K}` : T[K] extends Date ? `${K}` : T[K] extends any[] ? GenNode<K, IsRoot> : T[K] extends object ? `${GenNode<K, IsRoot>}${FilterableFields<T[K], false>}` : GenNode<K, IsRoot> : never;
49
+ type GetValue<T, K extends string> = K extends `${infer L}.${infer R}` ? L extends keyof T ? GetValue<T[L], R> : never : K extends keyof T ? T[K] extends Date ? Date | FirestoreTypes.Timestamp : T[K] : K extends string ? string | number | boolean : never;
50
+ export type PrimitiveFilterOp = '<' | '<=' | '==' | '!=' | '>=' | '>';
51
+ export type FilterBy<T extends object, Field extends string = FilterableFields<T>> = Field extends string ? GetValue<T, Field> extends any[] ? [Field, 'array-contains', string] | [Field, 'array-contains-any', string[]] : [Field, PrimitiveFilterOp, GetValue<T, Field>] | [Field, 'in', string[]] : never;
52
+ export type OrderBy<T extends DocumentData, Fields extends string = FilterableFields<T>> = [
53
+ Fields,
54
+ FirestoreTypes.OrderByDirection
55
+ ];
56
+ export declare abstract class FieldValues {
57
+ abstract serverTimestamp(): FirestoreTypes.FieldValue;
58
+ abstract delete(): FirestoreTypes.FieldValue;
59
+ abstract increment(n: number): FirestoreTypes.FieldValue;
60
+ abstract arrayUnion(...elements: any[]): FirestoreTypes.FieldValue;
61
+ abstract arrayRemove(...elements: any[]): FirestoreTypes.FieldValue;
62
+ }
63
+ /**********
64
+ *
65
+ *
66
+ * INJECTABLES
67
+ *
68
+ *
69
+ * **********/
70
+ export interface FirestoreAppSettings {
71
+ persistence?: boolean;
72
+ cacheSizeBytes?: number;
73
+ host?: string;
74
+ ssl?: boolean;
75
+ ignoreUndefinedProperties?: boolean;
76
+ serverTimestampBehavior?: 'estimate' | 'previous' | 'none';
77
+ }
78
+ export declare abstract class FirestoreApp {
79
+ abstract type?: string;
80
+ abstract toJSON?(): object;
81
+ abstract terminate?(): Promise<void>;
82
+ abstract settings?(settings: FirestoreAppSettings): void;
83
+ abstract useEmulator?(host: string, port: number): void;
84
+ abstract runTransaction?<T>(updateFunction: (transaction: Transaction) => Promise<T>, options?: FirestoreTypes.TransactionOptions): Promise<T>;
85
+ }
86
+ export declare abstract class Firestore {
87
+ abstract app: FirestoreApp;
88
+ abstract collection(reference: FirestoreTypes.CollectionReference | FirestoreApp, path: string): any;
89
+ abstract getDocs<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>(reference: FirestoreTypes.Query<AppModelType, DbModelType>): Promise<FirestoreTypes.QuerySnapshot<AppModelType, DbModelType>>;
90
+ abstract getDoc<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>(reference: FirestoreTypes.DocumentReference<AppModelType, DbModelType>, path?: string): Promise<FirestoreTypes.DocumentSnapshot<AppModelType, DbModelType>>;
91
+ abstract serverTimestamp(): FirestoreTypes.FieldValue;
92
+ abstract increment(n: number): FirestoreTypes.FieldValue;
93
+ abstract query<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>(reference: FirestoreTypes.Query<AppModelType, DbModelType>, filter: any): FirestoreTypes.Query<AppModelType, DbModelType>;
94
+ abstract where(field: string | FieldPath, op: string, value: unknown): QueryConstraint;
95
+ abstract limit(limit: number): any;
96
+ abstract orderBy(orderBy: string, direction: FirestoreTypes.OrderByDirection): any;
97
+ abstract setDoc<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>(reference: FirestoreTypes.DocumentReference<AppModelType, DbModelType>, data: any, options?: FirestoreTypes.SetOptions): Promise<void>;
98
+ abstract updateDoc<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>(reference: FirestoreTypes.DocumentReference<AppModelType, DbModelType>, data: any): Promise<void>;
99
+ abstract doc<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>(reference: FirestoreTypes.Query<AppModelType, DbModelType>, path?: string): FirestoreTypes.DocumentReference<AppModelType, DbModelType>;
100
+ abstract deleteDoc<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>(reference: FirestoreTypes.DocumentReference<AppModelType, DbModelType>): Promise<void>;
101
+ abstract onSnapshot<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>(reference: FirestoreTypes.DocumentReference<AppModelType, DbModelType>, onNext: (snapshot: FirestoreTypes.DocumentSnapshot<AppModelType, DbModelType>) => void, onError?: (error: Error) => void): () => void;
102
+ abstract onSnapshot<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>(reference: FirestoreTypes.Query<AppModelType, DbModelType>, onNext: (snapshot: FirestoreTypes.QuerySnapshot<AppModelType, DbModelType>) => void, onError?: (error: Error) => void): () => void;
103
+ abstract runTransaction<T>(firestore: FirestoreApp, transaction: (transaction: Transaction) => Promise<T>, options?: FirestoreTypes.TransactionOptions): Promise<T>;
104
+ }
105
+ export declare abstract class FirestoreSettings {
106
+ abstract readMode: FirestoreReadMode;
107
+ }
108
+ export declare abstract class FirestoreFunctions {
109
+ abstract httpsCallable(name: string, options?: HttpsCallableOptions): HttpsCallable;
110
+ abstract useEmulator(host: string, port: number): void;
111
+ abstract useFunctionsEmulator(origin: string): void;
112
+ }
113
+ export declare class DummyFirestoreFunctions implements FirestoreFunctions {
114
+ httpsCallable(): HttpsCallable;
115
+ useEmulator(): void;
116
+ useFunctionsEmulator(): void;
117
+ }
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.DummyFirestoreFunctions = exports.FirestoreFunctions = exports.FirestoreSettings = exports.Firestore = exports.FirestoreApp = exports.FieldValues = exports.Transaction = exports.FieldValue = void 0;
42
+ const firestore_1 = require("@google-cloud/firestore");
43
+ Object.defineProperty(exports, "FieldValue", { enumerable: true, get: function () { return firestore_1.FieldValue; } });
44
+ Object.defineProperty(exports, "Transaction", { enumerable: true, get: function () { return firestore_1.Transaction; } });
45
+ const inversify_1 = require("inversify");
46
+ class FieldValues {
47
+ }
48
+ exports.FieldValues = FieldValues;
49
+ class FirestoreApp {
50
+ }
51
+ exports.FirestoreApp = FirestoreApp;
52
+ let Firestore = (() => {
53
+ let _classDecorators = [(0, inversify_1.injectable)()];
54
+ let _classDescriptor;
55
+ let _classExtraInitializers = [];
56
+ let _classThis;
57
+ var Firestore = _classThis = class {
58
+ };
59
+ __setFunctionName(_classThis, "Firestore");
60
+ (() => {
61
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
62
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
63
+ Firestore = _classThis = _classDescriptor.value;
64
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
65
+ __runInitializers(_classThis, _classExtraInitializers);
66
+ })();
67
+ return Firestore = _classThis;
68
+ })();
69
+ exports.Firestore = Firestore;
70
+ let FirestoreSettings = (() => {
71
+ let _classDecorators = [(0, inversify_1.injectable)()];
72
+ let _classDescriptor;
73
+ let _classExtraInitializers = [];
74
+ let _classThis;
75
+ var FirestoreSettings = _classThis = class {
76
+ };
77
+ __setFunctionName(_classThis, "FirestoreSettings");
78
+ (() => {
79
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
80
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
81
+ FirestoreSettings = _classThis = _classDescriptor.value;
82
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
83
+ __runInitializers(_classThis, _classExtraInitializers);
84
+ })();
85
+ return FirestoreSettings = _classThis;
86
+ })();
87
+ exports.FirestoreSettings = FirestoreSettings;
88
+ let FirestoreFunctions = (() => {
89
+ let _classDecorators = [(0, inversify_1.injectable)()];
90
+ let _classDescriptor;
91
+ let _classExtraInitializers = [];
92
+ let _classThis;
93
+ var FirestoreFunctions = _classThis = class {
94
+ };
95
+ __setFunctionName(_classThis, "FirestoreFunctions");
96
+ (() => {
97
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
98
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
99
+ FirestoreFunctions = _classThis = _classDescriptor.value;
100
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
101
+ __runInitializers(_classThis, _classExtraInitializers);
102
+ })();
103
+ return FirestoreFunctions = _classThis;
104
+ })();
105
+ exports.FirestoreFunctions = FirestoreFunctions;
106
+ let DummyFirestoreFunctions = (() => {
107
+ let _classDecorators = [(0, inversify_1.injectable)()];
108
+ let _classDescriptor;
109
+ let _classExtraInitializers = [];
110
+ let _classThis;
111
+ var DummyFirestoreFunctions = _classThis = class {
112
+ httpsCallable() {
113
+ return () => {
114
+ throw new Error('httpsCallable not implemented - DummyFirestoreFunctions');
115
+ };
116
+ }
117
+ useEmulator() { }
118
+ useFunctionsEmulator() { }
119
+ };
120
+ __setFunctionName(_classThis, "DummyFirestoreFunctions");
121
+ (() => {
122
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
123
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
124
+ DummyFirestoreFunctions = _classThis = _classDescriptor.value;
125
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
126
+ __runInitializers(_classThis, _classExtraInitializers);
127
+ })();
128
+ return DummyFirestoreFunctions = _classThis;
129
+ })();
130
+ exports.DummyFirestoreFunctions = DummyFirestoreFunctions;
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './FirestoreDataManager';
2
+ export * from './FirestoreList';
3
+ export * from './FirestoreMetadata';
4
+ export * from './FirestoreReference';
5
+ export * from './firestoreTypes';
6
+ export * from './utils';
package/lib/index.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./FirestoreDataManager"), exports);
18
+ __exportStar(require("./FirestoreList"), exports);
19
+ __exportStar(require("./FirestoreMetadata"), exports);
20
+ __exportStar(require("./FirestoreReference"), exports);
21
+ __exportStar(require("./firestoreTypes"), exports);
22
+ __exportStar(require("./utils"), exports);
package/lib/utils.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { WithoutId } from '@data-weave/datamanager';
2
+ import { DocumentData, Firestore, FirestoreTypes, InternalFirestoreDataConverter, Transaction, WithFieldValue } from './firestoreTypes';
3
+ import { Firestore as FirebaseFirestore } from 'firebase/firestore';
4
+ export declare class MergeConverters<T extends DocumentData, SerializedT extends DocumentData, G extends DocumentData, SerializedG extends DocumentData> implements InternalFirestoreDataConverter<T & G, SerializedT & SerializedG> {
5
+ private converter1;
6
+ private converter2;
7
+ constructor(converter1: InternalFirestoreDataConverter<T, SerializedT>, converter2: InternalFirestoreDataConverter<G, SerializedG>);
8
+ toFirestore(modelObject: WithoutId<Partial<WithFieldValue<T>>> & WithoutId<Partial<WithFieldValue<G>>>, options?: FirestoreTypes.SetOptions): WithFieldValue<WithoutId<SerializedT>> & WithFieldValue<WithoutId<SerializedG>>;
9
+ fromFirestore(snapshot: FirestoreTypes.QueryDocumentSnapshot<T & G, SerializedT & SerializedG>, options: FirestoreTypes.SnapshotOptions): T & G;
10
+ }
11
+ export declare function createModularFirestoreAdapter(firestore: FirebaseFirestore): Firestore;
12
+ export declare const isFieldValue: (value: any) => value is FirestoreTypes.FieldValue;
13
+ export declare const checkIfReferenceExists: (value: any) => boolean;
14
+ export declare const withTransaction: (firestore: Firestore, transaction: (transaction: Transaction) => Promise<void>, options?: FirestoreTypes.TransactionOptions) => Promise<void>;
package/lib/utils.js ADDED
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withTransaction = exports.checkIfReferenceExists = exports.isFieldValue = exports.MergeConverters = void 0;
4
+ exports.createModularFirestoreAdapter = createModularFirestoreAdapter;
5
+ const firestore_1 = require("firebase/firestore");
6
+ class MergeConverters {
7
+ constructor(converter1, converter2) {
8
+ this.converter1 = converter1;
9
+ this.converter2 = converter2;
10
+ }
11
+ toFirestore(modelObject, options) {
12
+ if (options) {
13
+ return Object.assign(Object.assign({}, this.converter1.toFirestore(modelObject, options)), this.converter2.toFirestore(modelObject, options));
14
+ }
15
+ else {
16
+ return Object.assign(Object.assign({}, this.converter1.toFirestore(modelObject)), this.converter2.toFirestore(modelObject));
17
+ }
18
+ }
19
+ fromFirestore(snapshot, options) {
20
+ return Object.assign(Object.assign({}, this.converter1.fromFirestore(snapshot, options)), this.converter2.fromFirestore(snapshot, options));
21
+ }
22
+ }
23
+ exports.MergeConverters = MergeConverters;
24
+ function createModularFirestoreAdapter(firestore) {
25
+ return {
26
+ app: firestore,
27
+ collection: firestore_1.collection,
28
+ getDocs: firestore_1.getDocs,
29
+ getDoc: firestore_1.getDoc,
30
+ serverTimestamp: firestore_1.serverTimestamp,
31
+ query: firestore_1.query,
32
+ where: firestore_1.where,
33
+ limit: firestore_1.limit,
34
+ orderBy: firestore_1.orderBy,
35
+ setDoc: firestore_1.setDoc,
36
+ updateDoc: firestore_1.updateDoc,
37
+ deleteDoc: firestore_1.deleteDoc,
38
+ doc: firestore_1.doc,
39
+ onSnapshot: firestore_1.onSnapshot,
40
+ increment: firestore_1.increment,
41
+ // TODO: fix this
42
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
+ runTransaction: firestore_1.runTransaction,
44
+ };
45
+ }
46
+ // Value can be anything
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ const isFieldValue = (value) => {
49
+ return value !== undefined && typeof value._toFieldTransform === 'function';
50
+ };
51
+ exports.isFieldValue = isFieldValue;
52
+ // Modular firestore uses exists, namespaced uses exists()
53
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
+ const checkIfReferenceExists = (value) => {
55
+ if (value == null)
56
+ return false;
57
+ if (typeof value.exists === 'function')
58
+ return value.exists();
59
+ return value.exists;
60
+ };
61
+ exports.checkIfReferenceExists = checkIfReferenceExists;
62
+ const withTransaction = (firestore, transaction, options) => {
63
+ return firestore.runTransaction(firestore.app, transaction, options);
64
+ };
65
+ exports.withTransaction = withTransaction;
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- module.exports = '0.4.2';
2
+ module.exports = '0.4.3';
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "@data-weave/backend-firestore",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "author": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
7
+ "files": [
8
+ "lib/**/*.js",
9
+ "lib/**/*.d.ts"
10
+ ],
7
11
  "scripts": {
8
- "build": "genversion --semi lib/version.js",
12
+ "build": "genversion --semi lib/version.js && cp -r ../../build/backend-firestore/lib/*.js lib/ && cp -r ../../build/types/backend-firestore/lib/*.d.ts lib/",
9
13
  "build:clean": "rimraf android/build && rimraf ios/build",
10
14
  "prepare": "npm run build"
11
15
  },
@@ -18,8 +22,8 @@
18
22
  "registry": "https://registry.npmjs.org/"
19
23
  },
20
24
  "peerDependencies": {
21
- "@data-weave/datamanager": "0.4.1",
25
+ "@data-weave/datamanager": "0.4.2",
22
26
  "firebase": ">=11.0.0"
23
27
  },
24
- "gitHead": "1dcdcb73b691bdeaa60f9a7dd3ada171fde24f32"
28
+ "gitHead": "5dd7dfd873ebb8a0b8a11870fac08f41d9548aa7"
25
29
  }
package/CHANGELOG.md DELETED
@@ -1,78 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [0.4.2](https://github.com/data-weave/datamanager/compare/v0.4.1...v0.4.2) (2025-10-15)
7
-
8
- **Note:** Version bump only for package @data-weave/backend-firestore
9
-
10
- ## [0.4.1](https://github.com/data-weave/datamanager/compare/v0.4.0...v0.4.1) (2025-10-15)
11
-
12
- **Note:** Version bump only for package @data-weave/backend-firestore
13
-
14
- ## [0.4.0](https://github.com/data-weave/datamanager/compare/v0.3.8...v0.4.0) (2025-10-15)
15
-
16
- ### Features
17
-
18
- - add error interceptor ([dde95c8](https://github.com/data-weave/datamanager/commit/dde95c8dba3d02d7861d132314db4d1cf23bec37))
19
- - add new typing, snapshot options and sane type defaults ([7095568](https://github.com/data-weave/datamanager/commit/7095568892048dc75cccc284e2dd2ba23793a152))
20
- - create shim for modular firebase as well ([591b25a](https://github.com/data-weave/datamanager/commit/591b25a8cbcf89687b3880cc3ca1cd95a735e11d))
21
- - move firebase-admin shim to it's own package ([ac9f861](https://github.com/data-weave/datamanager/commit/ac9f861ca810a2a14706e10e87674b1b1f14a964))
22
-
23
- ## [0.3.8](https://github.com/data-weave/datamanager/compare/v0.3.7...v0.3.8) (2025-09-28)
24
-
25
- **Note:** Version bump only for package @data-weave/backend-firestore
26
-
27
- ## [0.3.7](https://github.com/data-weave/datamanager/compare/v0.3.6...v0.3.7) (2025-09-28)
28
-
29
- **Note:** Version bump only for package @data-weave/backend-firestore
30
-
31
- ## [0.3.6](https://github.com/data-weave/datamanager/compare/v0.3.5...v0.3.6) (2025-09-28)
32
-
33
- **Note:** Version bump only for package @data-weave/backend-firestore
34
-
35
- ## [0.3.5](https://github.com/data-weave/datamanager/compare/v0.3.4...v0.3.5) (2025-09-28)
36
-
37
- **Note:** Version bump only for package @data-weave/backend-firestore
38
-
39
- ## [0.3.4](https://github.com/data-weave/datamanager/compare/v0.3.3...v0.3.4) (2025-09-28)
40
-
41
- **Note:** Version bump only for package @data-weave/backend-firestore
42
-
43
- ## [0.3.3](https://github.com/data-weave/datamanager/compare/v0.3.2...v0.3.3) (2025-09-28)
44
-
45
- **Note:** Version bump only for package @data-weave/backend-firestore
46
-
47
- ## [0.3.2](https://github.com/data-weave/datamanager/compare/v0.3.1...v0.3.2) (2025-09-28)
48
-
49
- **Note:** Version bump only for package @data-weave/backend-firestore
50
-
51
- ## [0.3.1](https://github.com/data-weave/datamanager/compare/v0.3.0...v0.3.1) (2025-09-28)
52
-
53
- **Note:** Version bump only for package @data-weave/backend-firestore
54
-
55
- ## 0.3.0 (2025-09-28)
56
-
57
- ### Features
58
-
59
- - add code quality workflow and circular dep check ([9c7b7e3](https://github.com/data-weave/datamanager/commit/9c7b7e34501dfc95ddc2bcff686f55db06d9b1b8))
60
- - add transactions support ([59db0ff](https://github.com/data-weave/datamanager/commit/59db0ffce889e040828779bd2d03efe5ac088e78))
61
- - project re-organization ([4a00af3](https://github.com/data-weave/datamanager/commit/4a00af36c4c2f6e49287542e0d5ad85acaa50cda))
62
-
63
- ### Bug Fixes
64
-
65
- - adjust config and lib versions ([9c7e2c9](https://github.com/data-weave/datamanager/commit/9c7e2c9072ea34b1e54326c2612b43c92ec2da4e))
66
- - adjust tests for firestore realtime snapshots ([539f314](https://github.com/data-weave/datamanager/commit/539f31448f68b084dc4e429663fe71e69c98760e))
67
- - implement Cache prop & clean up some of anys ([955b11a](https://github.com/data-weave/datamanager/commit/955b11a6ab05224f843db834ad28796602679fac))
68
-
69
- ### Reverts
70
-
71
- - revert incorrect name change ([191e64e](https://github.com/data-weave/datamanager/commit/191e64e1123bdbc3555ff7830a532761157fd8ac))
72
-
73
- ### Code Refactoring
74
-
75
- - abstract out firestoreReference into LiveReference ([7848a87](https://github.com/data-weave/datamanager/commit/7848a872155593e5acab56696d4d9f27f0e6abb2))
76
- - abstract out LiveList function from FirestorList ([bb4278e](https://github.com/data-weave/datamanager/commit/bb4278e960d0080d1fb18d847036acb189782ec9))
77
- - adjustments for LiveList & ListReference ([49cd540](https://github.com/data-weave/datamanager/commit/49cd540295693e40bbb9eb75b5101b45c6932921))
78
- - include namepspace in DataManager name ([9c0a171](https://github.com/data-weave/datamanager/commit/9c0a1712d8de3cef0d2e1f8022044d0ca3628ae6))