@donotdev/firebase 0.0.1
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/LICENSE.md +242 -0
- package/README.md +386 -0
- package/dist/client/firestore.d.ts +147 -0
- package/dist/client/firestore.d.ts.map +1 -0
- package/dist/client/firestore.js +1 -0
- package/dist/client/functions.d.ts +28 -0
- package/dist/client/functions.d.ts.map +1 -0
- package/dist/client/functions.js +1 -0
- package/dist/client/index.d.ts +11 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +1 -0
- package/dist/client/sdk.d.ts +968 -0
- package/dist/client/sdk.d.ts.map +1 -0
- package/dist/client/sdk.js +21 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/server/batch.d.ts +97 -0
- package/dist/server/batch.d.ts.map +1 -0
- package/dist/server/batch.js +1 -0
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/init.d.ts +13 -0
- package/dist/server/init.d.ts.map +1 -0
- package/dist/server/init.js +2 -0
- package/dist/server/subscription.d.ts +117 -0
- package/dist/server/subscription.d.ts.map +1 -0
- package/dist/server/subscription.js +1 -0
- package/dist/server/uniqueness.d.ts +69 -0
- package/dist/server/uniqueness.d.ts.map +1 -0
- package/dist/server/uniqueness.js +1 -0
- package/dist/server/utils.d.ts +28 -0
- package/dist/server/utils.d.ts.map +1 -0
- package/dist/server/utils.js +1 -0
- package/dist/server/validation.d.ts +43 -0
- package/dist/server/validation.d.ts.map +1 -0
- package/dist/server/validation.js +1 -0
- package/dist/shared/index.d.ts +11 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +1 -0
- package/dist/shared/transform.d.ts +96 -0
- package/dist/shared/transform.d.ts.map +1 -0
- package/dist/shared/transform.js +1 -0
- package/dist/shared/types.d.ts +37 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +0 -0
- package/dist/shared/utils.d.ts +71 -0
- package/dist/shared/utils.d.ts.map +1 -0
- package/dist/shared/utils.js +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Firestore Client SDK Exports
|
|
3
|
+
* @description Re-exports all Firestore client functions with framework integration. Provides direct access to Firestore client SDK functions while maintaining the framework's separation between client-safe and server-only operations. All functions are browser-safe and can be used in client-side applications. Features direct Firestore SDK access, framework data transformation utilities integration, type-safe operations with proper error handling, real-time subscriptions support, and query building and filtering capabilities.
|
|
4
|
+
* @version 0.0.1
|
|
5
|
+
* @since 0.0.1
|
|
6
|
+
* @author AMBROISE PARK Consulting
|
|
7
|
+
*/
|
|
8
|
+
import { type Firestore } from 'firebase/firestore';
|
|
9
|
+
/**
|
|
10
|
+
* Get Firestore instance with automatic emulator connection
|
|
11
|
+
*
|
|
12
|
+
* Ensures Firebase app is initialized and returns Firestore instance.
|
|
13
|
+
* Handles emulator connection automatically in development.
|
|
14
|
+
* Safe to call from any consumer - handles initialization order automatically.
|
|
15
|
+
*
|
|
16
|
+
* @returns Promise resolving to Firestore instance
|
|
17
|
+
* @throws Error if initialization fails
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const firestore = await getFirebaseFirestore();
|
|
22
|
+
* const docRef = doc(firestore, 'users', 'user123');
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @version 0.0.1
|
|
26
|
+
* @since 0.0.1
|
|
27
|
+
* @author AMBROISE PARK Consulting
|
|
28
|
+
*/
|
|
29
|
+
export declare function getFirebaseFirestore(): Promise<Firestore>;
|
|
30
|
+
export { getFirestore } from 'firebase/firestore';
|
|
31
|
+
/**
|
|
32
|
+
* Document reference operations
|
|
33
|
+
*/
|
|
34
|
+
export { doc, getDoc, getDocs, setDoc, updateDoc, deleteDoc, addDoc, } from 'firebase/firestore';
|
|
35
|
+
/**
|
|
36
|
+
* Collection operations
|
|
37
|
+
*/
|
|
38
|
+
export { collection, collectionGroup } from 'firebase/firestore';
|
|
39
|
+
/**
|
|
40
|
+
* Query operations
|
|
41
|
+
*/
|
|
42
|
+
export { query, where, orderBy, limit, limitToLast, startAt, startAfter, endAt, endBefore, } from 'firebase/firestore';
|
|
43
|
+
/**
|
|
44
|
+
* Real-time subscriptions
|
|
45
|
+
*/
|
|
46
|
+
export { onSnapshot, onSnapshotsInSync } from 'firebase/firestore';
|
|
47
|
+
/**
|
|
48
|
+
* Batch operations
|
|
49
|
+
*/
|
|
50
|
+
export { writeBatch, runTransaction } from 'firebase/firestore';
|
|
51
|
+
/**
|
|
52
|
+
* Server timestamp
|
|
53
|
+
*/
|
|
54
|
+
export { serverTimestamp, increment, arrayUnion, arrayRemove, } from 'firebase/firestore';
|
|
55
|
+
/**
|
|
56
|
+
* Field value operations
|
|
57
|
+
* Note: Timestamp type is defined in @donotdev/core, this exports the Firebase SDK Timestamp class
|
|
58
|
+
*/
|
|
59
|
+
export { FieldValue, GeoPoint } from 'firebase/firestore';
|
|
60
|
+
export { Timestamp as FirestoreTimestampClass } from 'firebase/firestore';
|
|
61
|
+
/**
|
|
62
|
+
* Transform Firestore data to application format
|
|
63
|
+
* Converts Firestore Timestamps to ISO strings and handles other type conversions
|
|
64
|
+
*
|
|
65
|
+
* @param data - Raw Firestore document data
|
|
66
|
+
* @returns Transformed data ready for application use
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const snapshot = await getDoc(docRef);
|
|
71
|
+
* const appData = transformFirestoreData(snapshot.data());
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export { transformFirestoreData } from '../shared/transform';
|
|
75
|
+
/**
|
|
76
|
+
* Convert ISO date strings to Date objects for schema validation
|
|
77
|
+
* Schema validation expects Date objects for timestamp fields, not ISO strings.
|
|
78
|
+
* This function recursively converts ISO date strings back to Date objects.
|
|
79
|
+
*
|
|
80
|
+
* @param data - Data containing ISO date strings
|
|
81
|
+
* @returns Data with ISO strings converted to Date objects
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const data = { createdAt: '2025-12-27T23:13:00.727Z' };
|
|
86
|
+
* const converted = convertISOStringsToDates(data);
|
|
87
|
+
* // { createdAt: Date('2025-12-27T23:13:00.727Z') }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export { convertISOStringsToDates } from '../shared/transform';
|
|
91
|
+
/**
|
|
92
|
+
* Prepare application data for Firestore storage
|
|
93
|
+
* Converts ISO strings to Firestore Timestamps and handles other type conversions
|
|
94
|
+
*
|
|
95
|
+
* @param data - Application data to store
|
|
96
|
+
* @returns Data formatted for Firestore storage
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const firestoreData = prepareForFirestore(userData);
|
|
101
|
+
* await setDoc(docRef, firestoreData);
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export { prepareForFirestore } from '../shared/transform';
|
|
105
|
+
/**
|
|
106
|
+
* Convert Date or ISO string to Firestore Timestamp
|
|
107
|
+
*
|
|
108
|
+
* @param date - Date object or ISO string
|
|
109
|
+
* @returns Firestore Timestamp
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const timestamp = toTimestamp(new Date());
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export { toTimestamp } from '../shared/transform';
|
|
117
|
+
/**
|
|
118
|
+
* Convert DateValue to ISO string
|
|
119
|
+
* Note: For generic Date conversion, use toISOString from @donotdev/core
|
|
120
|
+
*
|
|
121
|
+
* @param dateValue - Date, Timestamp, or ISO string
|
|
122
|
+
* @returns ISO string representation
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* const isoString = firestoreToISOString(timestamp);
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export { firestoreToISOString } from '../shared/transform';
|
|
130
|
+
/**
|
|
131
|
+
* Create partial update object for Firestore
|
|
132
|
+
*
|
|
133
|
+
* @param updates - Partial data updates
|
|
134
|
+
* @returns Firestore-compatible update object
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* const updates = createFirestorePartialUpdate({ name: 'New Name' });
|
|
139
|
+
* await updateDoc(docRef, updates);
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
export { createFirestorePartialUpdate } from '../shared/transform';
|
|
143
|
+
/**
|
|
144
|
+
* Firestore types for TypeScript integration
|
|
145
|
+
*/
|
|
146
|
+
export type { DocumentData, DocumentSnapshot, QuerySnapshot, QueryDocumentSnapshot, DocumentReference, CollectionReference, Query, QueryConstraint, WhereFilterOp, OrderByDirection, FirestoreError, Unsubscribe, SnapshotOptions, DocumentChange, DocumentChangeType, Timestamp as FirestoreTimestamp, GeoPoint as FirestoreGeoPoint, FieldValue as FirestoreFieldValue, } from 'firebase/firestore';
|
|
147
|
+
//# sourceMappingURL=firestore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firestore.d.ts","sourceRoot":"","sources":["../../src/client/firestore.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,oBAAoB,CAAC;AAa5B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,SAAS,CAAC,CAqB/D;AAOD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;GAEG;AACH,OAAO,EACL,GAAG,EACH,MAAM,EACN,OAAO,EACP,MAAM,EACN,SAAS,EACT,SAAS,EACT,MAAM,GACP,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAA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AClB,SAAS,IAAI,kBAAkB,EAC/B,QAAQ,IAAI,iBAAiB,EAC7B,UAAU,IAAI,mBAAmB,GAClC,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getFirestore as m,connectFirestoreEmulator as p}from"firebase/firestore";import{getPlatformEnvVar as r}from"@donotdev/core";import{getFirebaseSDK as c}from"./sdk";let e=null,t=!1;async function F(){if(e)return e;const o=await c().getApp();e=m(o);const s=r("NODE_ENV")==="development",a=r("USE_FIREBASE_EMULATOR")==="true";if(s&&a&&!t){const n=r("FIREBASE_EMULATOR_HOST")||"localhost",i=parseInt(r("FIREBASE_FIRESTORE_EMULATOR_PORT")||"8080");p(e,n,i),t=!0}return e}import{getFirestore as S}from"firebase/firestore";import{doc as D,getDoc as g,getDocs as A,setDoc as R,updateDoc as I,deleteDoc as O,addDoc as _}from"firebase/firestore";import{collection as v,collectionGroup as y}from"firebase/firestore";import{query as U,where as L,orderBy as P,limit as w,limitToLast as M,startAt as V,startAfter as b,endAt as k,endBefore as C}from"firebase/firestore";import{onSnapshot as N,onSnapshotsInSync as q}from"firebase/firestore";import{writeBatch as K,runTransaction as j}from"firebase/firestore";import{serverTimestamp as J,increment as Q,arrayUnion as W,arrayRemove as X}from"firebase/firestore";import{FieldValue as Z,GeoPoint as $}from"firebase/firestore";import{Timestamp as re}from"firebase/firestore";import{transformFirestoreData as oe}from"../shared/transform";import{convertISOStringsToDates as ae}from"../shared/transform";import{prepareForFirestore as ie}from"../shared/transform";import{toTimestamp as pe}from"../shared/transform";import{firestoreToISOString as fe}from"../shared/transform";import{createFirestorePartialUpdate as Ee}from"../shared/transform";export{Z as FieldValue,re as FirestoreTimestampClass,$ as GeoPoint,_ as addDoc,X as arrayRemove,W as arrayUnion,v as collection,y as collectionGroup,ae as convertISOStringsToDates,Ee as createFirestorePartialUpdate,O as deleteDoc,D as doc,k as endAt,C as endBefore,fe as firestoreToISOString,g as getDoc,A as getDocs,F as getFirebaseFirestore,S as getFirestore,Q as increment,w as limit,M as limitToLast,N as onSnapshot,q as onSnapshotsInSync,P as orderBy,ie as prepareForFirestore,U as query,j as runTransaction,J as serverTimestamp,R as setDoc,b as startAfter,V as startAt,pe as toTimestamp,oe as transformFirestoreData,I as updateDoc,L as where,K as writeBatch};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Firebase Functions Client SDK
|
|
3
|
+
* @description Framework-integrated Firebase Functions client utilities. Provides singleton access to Firebase Functions with automatic app initialization and emulator support.
|
|
4
|
+
* @version 0.0.1
|
|
5
|
+
* @since 0.0.1
|
|
6
|
+
* @author AMBROISE PARK Consulting
|
|
7
|
+
*/
|
|
8
|
+
import { type Functions } from 'firebase/functions';
|
|
9
|
+
/**
|
|
10
|
+
* Get Firebase Functions instance
|
|
11
|
+
*
|
|
12
|
+
* Ensures Firebase app is initialized and returns Functions instance.
|
|
13
|
+
* Handles emulator connection automatically in development.
|
|
14
|
+
* Safe to call from any consumer - handles initialization order automatically.
|
|
15
|
+
*
|
|
16
|
+
* @param region - Functions region (defaults to FIREBASE_FUNCTIONS_REGION or 'europe-west1')
|
|
17
|
+
* @returns Promise resolving to Functions instance
|
|
18
|
+
* @throws Error if initialization fails
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const functions = await getFirebaseFunctions('europe-west1');
|
|
23
|
+
* const callable = httpsCallable(functions, 'myFunction');
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function getFirebaseFunctions(region?: string): Promise<Functions>;
|
|
27
|
+
export { httpsCallable, type HttpsCallable, type HttpsCallableOptions, type HttpsCallableResult, } from 'firebase/functions';
|
|
28
|
+
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/client/functions.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,oBAAoB,CAAC;AAY5B;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC,CA4DpB;AAGD,OAAO,EACL,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getFunctions as d,connectFunctionsEmulator as m}from"firebase/functions";import{getPlatformEnvVar as e}from"@donotdev/core";import{getFirebaseSDK as p}from"./sdk";const n=new Set;async function O(a){const r=await p().getApp(),s=a||e("FIREBASE_FUNCTIONS_REGION")||"europe-west1",c=d(r,s),i=e("NODE_ENV")==="development",l=e("USE_FIREBASE_EMULATOR")==="true";if(i&&l){const o=`${r.name}_${s}`;if(!n.has(o)){const u=e("FIREBASE_EMULATOR_HOST")||"localhost",E=e("FIREBASE_FUNCTIONS_EMULATOR_PORT")||"5001";try{m(c,u,parseInt(E)),n.add(o),typeof window<"u"}catch(t){(t instanceof Error?t.message:String(t)).includes("already")&&typeof window<"u",n.add(o)}}}return c}import{httpsCallable as A}from"firebase/functions";export{O as getFirebaseFunctions,A as httpsCallable};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Firebase client SDK barrel exports
|
|
3
|
+
* @description Browser-safe Firebase operations using client SDK. Exports Auth SDK and Firestore SDK functions for client-side use.
|
|
4
|
+
* @version 0.0.1
|
|
5
|
+
* @since 0.0.1
|
|
6
|
+
* @author AMBROISE PARK Consulting
|
|
7
|
+
*/
|
|
8
|
+
export * from './sdk';
|
|
9
|
+
export * from './firestore';
|
|
10
|
+
export * from './functions';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAGH,cAAc,OAAO,CAAC;AAGtB,cAAc,aAAa,CAAC;AAG5B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./sdk";export*from"./firestore";export*from"./functions";
|