ngx-firestore-wrapper-kit 0.0.2 → 0.0.4

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
@@ -1,139 +1,36 @@
1
1
  # ngx-firestore-wrapper-kit — Integration Guide
2
2
 
3
- <style>
4
- .guide-header {
5
- max-width: 960px;
6
- margin: 0 auto 1.5rem;
7
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
8
- line-height: 1.6;
9
- color: #24292f;
10
- }
11
-
12
- .guide-intro {
13
- margin: 0 0 1rem;
14
- color: #57606a;
15
- }
16
-
17
- .guide-requirements {
18
- background: #fff8e6;
19
- border-left: 4px solid #d4a72c;
20
- border-radius: 0 6px 6px 0;
21
- padding: 0.75rem 1rem;
22
- margin: 0 0 1.25rem;
23
- font-size: 0.95rem;
24
- }
25
-
26
- .guide-nav {
27
- background: #f6f8fa;
28
- border: 1px solid #d0d7de;
29
- border-left: 4px solid #0969da;
30
- border-radius: 8px;
31
- padding: 1rem 1.25rem;
32
- margin: 0 0 1.5rem;
33
- }
34
-
35
- .guide-nav-title {
36
- margin: 0 0 0.85rem;
37
- padding-bottom: 0.65rem;
38
- border-bottom: 1px solid #d8dee4;
39
- font-size: 0.95rem;
40
- font-weight: 600;
41
- color: #24292f;
42
- }
43
-
44
- .guide-nav-grid {
45
- display: grid;
46
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
47
- gap: 0.25rem 1rem;
48
- margin: 0;
49
- padding: 0;
50
- list-style: none;
51
- }
52
-
53
- .guide-nav-grid li {
54
- margin: 0;
55
- }
3
+ Steps to install, configure, and use this library in an Angular application.
56
4
 
57
- .guide-nav-grid a {
58
- display: block;
59
- padding: 0.4rem 0.5rem;
60
- color: #0969da;
61
- text-decoration: none;
62
- font-size: 0.9rem;
63
- border-radius: 4px;
64
- transition: background 0.15s ease, color 0.15s ease;
65
- }
5
+ <p style="font-size: 1.15rem; line-height: 1.6;"><strong>Requirements:</strong> Angular ^20.3.0, a Firebase project with Firestore enabled.</p>
66
6
 
67
- .guide-nav-grid a:hover {
68
- color: #0550ae;
69
- background: #eef6ff;
70
- }
7
+ <div style="background: #f6f8fa; border: 1px solid #d0d7de; border-left: 4px solid #0969da; border-radius: 8px; padding: 1rem 1.25rem; margin: 1rem 0; font-size: 1rem; line-height: 1.6;">
71
8
 
72
- .guide-nav-sub {
73
- display: grid;
74
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
75
- gap: 0.2rem 1rem;
76
- margin: 0.75rem 0 0;
77
- padding: 0.75rem 0 0;
78
- border-top: 1px solid #d8dee4;
79
- list-style: none;
80
- }
9
+ <p style="font-size: 1.05rem; font-weight: 600; margin: 0 0 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid #d8dee4;">On this page</p>
81
10
 
82
- .guide-nav-sub li {
83
- margin: 0;
84
- }
11
+ <ul style="margin: 0; padding-left: 1.25rem;">
12
+ <li style="margin-bottom: 0.35rem;"><a href="#1-install" style="color: #0969da; text-decoration: none;">1. Install</a></li>
13
+ <li style="margin-bottom: 0.35rem;"><a href="#2-firebase-configuration" style="color: #0969da; text-decoration: none;">2. Firebase configuration</a></li>
14
+ <li style="margin-bottom: 0.35rem;"><a href="#3-register-the-library-in-your-app" style="color: #0969da; text-decoration: none;">3. Register the library in your app</a></li>
15
+ <li style="margin-bottom: 0.35rem;"><a href="#4-usage" style="color: #0969da; text-decoration: none;">4. Usage</a></li>
16
+ <li style="margin-bottom: 0.35rem;"><a href="#5-checklist" style="color: #0969da; text-decoration: none;">5. Checklist</a></li>
17
+ <li style="margin-bottom: 0.35rem;"><a href="#exports-reference" style="color: #0969da; text-decoration: none;">Exports reference</a></li>
18
+ </ul>
85
19
 
86
- .guide-nav-sub a {
87
- display: block;
88
- padding: 0.35rem 0.5rem;
89
- font-size: 0.85rem;
90
- color: #57606a;
91
- text-decoration: none;
92
- border-radius: 4px;
93
- transition: background 0.15s ease, color 0.15s ease;
94
- }
95
-
96
- .guide-nav-sub a:hover {
97
- color: #0969da;
98
- background: #eef6ff;
99
- }
100
-
101
- .guide-section {
102
- scroll-margin-top: 1.5rem;
103
- }
104
- </style>
105
-
106
- <div class="guide-header">
107
-
108
- <p class="guide-intro">Steps to install, configure, and use this library in an Angular application.</p>
109
-
110
- <div class="guide-requirements">
111
- <strong>Requirements:</strong> Angular ^20.3.0, a Firebase project with Firestore enabled.
112
- </div>
20
+ <p style="font-size: 0.95rem; font-weight: 600; margin: 1rem 0 0.5rem; color: #57606a;">Usage sections</p>
113
21
 
114
- <nav class="guide-nav" aria-label="Table of contents">
115
- <p class="guide-nav-title">On this page</p>
116
- <ul class="guide-nav-grid">
117
- <li><a href="#install">1. Install</a></li>
118
- <li><a href="#firebase-configuration">2. Firebase configuration</a></li>
119
- <li><a href="#register-the-library">3. Register the library</a></li>
120
- <li><a href="#usage">4. Usage</a></li>
121
- <li><a href="#checklist">5. Checklist</a></li>
122
- <li><a href="#exports-reference">Exports reference</a></li>
123
- </ul>
124
- <ul class="guide-nav-sub">
125
- <li><a href="#response-shape">↳ Response shape</a></li>
126
- <li><a href="#listen-to-a-document">↳ Listen to a document</a></li>
127
- <li><a href="#listen-to-a-collection">↳ Listen to a collection</a></li>
128
- <li><a href="#path-helpers">↳ Path helpers</a></li>
129
- </ul>
130
- </nav>
22
+ <ul style="margin: 0; padding-left: 1.25rem;">
23
+ <li style="margin-bottom: 0.35rem;"><a href="#response-shape" style="color: #0969da; text-decoration: none;">Response shape</a></li>
24
+ <li style="margin-bottom: 0.35rem;"><a href="#listen-to-a-document-real-time" style="color: #0969da; text-decoration: none;">Listen to a document (real-time)</a></li>
25
+ <li style="margin-bottom: 0.35rem;"><a href="#listen-to-a-collection-real-time" style="color: #0969da; text-decoration: none;">Listen to a collection (real-time)</a></li>
26
+ <li style="margin-bottom: 0.35rem;"><a href="#path-helpers" style="color: #0969da; text-decoration: none;">Path helpers</a></li>
27
+ </ul>
131
28
 
132
29
  </div>
133
30
 
134
31
  ---
135
32
 
136
- <a id="install" class="guide-section"></a>
33
+ <a id="1-install"></a>
137
34
 
138
35
  ## 1. Install
139
36
 
@@ -145,7 +42,7 @@ npm install ngx-firestore-wrapper-kit
145
42
 
146
43
  ---
147
44
 
148
- <a id="firebase-configuration" class="guide-section"></a>
45
+ <a id="2-firebase-configuration"></a>
149
46
 
150
47
  ## 2. Firebase configuration
151
48
 
@@ -171,7 +68,7 @@ Get these values from [Firebase Console](https://console.firebase.google.com/)
171
68
 
172
69
  ---
173
70
 
174
- <a id="register-the-library" class="guide-section"></a>
71
+ <a id="3-register-the-library-in-your-app"></a>
175
72
 
176
73
  ## 3. Register the library in your app
177
74
 
@@ -191,7 +88,7 @@ export const appConfig: ApplicationConfig = {
191
88
 
192
89
  ---
193
90
 
194
- <a id="usage" class="guide-section"></a>
91
+ <a id="4-usage"></a>
195
92
 
196
93
  ## 4. Usage
197
94
 
@@ -200,14 +97,13 @@ Import from the package:
200
97
  ```typescript
201
98
  import {
202
99
  FirestoreDataService,
203
- FirestorePaths,
204
100
  FirestoreResponse
205
101
  } from 'ngx-firestore-wrapper-kit';
206
102
  ```
207
103
 
208
104
  Inject `FirestoreDataService` where you need Firestore data. It is `providedIn: 'root'`, so no extra providers are required.
209
105
 
210
- <a id="response-shape" class="guide-section"></a>
106
+ <a id="response-shape"></a>
211
107
 
212
108
  ### Response shape
213
109
 
@@ -225,14 +121,14 @@ Always check `success` before using `data`.
225
121
 
226
122
  ---
227
123
 
228
- <a id="listen-to-a-document" class="guide-section"></a>
124
+ <a id="listen-to-a-document-real-time"></a>
229
125
 
230
126
  ### Listen to a document (real-time)
231
127
 
232
128
  ```typescript
233
129
  import { inject, OnDestroy, OnInit } from '@angular/core';
234
130
  import { Subscription } from 'rxjs';
235
- import { FirestoreDataService, FirestorePaths, FirestoreResponse } from 'ngx-firestore-wrapper-kit';
131
+ import { FirestoreDataService, FirestoreResponse } from 'ngx-firestore-wrapper-kit';
236
132
 
237
133
  interface BatchJob {
238
134
  status: string;
@@ -246,7 +142,8 @@ export class BatchJobComponent implements OnInit, OnDestroy {
246
142
  response: FirestoreResponse<BatchJob> | null = null;
247
143
 
248
144
  ngOnInit(): void {
249
- const path = FirestorePaths.getBatchJobDocumentPath('client-001', 'job-001');
145
+ // collection / collection-001 (document) / subCollection / sub-collection-001 (document)
146
+ const path = ['collection', 'collection-001', 'subCollection', 'sub-collection-001'];
250
147
 
251
148
  this.sub = this.firestoreData
252
149
  .listenToDocument<BatchJob>(path)
@@ -261,14 +158,14 @@ export class BatchJobComponent implements OnInit, OnDestroy {
261
158
 
262
159
  ---
263
160
 
264
- <a id="listen-to-a-collection" class="guide-section"></a>
161
+ <a id="listen-to-a-collection-real-time"></a>
265
162
 
266
163
  ### Listen to a collection (real-time)
267
164
 
268
165
  ```typescript
269
166
  import { inject, OnDestroy, OnInit } from '@angular/core';
270
167
  import { Subscription } from 'rxjs';
271
- import { FirestoreDataService, FirestorePaths, FirestoreResponse } from 'ngx-firestore-wrapper-kit';
168
+ import { FirestoreDataService, FirestoreResponse } from 'ngx-firestore-wrapper-kit';
272
169
 
273
170
  interface BatchJob {
274
171
  status: string;
@@ -282,7 +179,8 @@ export class BatchJobListComponent implements OnInit, OnDestroy {
282
179
  response: FirestoreResponse<BatchJob[]> | null = null;
283
180
 
284
181
  ngOnInit(): void {
285
- const path = FirestorePaths.getBatchJobCollectionPath('client-001');
182
+ // collection / collection-001 (document) / subCollection
183
+ const path = ['collection', 'collection-001', 'subCollection'];
286
184
 
287
185
  this.sub = this.firestoreData
288
186
  .listenToCollection<BatchJob>(path)
@@ -297,18 +195,18 @@ export class BatchJobListComponent implements OnInit, OnDestroy {
297
195
 
298
196
  ---
299
197
 
300
- <a id="path-helpers" class="guide-section"></a>
198
+ <a id="path-helpers"></a>
301
199
 
302
200
  ### Path helpers
303
201
 
304
202
  Build paths as **string arrays** — alternating collection and document IDs:
305
203
 
306
204
  ```typescript
307
- // Document: collection/{collectionId}/childCollection/{childCollectionDocumentId}
308
- const documentPath = ['collection', 'collection-001', 'childCollection', 'child-collection-001'];
205
+ // Document: collection / {collectionId} (document) / subCollection / {subCollectionId} (document)
206
+ const documentPath = ['collection', 'collection-001', 'subCollection', 'sub-collection-001'];
309
207
 
310
- // Collection: collection/{collectionId}/childCollection
311
- const collectionPath = ['collection', 'collection-001', 'childCollection'];
208
+ // Collection: collection / {collectionId} (document) / subCollection
209
+ const collectionPath = ['collection', 'collection-001', 'subCollection'];
312
210
  ```
313
211
 
314
212
  **Example with the service:**
@@ -321,7 +219,7 @@ this.firestoreData
321
219
 
322
220
  ---
323
221
 
324
- <a id="checklist" class="guide-section"></a>
222
+ <a id="5-checklist"></a>
325
223
 
326
224
  ## 5. Checklist
327
225
 
@@ -334,7 +232,7 @@ this.firestoreData
334
232
 
335
233
  ---
336
234
 
337
- <a id="exports-reference" class="guide-section"></a>
235
+ <a id="exports-reference"></a>
338
236
 
339
237
  ## Exports reference
340
238
 
@@ -342,5 +240,4 @@ this.firestoreData
342
240
  |--------|-----|
343
241
  | `provideFirestoreKit(config)` | Bootstrap Firebase + Firestore in the app |
344
242
  | `FirestoreDataService` | `listenToDocument()`, `listenToCollection()` |
345
- | `FirestorePaths` | Static path segment helpers |
346
243
  | `FirestoreResponse<T>` | Type for listener responses |
@@ -65,26 +65,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.23", ngImpo
65
65
  }]
66
66
  }] });
67
67
 
68
- class FirestorePaths {
69
- static CLIENTS_COLLECTION = 'clients';
70
- static BATCH_JOBS_COLLECTION = 'batchJobs';
71
- static getBatchJobDocumentPath(clientId, batchJobDocumentId) {
72
- return [
73
- FirestorePaths.CLIENTS_COLLECTION,
74
- clientId,
75
- FirestorePaths.BATCH_JOBS_COLLECTION,
76
- batchJobDocumentId
77
- ];
78
- }
79
- static getBatchJobCollectionPath(clientId) {
80
- return [
81
- FirestorePaths.CLIENTS_COLLECTION,
82
- clientId,
83
- FirestorePaths.BATCH_JOBS_COLLECTION
84
- ];
85
- }
86
- }
87
-
88
68
  /**
89
69
  * Custom library provider that configures and initializes Firebase and Firestore
90
70
  * behind the scenes for the consuming application.
@@ -105,5 +85,5 @@ function provideFirestoreKit(firebaseConfig) {
105
85
  * Generated bundle index. Do not edit.
106
86
  */
107
87
 
108
- export { FirestoreDataService, FirestorePaths, NgxFirestoreKit, provideFirestoreKit };
88
+ export { FirestoreDataService, NgxFirestoreKit, provideFirestoreKit };
109
89
  //# sourceMappingURL=ngx-firestore-wrapper-kit.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ngx-firestore-wrapper-kit.mjs","sources":["../../../projects/ngx-firestore-kit/src/lib/ngx-firestore-kit.ts","../../../projects/ngx-firestore-kit/src/lib/service/firestore-data.service.ts","../../../projects/ngx-firestore-kit/src/lib/service/firestore-paths.ts","../../../projects/ngx-firestore-kit/src/lib/service/firestore-providers.ts","../../../projects/ngx-firestore-kit/src/public-api.ts","../../../projects/ngx-firestore-kit/src/ngx-firestore-wrapper-kit.ts"],"sourcesContent":["import { Component } from '@angular/core';\r\n\r\n@Component({\r\n selector: 'lib-ngx-firestore-kit',\r\n imports: [],\r\n template: `\r\n <p>\r\n ngx-firestore-kit works!\r\n </p>\r\n `,\r\n styles: ``,\r\n})\r\nexport class NgxFirestoreKit {\r\n\r\n}\r\n","import { Injectable, Injector, inject, runInInjectionContext } from '@angular/core';\r\nimport { Firestore, collection, collectionChanges, doc, docData } from '@angular/fire/firestore';\r\nimport { Observable, of } from 'rxjs';\r\nimport { catchError, filter, map } from 'rxjs/operators';\r\n\r\nexport interface FirestoreResponse<T> {\r\n success: boolean;\r\n data: any;\r\n error: unknown;\r\n}\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\n\r\nexport class FirestoreDataService {\r\n\r\n private readonly firestore = inject(Firestore);\r\n private readonly injector = inject(Injector);\r\n\r\n /**\r\n * Listen realtime document changes\r\n */\r\n public listenToDocument<T>(pathSegments: string[]): Observable<FirestoreResponse<T>> {\r\n const documentRef = doc(this.firestore, pathSegments[0], ...pathSegments.slice(1));\r\n return runInInjectionContext(this.injector, () => docData(documentRef)).pipe(\r\n // Cast the response to the expected type\r\n filter((response) => response != null),\r\n // Return the response\r\n map((response) => ({ success: true, data: response, error: null })),\r\n // Handle errors\r\n catchError((error: unknown) => {\r\n console.error('[Firestore Document Listener Error]', error);\r\n return of({ success: false, data: null, error });\r\n })\r\n\r\n );\r\n }\r\n\r\n /**\r\n * Listen realtime collection changes\r\n */\r\n public listenToCollection<T>(collectionPath: string[]): Observable<FirestoreResponse<T[]>> {\r\n const collectionRef = collection(this.firestore, collectionPath[0], ...collectionPath.slice(1));\r\n return runInInjectionContext(this.injector, () => collectionChanges(collectionRef)).pipe(\r\n // Cast the response to the expected type\r\n map((response) => ({ success: true, data: response, error: null })),\r\n // Handle errors\r\n catchError((error: unknown) => {\r\n console.error('[Firestore Collection Listener Error]', error);\r\n return of({ success: false, data: null, error });\r\n })\r\n );\r\n }\r\n}","export class FirestorePaths {\r\n\r\n public static readonly CLIENTS_COLLECTION = 'clients';\r\n public static readonly BATCH_JOBS_COLLECTION = 'batchJobs';\r\n\r\n public static getBatchJobDocumentPath(clientId: string, batchJobDocumentId: string): string[] {\r\n return [\r\n FirestorePaths.CLIENTS_COLLECTION,\r\n clientId,\r\n FirestorePaths.BATCH_JOBS_COLLECTION,\r\n batchJobDocumentId\r\n ];\r\n }\r\n\r\n public static getBatchJobCollectionPath(clientId: string): string[] {\r\n return [\r\n FirestorePaths.CLIENTS_COLLECTION,\r\n clientId,\r\n FirestorePaths.BATCH_JOBS_COLLECTION\r\n ];\r\n }\r\n\r\n}\r\n","import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\r\nimport { initializeApp, provideFirebaseApp } from '@angular/fire/app';\r\nimport { getFirestore, provideFirestore } from '@angular/fire/firestore';\r\n\r\n/**\r\n * Custom library provider that configures and initializes Firebase and Firestore \r\n * behind the scenes for the consuming application.\r\n */\r\nexport function provideFirestoreKit(firebaseConfig: any): EnvironmentProviders {\r\n return makeEnvironmentProviders([\r\n // The library handles the Angular Fire initialization boilerplate internally\r\n provideFirebaseApp(() => initializeApp(firebaseConfig)),\r\n provideFirestore(() => getFirestore())\r\n ]);\r\n}","/*\r\n * Public API Surface of ngx-firestore-kit\r\n */\r\n\r\nexport * from './lib/ngx-firestore-kit';\r\nexport * from './lib/service/firestore-data.service';\r\nexport * from './lib/service/firestore-paths';\r\nexport * from './lib/service/firestore-providers';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MAYa,eAAe,CAAA;wGAAf,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAf,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,eAAe,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,uBAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,EAPhB,CAAA;;;;AAIT,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA;;4FAGU,eAAe,EAAA,UAAA,EAAA,CAAA;kBAV3B,SAAS;+BACE,uBAAuB,EAAA,OAAA,EACxB,EAAE,EAAA,QAAA,EACD,CAAA;;;;AAIT,EAAA,CAAA,EAAA;;;MCMU,oBAAoB,CAAA;AAEZ,IAAA,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;AAC7B,IAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAE5C;;AAEG;AACI,IAAA,gBAAgB,CAAI,YAAsB,EAAA;QAC7C,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,YA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AC,CAAC,CACL;IACL;wGAtCS,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAApB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,oBAAoB,cAHjB,MAAM,EAAA,CAAA;;4FAGT,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBAJhC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,UAAU,EAAE;AACf,iBAAA;;;MCbY,cAAc,CAAA;AAEhB,IAAA,OAAgB,kBAAkB,GAAG,SAAS;AAC9C,IAAA,OAAgB,qBAAqB,GAAG,WAAW;AAEnD,IAAA,OAAO,uBAAuB,CAAC,QAAgB,EAAE,kBAA0B,EAAA;QAC9E,OAAO;AACH,YAAA,cAAc,CAAC,kBAAkB;YACjC,QAAQ;AACR,YAAA,cAAc,CAAC,qBAAqB;YACpC;SACH;IACL;IAEO,OAAO,yBAAyB,CAAC,QAAgB,EAAA;QACpD,OAAO;AACH,YAAA,cAAc,CAAC,kBAAkB;YACjC,QAAQ;AACR,YAAA,cAAc,CAAC;SAClB;IACL;;;AChBJ;;;AAGG;AACG,SAAU,mBAAmB,CAAC,cAAmB,EAAA;AACnD,IAAA,OAAO,wBAAwB,CAAC;;QAE5B,kBAAkB,CAAC,MAAM,aAAa,CAAC,cAAc,CAAC,CAAC;AACvD,QAAA,gBAAgB,CAAC,MAAM,YAAY,EAAE;AACxC,KAAA,CAAC;AACN;;ACdA;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"ngx-firestore-wrapper-kit.mjs","sources":["../../../projects/ngx-firestore-kit/src/lib/ngx-firestore-kit.ts","../../../projects/ngx-firestore-kit/src/lib/service/firestore-data.service.ts","../../../projects/ngx-firestore-kit/src/lib/service/firestore-providers.ts","../../../projects/ngx-firestore-kit/src/public-api.ts","../../../projects/ngx-firestore-kit/src/ngx-firestore-wrapper-kit.ts"],"sourcesContent":["import { Component } from '@angular/core';\r\n\r\n@Component({\r\n selector: 'lib-ngx-firestore-kit',\r\n imports: [],\r\n template: `\r\n <p>\r\n ngx-firestore-kit works!\r\n </p>\r\n `,\r\n styles: ``,\r\n})\r\nexport class NgxFirestoreKit {\r\n\r\n}\r\n","import { Injectable, Injector, inject, runInInjectionContext } from '@angular/core';\r\nimport { Firestore, collection, collectionChanges, doc, docData } from '@angular/fire/firestore';\r\nimport { Observable, of } from 'rxjs';\r\nimport { catchError, filter, map } from 'rxjs/operators';\r\n\r\nexport interface FirestoreResponse<T> {\r\n success: boolean;\r\n data: any;\r\n error: unknown;\r\n}\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\n\r\nexport class FirestoreDataService {\r\n\r\n private readonly firestore = inject(Firestore);\r\n private readonly injector = inject(Injector);\r\n\r\n /**\r\n * Listen realtime document changes\r\n */\r\n public listenToDocument<T>(pathSegments: string[]): Observable<FirestoreResponse<T>> {\r\n const documentRef = doc(this.firestore, pathSegments[0], ...pathSegments.slice(1));\r\n return runInInjectionContext(this.injector, () => docData(documentRef)).pipe(\r\n // Cast the response to the expected type\r\n filter((response) => response != null),\r\n // Return the response\r\n map((response) => ({ success: true, data: response, error: null })),\r\n // Handle errors\r\n catchError((error: unknown) => {\r\n console.error('[Firestore Document Listener Error]', error);\r\n return of({ success: false, data: null, error });\r\n })\r\n\r\n );\r\n }\r\n\r\n /**\r\n * Listen realtime collection changes\r\n */\r\n public listenToCollection<T>(collectionPath: string[]): Observable<FirestoreResponse<T[]>> {\r\n const collectionRef = collection(this.firestore, collectionPath[0], ...collectionPath.slice(1));\r\n return runInInjectionContext(this.injector, () => collectionChanges(collectionRef)).pipe(\r\n // Cast the response to the expected type\r\n map((response) => ({ success: true, data: response, error: null })),\r\n // Handle errors\r\n catchError((error: unknown) => {\r\n console.error('[Firestore Collection Listener Error]', error);\r\n return of({ success: false, data: null, error });\r\n })\r\n );\r\n }\r\n}","import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\r\nimport { initializeApp, provideFirebaseApp } from '@angular/fire/app';\r\nimport { getFirestore, provideFirestore } from '@angular/fire/firestore';\r\n\r\n/**\r\n * Custom library provider that configures and initializes Firebase and Firestore \r\n * behind the scenes for the consuming application.\r\n */\r\nexport function provideFirestoreKit(firebaseConfig: any): EnvironmentProviders {\r\n return makeEnvironmentProviders([\r\n // The library handles the Angular Fire initialization boilerplate internally\r\n provideFirebaseApp(() => initializeApp(firebaseConfig)),\r\n provideFirestore(() => getFirestore())\r\n ]);\r\n}","/*\r\n * Public API Surface of ngx-firestore-kit\r\n */\r\n\r\nexport * from './lib/ngx-firestore-kit';\r\nexport * from './lib/service/firestore-data.service';\r\nexport * from './lib/service/firestore-providers';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MAYa,eAAe,CAAA;wGAAf,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAf,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,eAAe,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,uBAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,EAPhB,CAAA;;;;AAIT,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA;;4FAGU,eAAe,EAAA,UAAA,EAAA,CAAA;kBAV3B,SAAS;+BACE,uBAAuB,EAAA,OAAA,EACxB,EAAE,EAAA,QAAA,EACD,CAAA;;;;AAIT,EAAA,CAAA,EAAA;;;MCMU,oBAAoB,CAAA;AAEZ,IAAA,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I,EAAE,CAAC,CAAC;;AAEnE,QAAA,UAAU,CAAC,CAAC,KAAc,KAAI;AAC1B,YAAA,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC;AAC7D,YAAA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACpD,CAAC,CAAC,CACL;IACL;wGAtCS,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAApB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,oBAAoB,cAHjB,MAAM,EAAA,CAAA;;4FAGT,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBAJhC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,UAAU,EAAE;AACf,iBAAA;;;ACTD;;;AAGG;AACG,SAAU,mBAAmB,CAAC,cAAmB,EAAA;AACnD,IAAA,OAAO,wBAAwB,CAAC;;QAE5B,kBAAkB,CAAC,MAAM,aAAa,CAAC,cAAc,CAAC,CAAC;AACvD,QAAA,gBAAgB,CAAC,MAAM,YAAY,EAAE;AACxC,KAAA,CAAC;AACN;;ACdA;;AAEG;;ACFH;;AAEG;;;;"}
package/index.d.ts CHANGED
@@ -27,18 +27,11 @@ declare class FirestoreDataService {
27
27
  static ɵprov: i0.ɵɵInjectableDeclaration<FirestoreDataService>;
28
28
  }
29
29
 
30
- declare class FirestorePaths {
31
- static readonly CLIENTS_COLLECTION = "clients";
32
- static readonly BATCH_JOBS_COLLECTION = "batchJobs";
33
- static getBatchJobDocumentPath(clientId: string, batchJobDocumentId: string): string[];
34
- static getBatchJobCollectionPath(clientId: string): string[];
35
- }
36
-
37
30
  /**
38
31
  * Custom library provider that configures and initializes Firebase and Firestore
39
32
  * behind the scenes for the consuming application.
40
33
  */
41
34
  declare function provideFirestoreKit(firebaseConfig: any): EnvironmentProviders;
42
35
 
43
- export { FirestoreDataService, FirestorePaths, NgxFirestoreKit, provideFirestoreKit };
36
+ export { FirestoreDataService, NgxFirestoreKit, provideFirestoreKit };
44
37
  export type { FirestoreResponse };
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "ngx-firestore-wrapper-kit",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^20.3.0",
6
- "@angular/core": "^20.3.0"
6
+ "@angular/core": "^20.3.0",
7
+ "@angular/fire": "^20.0.1",
8
+ "firebase": "^11.10.0"
7
9
  },
8
10
  "dependencies": {
9
11
  "tslib": "^2.3.0"