@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.
Files changed (51) hide show
  1. package/LICENSE.md +242 -0
  2. package/README.md +386 -0
  3. package/dist/client/firestore.d.ts +147 -0
  4. package/dist/client/firestore.d.ts.map +1 -0
  5. package/dist/client/firestore.js +1 -0
  6. package/dist/client/functions.d.ts +28 -0
  7. package/dist/client/functions.d.ts.map +1 -0
  8. package/dist/client/functions.js +1 -0
  9. package/dist/client/index.d.ts +11 -0
  10. package/dist/client/index.d.ts.map +1 -0
  11. package/dist/client/index.js +1 -0
  12. package/dist/client/sdk.d.ts +968 -0
  13. package/dist/client/sdk.d.ts.map +1 -0
  14. package/dist/client/sdk.js +21 -0
  15. package/dist/index.d.ts +9 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +1 -0
  18. package/dist/server/batch.d.ts +97 -0
  19. package/dist/server/batch.d.ts.map +1 -0
  20. package/dist/server/batch.js +1 -0
  21. package/dist/server/index.d.ts +15 -0
  22. package/dist/server/index.d.ts.map +1 -0
  23. package/dist/server/index.js +1 -0
  24. package/dist/server/init.d.ts +13 -0
  25. package/dist/server/init.d.ts.map +1 -0
  26. package/dist/server/init.js +2 -0
  27. package/dist/server/subscription.d.ts +117 -0
  28. package/dist/server/subscription.d.ts.map +1 -0
  29. package/dist/server/subscription.js +1 -0
  30. package/dist/server/uniqueness.d.ts +69 -0
  31. package/dist/server/uniqueness.d.ts.map +1 -0
  32. package/dist/server/uniqueness.js +1 -0
  33. package/dist/server/utils.d.ts +28 -0
  34. package/dist/server/utils.d.ts.map +1 -0
  35. package/dist/server/utils.js +1 -0
  36. package/dist/server/validation.d.ts +43 -0
  37. package/dist/server/validation.d.ts.map +1 -0
  38. package/dist/server/validation.js +1 -0
  39. package/dist/shared/index.d.ts +11 -0
  40. package/dist/shared/index.d.ts.map +1 -0
  41. package/dist/shared/index.js +1 -0
  42. package/dist/shared/transform.d.ts +96 -0
  43. package/dist/shared/transform.d.ts.map +1 -0
  44. package/dist/shared/transform.js +1 -0
  45. package/dist/shared/types.d.ts +37 -0
  46. package/dist/shared/types.d.ts.map +1 -0
  47. package/dist/shared/types.js +0 -0
  48. package/dist/shared/utils.d.ts +71 -0
  49. package/dist/shared/utils.d.ts.map +1 -0
  50. package/dist/shared/utils.js +1 -0
  51. package/package.json +50 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/client/sdk.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,eAAe,CAAC;AASvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAEV,IAAI,EACJ,cAAc,EAEd,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,WAAW,EAEZ,MAAM,eAAe,CAAC;AAGvB,YAAY,EACV,IAAI,IAAI,YAAY,EACpB,QAAQ,EACR,eAAe,EACf,cAAc,GACf,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,iBAAiB,GAClB,MAAM,eAAe,CAAC;AA0CvB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,cAAM,WAAW;IACf,kCAAkC;IAClC,OAAO,CAAC,WAAW,CAAS;IAE5B,4BAA4B;IAC5B,OAAO,CAAC,GAAG,CAA4B;IAEvC,kDAAkD;IAClD,OAAO,CAAC,IAAI,CAAqB;IAEjC,8EAA8E;IAC9E,OAAO,CAAC,QAAQ,CAAyB;IAEzC,yEA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AO,CAAC,IAAI,CAAC;IAKlD;;;;OAIG;IACG,eAAe,IAAI,OAAO,CAAC,cAAc,CAAC;IAKhD;;;;OAIG;IACG,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;IAK9C;;;;;OAKG;IACG,0BAA0B,CAC9B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC;IAM1B;;;;;;OAMG;IACG,eAAe,CACnB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC;IAI1B;;;;;;OAMG;IACG,mBAAmB,CACvB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC;IAI1B;;;;;OAKG;IACG,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC;IAKzD;;;;;OAKG;IACG,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC;IAKzD;;;;;OAKG;IACG,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC;IAK3D;;;;;OAKG;IACG,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC;IAK1D;;;;;OAKG;IACG,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC;IAK5D;;;;;OAKG;IACG,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC;IAKxD;;;;;;;OAOG;IACH,KAAK,IAAI,IAAI;CAMd;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,mBAA2C,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @fileoverview Firebase SDK Wrapper - Production Ready
3
+ * @description Type-safe Firebase Auth SDK wrapper with proper auth instance management
4
+ *
5
+ * This wrapper isolates Firebase API changes from the rest of the auth system.
6
+ * When Firebase updates to v13+, only this file needs changes - all business logic
7
+ * in FirebaseAuth and AuthService continues working unchanged.
8
+ *
9
+ * **Architecture Layer:**
10
+ * - SDK: Pure Firebase wrapper with auth instance management (this file)
11
+ * - FirebaseAuth: Firebase-specific business logic
12
+ * - AuthService: High-level orchestration
13
+ * - useAuth: React hook entry point
14
+ *
15
+ * @version 0.0.1
16
+ * @since 0.0.1
17
+ * @author AMBROISE PARK Consulting
18
+ * @license Commercial
19
+ *
20
+ * @module @donotdev/firebase/sdk
21
+ */import{initializeApp as A,getApps as d}from"firebase/app";import{initializeAppCheck as w,ReCaptchaEnterpriseProvider as m}from"firebase/app-check";import*as i from"firebase/auth";import{GoogleAuthProvider as v}from"firebase/auth";import{createSingleton as y,getPlatformEnvVar as n,getAuthDomain as k,handleError as l}from"@donotdev/core";import{GoogleAuthProvider as O,GithubAuthProvider as K,FacebookAuthProvider as M,TwitterAuthProvider as N,OAuthProvider as L,EmailAuthProvider as H}from"firebase/auth";let a=null,u,p=!1,I=0;class f{initialized=!1;app=null;auth=null;appCheck=null;authEmulatorConnected=!1;async initialize(){if(!this.initialized)try{const e=n("FIREBASE_API_KEY"),t=n("FIREBASE_PROJECT_ID");if(!e||!t){this.initialized=!0;return}const r=k(),s={apiKey:e,authDomain:r,projectId:t,storageBucket:n("FIREBASE_STORAGE_BUCKET"),messagingSenderId:n("FIREBASE_MESSAGING_SENDER_ID"),appId:n("FIREBASE_APP_ID"),measurementId:n("FIREBASE_MEASUREMENT_ID")};if(d().length===0?this.app=A(s):this.app=d()[0]||null,this.auth=this.app?i.getAuth(this.app):null,this.auth)try{await i.setPersistence(this.auth,i.browserLocalPersistence)}catch{}const P=n("NODE_ENV")==="development",E=n("USE_FIREBASE_EMULATOR")==="true";if(P&&E&&this.auth&&!this.authEmulatorConnected){const o=n("FIREBASE_EMULATOR_HOST"),g=n("FIREBASE_EMULATOR_PORT")||"9099";if(o)try{await i.connectAuthEmulator(this.auth,`http://${o}:${g}`,{disableWarnings:!0}),this.authEmulatorConnected=!0}catch(h){const c=h instanceof Error?h.message:String(h);(c.includes("already")||c.includes("emulator-config-failed"))&&(this.authEmulatorConnected=!0)}}this.initialized=!0}catch(e){throw l(e,{showNotification:!1,severity:"warning",context:{operation:"FirebaseSDK.initialize"}}),e}}ensureInitialized(){if(!this.auth)throw new Error("Firebase Auth not initialized. Call initialize() first.");return this.auth}async initializeAppCheck(e){if(!this.app||this.appCheck)return;const t=n("RECAPTCHA_SITE_KEY");if(t)try{if(e&&typeof window<"u"){const r=n("APPCHECK_DEBUG_TOKEN");window.FIREBASE_APPCHECK_DEBUG_TOKEN=r||!0}this.appCheck=w(this.app,{provider:new m(t),isTokenAutoRefreshEnabled:!0})}catch{}}appCheckInitPromise=null;async ensureAppCheckInitialized(){if(this.appCheck||!this.initialized)return;if(this.appCheckInitPromise)return this.appCheckInitPromise;const e=n("NODE_ENV")==="development";return this.appCheckInitPromise=this.initializeAppCheck(e).then(()=>{this.appCheckInitPromise=null}).catch(t=>{throw this.appCheckInitPromise=null,t}),this.appCheckInitPromise}isAppCheckEnabled(){return this.appCheck!==null}async getApp(){if(await this.initialize(),!this.app)throw new Error("Firebase app not initialized. This should never happen after initialize().");return this.app}onAuthStateChanged(e){const t=this.ensureInitialized();return i.onAuthStateChanged(t,e)}beforeAuthStateChanged(e){const t=this.ensureInitialized();return i.beforeAuthStateChanged(t,e)}getCurrentUser(){return this.ensureInitialized().currentUser}async getRedirectResult(){const e=this.ensureInitialized(),t=Date.now(),r=t-I;return u!==void 0?u:a||(p=!0,I=t,a=i.getRedirectResult(e).then(s=>(u=s,a=null,s)).catch(s=>{throw l(s,{showNotification:!1,severity:"warning",context:{operation:"getRedirectResult"}}),a=null,p=!1,s}),a)}async signInWithRedirect(e){const t=this.ensureInitialized();return await this.ensureAppCheckInitialized(),i.signInWithRedirect(t,e)}async signInWithPopup(e){const t=this.ensureInitialized();return await this.ensureAppCheckInitialized(),i.signInWithPopup(t,e)}async signInWithEmailAndPassword(e,t){const r=this.ensureInitialized();return await this.ensureAppCheckInitialized(),i.signInWithEmailAndPassword(r,e,t)}async createUserWithEmailAndPassword(e,t){const r=this.ensureInitialized();return await this.ensureAppCheckInitialized(),i.createUserWithEmailAndPassword(r,e,t)}async sendPasswordResetEmail(e,t){const r=this.ensureInitialized();return i.sendPasswordResetEmail(r,e,t)}async confirmPasswordReset(e,t){const r=this.ensureInitialized();return i.confirmPasswordReset(r,e,t)}async verifyPasswordResetCode(e){const t=this.ensureInitialized();return i.verifyPasswordResetCode(t,e)}async signInWithEmailLink(e,t){const r=this.ensureInitialized();return await this.ensureAppCheckInitialized(),i.signInWithEmailLink(r,e,t)}async sendSignInLinkToEmail(e,t){const r=this.ensureInitialized();return i.sendSignInLinkToEmail(r,e,t)}isSignInWithEmailLink(e){const t=this.ensureInitialized();return i.isSignInWithEmailLink(t,e)}async signInWithCustomToken(e){const t=this.ensureInitialized();return i.signInWithCustomToken(t,e)}async signInAnonymously(){const e=this.ensureInitialized();return i.signInAnonymously(e)}async signInWithCredential(e){const t=this.ensureInitialized();return await this.ensureAppCheckInitialized(),i.signInWithCredential(t,e)}async signInWithPhoneNumber(e,t){const r=this.ensureInitialized();return await this.ensureAppCheckInitialized(),i.signInWithPhoneNumber(r,e,t)}async signOut(){const e=this.ensureInitialized();return i.signOut(e)}async sendEmailVerification(e,t){return i.sendEmailVerification(e,t)}async updatePassword(e,t){return i.updatePassword(e,t)}async updateEmail(e,t){return i.updateEmail(e,t)}async updateProfile(e,t){return i.updateProfile(e,t)}async reload(e){return i.reload(e)}async deleteUser(e){return i.deleteUser(e)}async getIdToken(e,t){return i.getIdToken(e,t)}async getIdTokenResult(e,t){return i.getIdTokenResult(e,t)}async linkWithCredential(e,t){return i.linkWithCredential(e,t)}async linkWithPopup(e,t){return i.linkWithPopup(e,t)}async linkWithRedirect(e,t){return i.linkWithRedirect(e,t)}async linkWithPhoneNumber(e,t,r){return i.linkWithPhoneNumber(e,t,r)}async unlink(e,t){return i.unlink(e,t)}async fetchSignInMethodsForEmail(e){const t=this.ensureInitialized();return i.fetchSignInMethodsForEmail(t,e)}async reauthenticateWithCredential(e,t){return i.reauthenticateWithCredential(e,t)}async reauthenticateWithPopup(e,t){return i.reauthenticateWithPopup(e,t)}async reauthenticateWithRedirect(e,t){return i.reauthenticateWithRedirect(e,t)}createGoogleProvider(){return new i.GoogleAuthProvider}createGithubProvider(){return new i.GithubAuthProvider}createFacebookProvider(){return new i.FacebookAuthProvider}createTwitterProvider(){return new i.TwitterAuthProvider}createMicrosoftProvider(){return new i.OAuthProvider("microsoft.com")}createAppleProvider(){return new i.OAuthProvider("apple.com")}createOAuthProvider(e){return new i.OAuthProvider(e)}createPhoneAuthProvider(){const e=this.ensureInitialized();return new i.PhoneAuthProvider(e)}createEmailAuthProvider(){return i.EmailAuthProvider}createRecaptchaVerifier(e,t){const r=this.ensureInitialized();return new i.RecaptchaVerifier(r,e,t)}multiFactor(e){return i.multiFactor(e)}getMultiFactorResolver(e){const t=this.ensureInitialized();return i.getMultiFactorResolver(t,e)}getAdditionalUserInfo(e){return i.getAdditionalUserInfo(e)}async setPersistence(e){const t=this.ensureInitialized();return i.setPersistence(t,e)}useDeviceLanguage(){const e=this.ensureInitialized();return i.useDeviceLanguage(e)}async checkActionCode(e){const t=this.ensureInitialized();return i.checkActionCode(t,e)}async applyActionCode(e){const t=this.ensureInitialized();return i.applyActionCode(t,e)}async signInWithGoogle(){const e=this.createGoogleProvider();return await this.signInWithPopup(e)}async signInWithGoogleRedirect(){const e=this.createGoogleProvider();return await this.signInWithRedirect(e)}async signInWithGitHub(){const e=this.createGithubProvider();return await this.signInWithPopup(e)}async signInWithGitHubRedirect(){const e=this.createGithubProvider();return await this.signInWithRedirect(e)}async signInWithFacebook(){const e=this.createFacebookProvider();return await this.signInWithPopup(e)}async signInWithFacebookRedirect(){const e=this.createFacebookProvider();return await this.signInWithRedirect(e)}async signInWithTwitter(){const e=this.createTwitterProvider();return await this.signInWithPopup(e)}async signInWithTwitterRedirect(){const e=this.createTwitterProvider();return await this.signInWithRedirect(e)}async signInWithMicrosoft(){const e=this.createMicrosoftProvider();return await this.signInWithPopup(e)}async signInWithMicrosoftRedirect(){const e=this.createMicrosoftProvider();return await this.signInWithRedirect(e)}async signInWithApple(){const e=this.createAppleProvider();return await this.signInWithPopup(e)}async signInWithAppleRedirect(){const e=this.createAppleProvider();return await this.signInWithRedirect(e)}async signInWithGoogleCredential(e){const t=this.createGoogleProvider(),r=v.credential(e);return await this.signInWithCredential(r)}async signInWithEmail(e,t){return await this.signInWithEmailAndPassword(e,t)}async createUserWithEmail(e,t){return await this.createUserWithEmailAndPassword(e,t)}async linkWithGoogle(e){const t=this.createGoogleProvider();return await this.linkWithPopup(e,t)}async linkWithGitHub(e){const t=this.createGithubProvider();return await this.linkWithPopup(e,t)}async linkWithFacebook(e){const t=this.createFacebookProvider();return await this.linkWithPopup(e,t)}async linkWithTwitter(e){const t=this.createTwitterProvider();return await this.linkWithPopup(e,t)}async linkWithMicrosoft(e){const t=this.createMicrosoftProvider();return await this.linkWithPopup(e,t)}async linkWithApple(e){const t=this.createAppleProvider();return await this.linkWithPopup(e,t)}reset(){this.initialized=!1,this.auth=null,this.app=null,this.appCheck=null}}const D=y(()=>new f);export{H as EmailAuthProvider,M as FacebookAuthProvider,K as GithubAuthProvider,O as GoogleAuthProvider,L as OAuthProvider,N as TwitterAuthProvider,D as getFirebaseSDK};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @fileoverview Firebase provider package
3
+ * @description Client-safe Firebase utilities and shared functionality. Main entry point for client-side Firebase operations. For server-only operations, use '@donotdev/firebase/server'.
4
+ * @version 0.0.1
5
+ * @since 0.0.1
6
+ * @author AMBROISE PARK Consulting
7
+ */
8
+ export * from './client';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,cAAc,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export*from"./client";
@@ -0,0 +1,97 @@
1
+ import type { dndevSchema } from '@donotdev/core';
2
+ interface FirestoreTransaction {
3
+ get: (docRef: any) => Promise<any>;
4
+ set: (docRef: any, data: any, options?: any) => FirestoreTransaction;
5
+ update: (docRef: any, data: any) => FirestoreTransaction;
6
+ delete: (docRef: any) => FirestoreTransaction;
7
+ }
8
+ /**
9
+ * Result of a batch operation
10
+ *
11
+ * @version 0.0.1
12
+ * @since 0.0.1
13
+ * @author AMBROISE PARK Consulting
14
+ */
15
+ export interface BatchResult {
16
+ /** Number of successful operations */
17
+ successes: number;
18
+ /** Number of failed operations */
19
+ failures: number;
20
+ /** Failed items with error information */
21
+ failedItems?: Array<{
22
+ index: number;
23
+ error: Error;
24
+ }>;
25
+ }
26
+ /**
27
+ * Options for batch operations
28
+ *
29
+ * @version 0.0.1
30
+ * @since 0.0.1
31
+ * @author AMBROISE PARK Consulting
32
+ */
33
+ export interface BatchOptions {
34
+ /** Field to use as document ID */
35
+ idField?: string;
36
+ /** Generate IDs for documents without them */
37
+ generateIds?: boolean;
38
+ /** Maximum batch size (Firestore has a limit of 500) */
39
+ maxBatchSize?: number;
40
+ /** Fields to remove before saving to Firestore */
41
+ removeFields?: string[];
42
+ /** Whether to validate items using the schema */
43
+ validate?: boolean;
44
+ }
45
+ /**
46
+ * Batch write operation (server-only)
47
+ *
48
+ * @version 0.0.1
49
+ * @since 0.0.1
50
+ * @author AMBROISE PARK Consulting
51
+ */
52
+ export declare const batchWrite: <T extends Record<string, any>>(collection: string, items: T[], operation: "create" | "update" | "delete", schema?: dndevSchema<T>, options?: BatchOptions) => Promise<BatchResult>;
53
+ /**
54
+ * Batch create operation (server-only)
55
+ *
56
+ * @version 0.0.1
57
+ * @since 0.0.1
58
+ * @author AMBROISE PARK Consulting
59
+ */
60
+ export declare const batchCreate: <T extends Record<string, any>>(collection: string, items: T[], schema?: dndevSchema<T>, options?: BatchOptions) => Promise<BatchResult>;
61
+ /**
62
+ * Batch update operation (server-only)
63
+ *
64
+ * @version 0.0.1
65
+ * @since 0.0.1
66
+ * @author AMBROISE PARK Consulting
67
+ */
68
+ export declare const batchUpdate: <T extends Record<string, any>>(collection: string, items: T[], schema?: dndevSchema<T>, options?: BatchOptions) => Promise<BatchResult>;
69
+ /**
70
+ * Batch delete operation (server-only)
71
+ *
72
+ * @version 0.0.1
73
+ * @since 0.0.1
74
+ * @author AMBROISE PARK Consulting
75
+ */
76
+ export declare const batchDelete: <T extends Record<string, any>>(collection: string, items: T[] | string[], options?: BatchOptions) => Promise<BatchResult>;
77
+ /**
78
+ * Run transaction operation (server-only)
79
+ *
80
+ * @version 0.0.1
81
+ * @since 0.0.1
82
+ * @author AMBROISE PARK Consulting
83
+ */
84
+ export declare const runTransaction: <T>(updateFunction: (transaction: FirestoreTransaction) => Promise<T>) => Promise<T>;
85
+ /**
86
+ * Bulk get operation (server-only)
87
+ *
88
+ * @version 0.0.1
89
+ * @since 0.0.1
90
+ * @author AMBROISE PARK Consulting
91
+ */
92
+ export declare const bulkGet: <T = Record<string, any>>(collection: string, ids: string[], options?: {
93
+ maxBatchSize?: number;
94
+ transform?: boolean;
95
+ }) => Promise<Array<T | null>>;
96
+ export {};
97
+ //# sourceMappingURL=batch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/server/batch.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAWlD,UAAU,oBAAoB;IAC5B,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,oBAAoB,CAAC;IACrE,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,oBA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D,WAAW,CAAC,CAAC,CAAC,YACd,YAAY,KACpB,OAAO,CAAC,WAAW,CAmKa,CAAC;AAEtC;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GA/JJ,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,cACjC,MAAM,SACX,CAAC,EAAE,GAAG,MAAM,EAAE,YACZ,YAAY,KACpB,OAAO,CAAC,WAAW,CA6Ja,CAAC;AAEtC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GA1IJ,CAAC,kBACJ,CAAC,WAAW,EAAE,oBAAoB,KAAK,OAAO,CAAC,CAAC,CAAC,KAChE,OAAO,CAAC,CAAC,CA0I0B,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GArIJ,CAAC,oCACD,MAAM,OACb,MAAM,EAAE,YACJ;IACP,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,KACA,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAgIK,CAAC"}
@@ -0,0 +1 @@
1
+ import*as E from"valibot";import{handleServerError as m}from"@donotdev/core/server";import{getServerFirestore as x}from"./utils";import{prepareForFirestore as W,transformFirestoreData as $}from"../shared/transform";const p=typeof window<"u",i={async batchWrite(e,t,r,n,w={}){if(!t||!t.length)return{successes:0,failures:0};const{idField:s="id",generateIds:y=!0,maxBatchSize:v=450,removeFields:l=[],validate:I=!!n}=w,c={successes:0,failures:0,failedItems:[]};try{const f=[],d=await x();let a=d.batch(),h=0;for(let b=0;b<t.length;b++){let u=t[b];if(!u){c.failures++,c.failedItems?.push({index:b,error:new Error("Item is null or undefined")});continue}try{if(r==="delete"){if(!u[s])throw m(new Error(`Missing ID for delete operation (${s})`),{userMessage:"Unable to delete item: missing ID",severity:"error",context:{collection:e,idField:s,operation:r}});const o=d.collection(e).doc(u[s]);a.delete(o)}else{if(I&&n)try{E.parse(n,u)}catch(F){throw m(F,{userMessage:"Validation failed for item",severity:"warning",context:{collection:e,operation:r,idField:s,itemId:u[s]}})}let o=u[s];if(!o&&r==="create"&&y)o=d.collection(e).doc().id,u={...u,[s]:o};else if(!o)throw m(new Error(`Missing ID for ${r} operation (${s})`),{userMessage:`Unable to ${r} item: missing ID`,severity:"error",context:{collection:e,idField:s,operation:r}});const M=[s,...l],C=W(u,M),D=d.collection(e).doc(o);r==="create"?a.create(D,C):r==="update"&&a.update(D,C)}c.successes++,h++,h>=v&&(f.push(a),a=d.batch(),h=0)}catch(o){c.failures++,c.failedItems?.push({index:b,error:o instanceof Error?o:new Error(String(o))})}}return h>0&&f.push(a),f.length>0&&await Promise.all(f.map(b=>b.commit())),c}catch(f){throw m(f,{userMessage:`Batch ${r} operation failed for collection ${e}`,context:{collection:e,operation:r,itemCount:t.length,processedCount:c.successes+c.failures,successCount:c.successes,failureCount:c.failures}})}},async batchCreate(e,t,r,n={}){return i.batchWrite(e,t,"create",r,n)},async batchUpdate(e,t,r,n={}){return i.batchWrite(e,t,"update",r,n)},async batchDelete(e,t,r={}){if(t.length>0&&typeof t[0]=="string"){const n=r.idField||"id",w=t.map(s=>({[n]:s}));return i.batchWrite(e,w,"delete",void 0,r)}return i.batchWrite(e,t,"delete",void 0,r)},async runTransaction(e){try{return await(await x()).runTransaction(e)}catch(t){throw m(t,{userMessage:"Transaction failed"})}},async bulkGet(e,t,r={}){if(!t.length)return[];const{maxBatchSize:n=450,transform:w=!0}=r;try{const s=[];for(let l=0;l<t.length;l+=n)s.push(t.slice(l,l+n));const y=s.map(async l=>{const f=await(await x()).collection(e).where("__name__","in",l).get(),d=new Map;return f.forEach(a=>{d.set(a.id,a.data())}),l.map(a=>{const h=d.get(a);return h?w?$({id:a,...h}):{id:a,...h}:null})});return(await Promise.all(y)).flat()}catch(s){throw m(s,{userMessage:`Bulk get operation failed for collection ${e}`,context:{collection:e,idCount:t.length}})}}},g=e=>()=>{throw new Error(`Firebase Admin function '${e}' is not available in browser environments`)},U=p?g("batchWrite"):i.batchWrite,k=p?g("batchCreate"):i.batchCreate,R=p?g("batchUpdate"):i.batchUpdate,G=p?g("batchDelete"):i.batchDelete,_=p?g("runTransaction"):i.runTransaction,z=p?g("bulkGet"):i.bulkGet;export{k as batchCreate,G as batchDelete,R as batchUpdate,U as batchWrite,z as bulkGet,_ as runTransaction};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @fileoverview Firebase server SDK barrel exports
3
+ * @description Server-only Firebase operations using Admin SDK. Provides server-side authentication, Firestore operations, batch processing, validation, and subscription management. Uses Firebase Admin SDK for privileged operations in Node.js environments only.
4
+ * @version 0.0.1
5
+ * @since 0.0.1
6
+ * @author AMBROISE PARK Consulting
7
+ */
8
+ export * from './init';
9
+ export * from './utils';
10
+ export * from './batch';
11
+ export * from './subscription';
12
+ export * from './validation';
13
+ export * from './uniqueness';
14
+ export { FieldValue, Query, Timestamp } from 'firebase-admin/firestore';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAG7B,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1 @@
1
+ export*from"./init";export*from"./utils";export*from"./batch";export*from"./subscription";export*from"./validation";export*from"./uniqueness";import{FieldValue as a,Query as i,Timestamp as l}from"firebase-admin/firestore";export{a as FieldValue,i as Query,l as Timestamp};
@@ -0,0 +1,13 @@
1
+ import type { App } from 'firebase-admin/app';
2
+ export interface FirebaseAdminServices {
3
+ app: App | null;
4
+ auth: any | null;
5
+ firestore: any | null;
6
+ functions: any | null;
7
+ }
8
+ export declare function initFirebaseAdmin(): Promise<FirebaseAdminServices>;
9
+ export declare function getFirebaseAdminApp(): Promise<App>;
10
+ export declare function getFirebaseAdminAuth(): any;
11
+ export declare function getFirebaseAdminFirestore(): any;
12
+ export declare function getFirebaseAdminFunctions(): any;
13
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/server/init.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAE9C,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IAChB,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;IACjB,SAAS,EAAE,GAAG,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,GAAG,GAAG,IAAI,CAAC;CACvB;AAwDD,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAUxE;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC,CAMxD;AAED,wBAAgB,oBAAoB,IAAI,GAAG,CAM1C;AAED,wBAAgB,yBAAyB,IAAI,GAAG,CAM/C;AAED,wBAAgB,yBAAyB,IAAI,GAAG,CAM/C"}
@@ -0,0 +1,2 @@
1
+ import{initializeApp as n,getApps as t,cert as o}from"firebase-admin/app";import{getAuth as s}from"firebase-admin/auth";import{getFirestore as c}from"firebase-admin/firestore";import{getFunctions as a}from"firebase-admin/functions";import{handleServerError as p,createSingleton as A}from"@donotdev/core/server";function E(){const e=t();let i=null;if(e.length===0?process.env.FIREBASE_ADMIN_PRIVATE_KEY&&process.env.FIREBASE_PROJECT_ID&&process.env.FIREBASE_CLIENT_EMAIL?i=n({credential:o({projectId:process.env.FIREBASE_PROJECT_ID,clientEmail:process.env.FIREBASE_CLIENT_EMAIL,privateKey:process.env.FIREBASE_ADMIN_PRIVATE_KEY.replace(/\\n/g,`
2
+ `)}),projectId:process.env.FIREBASE_PROJECT_ID}):i=n():i=e[0]||null,!i)throw new Error("Failed to initialize Firebase Admin app");return{app:i,auth:s(i),firestore:c(i),functions:a(i)}}const r=A(E);async function I(){try{return r()}catch(e){throw p(e,{userMessage:"Failed to initialize Firebase Admin",context:{provider:"FirebaseAdmin",operation:"initFirebaseAdmin"},severity:"error"})}}async function v(){const e=r();if(!e.app)throw new Error("Firebase Admin not initialized");return e.app}function _(){const e=r();if(!e.auth)throw new Error("Firebase Admin auth not initialized");return e.auth}function b(){const e=r();if(!e.firestore)throw new Error("Firebase Admin firestore not initialized");return e.firestore}function h(){const e=r();if(!e.functions)throw new Error("Firebase Admin functions not initialized");return e.functions}export{v as getFirebaseAdminApp,_ as getFirebaseAdminAuth,b as getFirebaseAdminFirestore,h as getFirebaseAdminFunctions,I as initFirebaseAdmin};
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @fileoverview Stripe subscription utilities for Firebase
3
+ * @description Helper functions for managing Stripe subscriptions in Firestore
4
+ *
5
+ * @version 0.0.1
6
+ * @since 0.0.1
7
+ * @author AMBROISE PARK Consulting
8
+ */
9
+ import type { SubscriptionStatus } from '@donotdev/core';
10
+ /**
11
+ * Subscription data type for Firestore storage
12
+ * This is different from SubscriptionClaims which is for Firebase Auth custom claims
13
+ *
14
+ * @version 0.0.1
15
+ * @since 0.0.1
16
+ * @author AMBROISE PARK Consulting
17
+ */
18
+ export interface SubscriptionData {
19
+ id: string;
20
+ customerId: string;
21
+ status: SubscriptionStatus;
22
+ planId: string;
23
+ currentPeriodStart: string;
24
+ currentPeriodEnd: string;
25
+ cancelAtPeriodEnd: boolean;
26
+ canceledAt?: string;
27
+ metadata?: Record<string, string>;
28
+ features?: string[];
29
+ createdAt: string;
30
+ updatedAt: string;
31
+ }
32
+ /**
33
+ * Options for subscription operations
34
+ *
35
+ * @version 0.0.1
36
+ * @since 0.0.1
37
+ * @author AMBROISE PARK Consulting
38
+ */
39
+ export interface SubscriptionOptions {
40
+ /**
41
+ * Collection where subscriptions are stored
42
+ * @default "subscriptions"
43
+ */
44
+ collection?: string;
45
+ /**
46
+ * User ID field name in subscription document
47
+ * @default "customerId"
48
+ */
49
+ userIdField?: string;
50
+ }
51
+ /**
52
+ * Gets a user's active subscription
53
+ * @param userId User ID or customer ID
54
+ * @param options Operation options
55
+ * @returns Active subscription or null if not found
56
+ *
57
+ * @version 0.0.1
58
+ * @since 0.0.1
59
+ * @author AMBROISE PARK Consulting
60
+ */
61
+ export declare function getActiveSubscription(userId: string, options?: SubscriptionOptions): Promise<SubscriptionData | null>;
62
+ /**
63
+ * Gets all subscriptions for a user
64
+ * @param userId User ID or customer ID
65
+ * @param options Operation options
66
+ * @returns Array of subscriptions
67
+ *
68
+ * @version 0.0.1
69
+ * @since 0.0.1
70
+ * @author AMBROISE PARK Consulting
71
+ */
72
+ export declare function getUserSubscriptions(userId: string, options?: SubscriptionOptions): Promise<SubscriptionData[]>;
73
+ /**
74
+ * Creates or updates a subscription
75
+ * @param subscription Subscription data
76
+ * @param options Operation options
77
+ * @returns Updated subscription data
78
+ *
79
+ * @version 0.0.1
80
+ * @since 0.0.1
81
+ * @author AMBROISE PARK Consulting
82
+ */
83
+ export declare function saveSubscription(subscription: SubscriptionData, options?: SubscriptionOptions): Promise<SubscriptionData>;
84
+ /**
85
+ * Updates a subscription status
86
+ * @param subscriptionId Subscription ID
87
+ * @param status New subscription status
88
+ * @param options Operation options
89
+ *
90
+ * @version 0.0.1
91
+ * @since 0.0.1
92
+ * @author AMBROISE PARK Consulting
93
+ */
94
+ export declare function updateSubscriptionStatus(subscriptionId: string, status: SubscriptionStatus, options?: SubscriptionOptions): Promise<void>;
95
+ /**
96
+ * Checks if a user has access to a specific feature
97
+ * @param userId User ID or customer ID
98
+ * @param featureKey Feature key to check
99
+ * @param options Operation options
100
+ * @returns Whether the user has access to the feature
101
+ *
102
+ * @version 0.0.1
103
+ * @since 0.0.1
104
+ * @author AMBROISE PARK Consulting
105
+ */
106
+ export declare function hasFeatureAccess(userId: string, featureKey: string, options?: SubscriptionOptions): Promise<boolean>;
107
+ /**
108
+ * Handler for Stripe webhook events
109
+ * @param event Stripe event object
110
+ * @param options Operation options
111
+ *
112
+ * @version 0.0.1
113
+ * @since 0.0.1
114
+ * @author AMBROISE PARK Consulting
115
+ */
116
+ export declare function handleStripeWebhookEvent(event: any, options?: SubscriptionOptions): Promise<void>;
117
+ //# sourceMappingURL=subscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/server/subscription.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAUzD;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CA8BlC;AAED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAqB7B;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,gBAAgB,EAC9B,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,gBAAgB,CAAC,CAmC3B;AAED;;;;;;;;;GASG;AACH,wBAAsB,wBAAwB,CAC5C,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,kBAAkB,EAC1B,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CAcf;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,OAAO,CAAC,CA2BlB;AAED;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,GAAG,EACV,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CA8Bf"}
@@ -0,0 +1 @@
1
+ import{handleServerError as l}from"@donotdev/core/server";import{getServerFirestore as i}from"./utils";import{prepareForFirestore as f,transformFirestoreData as w}from"../shared/transform";import{handleFirebaseError as u}from"../shared/utils";async function m(t,a={}){const{collection:r="subscriptions",userIdField:e="customerId"}=a;try{const n=await(await i()).collection(r).where(e,"==",t).where("status","==","active").limit(1).get();if(n.empty)return null;const c=n.docs[0];if(!c)return null;const d=c.data();return w({id:c.id,...d})}catch(o){throw u(o,"getActiveSubscription")}}async function I(t,a={}){const{collection:r="subscriptions",userIdField:e="customerId"}=a;try{return(await(await i()).collection(r).where(e,"==",t).orderBy("createdAt","desc").get()).docs.map(c=>w({id:c.id,...c.data()}))}catch(o){throw u(o,"getUserSubscriptions")}}async function p(t,a={}){const{collection:r="subscriptions"}=a;try{const e=await i(),o=new Date().toISOString();t.createdAt||(t.createdAt=o),t.updatedAt=o;const s=f(t),{id:n,...c}=s,d=n?e.collection(r).doc(n):e.collection(r).doc();return await d.set(c,{merge:!0}),{...t,id:d.id}}catch(e){throw u(e,"saveSubscription")}}async function h(t,a,r={}){const{collection:e="subscriptions"}=r;try{await(await i()).collection(e).doc(t).update({status:a,updatedAt:new Date().toISOString()})}catch(o){throw u(o,"updateSubscriptionStatus")}}async function v(t,a,r={}){try{const e=await m(t,r);return e?e.features&&Array.isArray(e.features)?e.features.includes(a):e.metadata&&e.metadata[a]?e.metadata[a]==="true":!1:!1}catch(e){return l(e,{context:{function:"hasFeatureAccess"}}),!1}}async function F(t,a={}){const r=t.type,e=t.data.object;try{switch(r){case"customer.subscription.created":case"customer.subscription.updated":await y(e,a);break;case"customer.subscription.deleted":await h(e.id,"canceled",a);break;default:}}catch(o){throw l(o,{userMessage:`Failed to handle Stripe webhook event: ${r}`,severity:"error",context:{eventType:r,eventId:t.id}})}}async function y(t,a={}){const r={id:t.id,customerId:t.customer,status:t.status,planId:t.items.data[0]?.plan.id||"",currentPeriodStart:new Date(t.current_period_start*1e3).toISOString(),currentPeriodEnd:new Date(t.current_period_end*1e3).toISOString(),cancelAtPeriodEnd:t.cancel_at_period_end,metadata:t.metadata||{},createdAt:new Date(t.created*1e3).toISOString(),updatedAt:new Date().toISOString()};t.canceled_at&&(r.canceledAt=new Date(t.canceled_at*1e3).toISOString()),await p(r,a)}export{m as getActiveSubscription,I as getUserSubscriptions,F as handleStripeWebhookEvent,v as hasFeatureAccess,p as saveSubscription,h as updateSubscriptionStatus};
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @fileoverview Firebase server uniqueness validation
3
+ * @description Implementation of uniqueness constraint validation for Firestore. Provides validation and registration of unique constraint validators for server-side operations.
4
+ * @version 0.0.1
5
+ * @since 0.0.1
6
+ * @author AMBROISE PARK Consulting
7
+ */
8
+ import type { UniqueConstraintValidator } from '@donotdev/core';
9
+ /**
10
+ * Registers a validator for uniqueness constraints
11
+ * @param validator - The validator implementation
12
+ *
13
+ * @version 0.0.1
14
+ * @since 0.0.1
15
+ * @author AMBROISE PARK Consulting
16
+ */
17
+ export declare function registerUniqueConstraintValidator(validator: UniqueConstraintValidator): void;
18
+ /**
19
+ * Gets the currently registered uniqueness constraint validator
20
+ * @returns The registered validator or undefined if none is registered
21
+ *
22
+ * @version 0.0.1
23
+ * @since 0.0.1
24
+ * @author AMBROISE PARK Consulting
25
+ */
26
+ export declare function getUniqueConstraintValidator(): UniqueConstraintValidator | undefined;
27
+ /**
28
+ * Checks if a uniqueness validator is registered
29
+ * @returns True if a validator is registered, false otherwise
30
+ *
31
+ * @version 0.0.1
32
+ * @since 0.0.1
33
+ * @author AMBROISE PARK Consulting
34
+ */
35
+ export declare function hasUniqueConstraintValidator(): boolean;
36
+ /**
37
+ * Creates a Firestore validator for uniqueness constraints in server environments
38
+ * @returns A Firestore-based uniqueness constraint validator
39
+ *
40
+ * @version 0.0.1
41
+ * @since 0.0.1
42
+ * @author AMBROISE PARK Consulting
43
+ */
44
+ export declare function createFirestoreValidator(): Promise<UniqueConstraintValidator>;
45
+ /**
46
+ * Creates a Firestore validator for browser environments
47
+ * @returns A client-side Firestore uniqueness constraint validator
48
+ *
49
+ * @version 0.0.1
50
+ * @since 0.0.1
51
+ * @author AMBROISE PARK Consulting
52
+ */
53
+ export declare function createFirestoreClientValidator(): Promise<UniqueConstraintValidator>;
54
+ /**
55
+ * Validates uniqueness constraints for a document
56
+ * @param collection Collection name
57
+ * @param constraints Array of field constraints to check
58
+ * @param data Document data
59
+ * @param currentDocId Current document ID (for updates)
60
+ *
61
+ * @version 0.0.1
62
+ * @since 0.0.1
63
+ * @author AMBROISE PARK Consulting
64
+ */
65
+ export declare function validateUniqueness(collection: string, constraints: Array<{
66
+ field: string;
67
+ errorMessage?: string;
68
+ }>, data: Record<string, any>, currentDocId?: string): Promise<void>;
69
+ //# sourceMappingURL=uniqueness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uniqueness.d.ts","sourceRoot":"","sources":["../../src/server/uniqueness.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAYhE;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,yBAAyB,GACnC,IAAI,CAEN;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,IACxC,yBAAyB,GACzB,SAAS,CAEZ;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,IAAI,OAAO,CAEtD;AAED;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,yBAAyB,CAAC,CAoDnF;AAED;;;;;;;GAOG;AACH,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,yBAAyB,CAAC,CAoDzF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC,EACF,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC,CAwDf"}
@@ -0,0 +1 @@
1
+ import{handleServerError as l}from"@donotdev/core/server";import{getServerFirestore as d}from"./utils";const u={};function f(t){u.uniqueConstraintValidator=t}function h(){return u.uniqueConstraintValidator}function k(){return!!u.uniqueConstraintValidator}async function p(){try{const t=await d(),i={checkDuplicate:async(a,r,e,s)=>{if(e==null)return!1;try{return(await t.collection(a).where(r,"==",e).get()).docs.some(o=>o.id!==s&&o.data()[r]===e)}catch(n){throw l(n,{userMessage:`Failed to check uniqueness for field "${r}"`,severity:"error",context:{collection:a,field:r,value:e}})}}};return f(i),i}catch{return{checkDuplicate:async()=>!1}}}async function y(){try{const t=await d(),i={checkDuplicate:async(a,r,e,s)=>{if(e==null)return!1;try{return(await t.collection(a).where(r,"==",e).get()).docs.some(o=>o.id!==s&&o.data()[r]===e)}catch(n){throw l(n,{userMessage:`Failed to check uniqueness for field "${r}"`,severity:"error",context:{collection:a,field:r,value:e}})}}};return f(i),i}catch{return{checkDuplicate:async()=>!1}}}async function m(t,i,a,r){if(!i.length)return;let e=h();if(e||(typeof window<"u"?e=await y():e=await p()),!e)return;const s=[];if(await Promise.all(i.map(async({field:n,errorMessage:c})=>{const o=a[n];if(o==null)return;await e.checkDuplicate(t,n,o,r)&&s.push({field:n,message:c||`The ${n} must be unique`})})),s.length>0)throw l(new Error("Uniqueness validation failed"),{userMessage:"Uniqueness validation failed",severity:"error",context:{validationErrors:s,collection:t}})}export{y as createFirestoreClientValidator,p as createFirestoreValidator,h as getUniqueConstraintValidator,k as hasUniqueConstraintValidator,f as registerUniqueConstraintValidator,m as validateUniqueness};
@@ -0,0 +1,28 @@
1
+ type FirebaseAdminType = any;
2
+ type FirestoreType = any;
3
+ /**
4
+ * Get Firebase Admin instance (server-only)
5
+ *
6
+ * @version 0.0.1
7
+ * @since 0.0.1
8
+ * @author AMBROISE PARK Consulting
9
+ */
10
+ export declare const getServerAdmin: () => Promise<FirebaseAdminType>;
11
+ /**
12
+ * Get Firebase Admin Firestore instance (server-only)
13
+ *
14
+ * @version 0.0.1
15
+ * @since 0.0.1
16
+ * @author AMBROISE PARK Consulting
17
+ */
18
+ export declare const getServerFirestore: () => Promise<FirestoreType>;
19
+ /**
20
+ * Generate Firestore document ID (server-only)
21
+ *
22
+ * @version 0.0.1
23
+ * @since 0.0.1
24
+ * @author AMBROISE PARK Consulting
25
+ */
26
+ export declare const generateServerId: () => Promise<string>;
27
+ export {};
28
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/server/utils.ts"],"names":[],"mappings":"AAaA,KAAK,iBAAiB,GAAG,GAAG,CAAC;AAC7B,KAAK,aAAa,GAAG,GAAG,CAAC;AA4BzB;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,QA/BD,OAAO,CAAC,iBAAiB,CA+Be,CAAC;AAEnE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,QA/BD,OAAO,CAAC,aAAa,CA+BuB,CAAC;AAE3E;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,QA/BD,OAAO,CAAC,MAAM,CA+B4B,CAAC"}
@@ -0,0 +1 @@
1
+ import{handleServerError as t}from"@donotdev/core/server";const r={async getServerAdmin(){try{const e=await import("firebase-admin");return e.default||e}catch(e){throw t(e,"Error getting Firebase Admin")}},async getServerFirestore(){try{return(await import("firebase-admin/firestore")).getFirestore()}catch(e){throw t(e,"Error getting Admin Firestore")}},async generateServerId(){return(await r.getServerFirestore()).collection("_").doc().id}},i=r.getServerAdmin,n=r.getServerFirestore,s=r.generateServerId;export{s as generateServerId,i as getServerAdmin,n as getServerFirestore};
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @fileoverview Firebase server validation
3
+ * @description Document validation utilities using server-side Firebase Admin SDK. Provides document validation, uniqueness validation, and schema validation for Firestore operations.
4
+ * @version 0.0.1
5
+ * @since 0.0.1
6
+ * @author AMBROISE PARK Consulting
7
+ */
8
+ import * as v from 'valibot';
9
+ import type { dndevSchema } from '@donotdev/core';
10
+ export { validateUniqueness, registerUniqueConstraintValidator, getUniqueConstraintValidator, hasUniqueConstraintValidator, createFirestoreValidator, createFirestoreClientValidator, } from './uniqueness';
11
+ /**
12
+ * Validates a Firestore document against its schema with enhanced checks
13
+ * @param schema - The Valibot schema to validate against
14
+ * @param data - The document data to validate
15
+ * @param operation - Whether this is a create or update operation
16
+ * @param currentDocId - Current document ID (for updates)
17
+ * @throws {Error} - If validation fails
18
+ *
19
+ * @version 0.0.1
20
+ * @since 0.0.1
21
+ * @author AMBROISE PARK Consulting
22
+ */
23
+ export declare function validateFirestoreDocument<T>(schema: dndevSchema<T>, data: Record<string, any>, operation: 'create' | 'update', currentDocId?: string): Promise<void>;
24
+ /**
25
+ * Enhances a Valibot schema with Firestore metadata
26
+ *
27
+ * @param schema Base Valibot schema
28
+ * @param metadata Firestore-specific metadata
29
+ * @returns Enhanced schema
30
+ *
31
+ * @version 0.0.1
32
+ * @since 0.0.1
33
+ * @author AMBROISE PARK Consulting
34
+ */
35
+ export declare function enhanceSchema<T>(schema: v.BaseSchema<unknown, T, v.BaseIssue<unknown>>, metadata: {
36
+ collection: string;
37
+ uniqueFields?: Array<{
38
+ field: string;
39
+ errorMessage?: string;
40
+ }>;
41
+ customValidate?: (data: Record<string, any>, operation: 'create' | 'update') => Promise<void>;
42
+ }): dndevSchema<T>;
43
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/server/validation.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,OAAO,KAAK,EAAE,WAAW,EAA6B,MAAM,gBAAgB,CAAC;AAM7E,OAAO,EACL,kBAAkB,EAClB,iCAAiC,EACjC,4BAA4B,EAC5B,4BAA4B,EAC5B,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;GAWG;AACH,wBAAsB,yBAAyB,CAAC,CAAC,EAC/C,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,SAAS,EAAE,QAAQ,GAAG,QAAQ,EAC9B,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC,CAyCf;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EACtD,QAAQ,EAAE;IACR,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,KAAK,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC,CAAC;IACH,cAAc,CAAC,EAAE,CACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,SAAS,EAAE,QAAQ,GAAG,QAAQ,KAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,GACA,WAAW,CAAC,CAAC,CAAC,CAIhB"}
@@ -0,0 +1 @@
1
+ import*as n from"valibot";import{handleServerError as i}from"@donotdev/core/server";import{validateUniqueness as s}from"./uniqueness";import{validateUniqueness as v,registerUniqueConstraintValidator as V,getUniqueConstraintValidator as p,hasUniqueConstraintValidator as q,createFirestoreValidator as g,createFirestoreClientValidator as w}from"./uniqueness";async function u(e,t,r,o){try{n.parse(e,t),e.metadata?.uniqueFields?.length&&await s(e.metadata.collection,e.metadata.uniqueFields,t,o),e.metadata?.customValidate&&await e.metadata.customValidate(t,r)}catch(a){throw a.name==="ValibotError"||a.issues?i(a,{userMessage:"Document validation failed",context:{validationErrors:a.issues||[],data:t},severity:"warning"}):i(a,{userMessage:"Document validation failed",context:{collection:e.metadata?.collection||"unknown"},severity:"error"})}}function c(e,t){const r=e;return r.metadata=t,r}export{w as createFirestoreClientValidator,g as createFirestoreValidator,c as enhanceSchema,p as getUniqueConstraintValidator,q as hasUniqueConstraintValidator,V as registerUniqueConstraintValidator,u as validateFirestoreDocument,v as validateUniqueness};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @fileoverview Firebase shared utilities barrel exports
3
+ * @description Cross-platform utilities for both client and server environments. Contains environment-agnostic transformations, types, and utilities that work in both browser and Node.js contexts.
4
+ * @version 0.0.1
5
+ * @since 0.0.1
6
+ * @author AMBROISE PARK Consulting
7
+ */
8
+ export * from './transform';
9
+ export * from './utils';
10
+ export * from './types';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -0,0 +1 @@
1
+ export*from"./transform";export*from"./utils";export*from"./types";