@nx-ddd/firestore-angular-adapter 19.84.0 → 19.85.0

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.
@@ -124,4 +124,3 @@ function provideFirestoreAdapter() {
124
124
  */
125
125
 
126
126
  export { AngularFirestoreAdapter, provideAngularFirestoreAdapter, provideFirestoreAdapter, unwrapCollectionLike, wrapCollectionLike, wrapDocumentReference };
127
- //# sourceMappingURL=nx-ddd-firestore-angular-adapter.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx-ddd/firestore-angular-adapter",
3
- "version": "19.84.0",
3
+ "version": "19.85.0",
4
4
  "homepage": "https://github.com/xx-machina/plaform/tree/main/packages/@nx-ddd/firestore-angular-adapter",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,7 +9,7 @@
9
9
  "peerDependencies": {
10
10
  "@angular/core": "20.0.5",
11
11
  "@angular/fire": "20.0.2",
12
- "@nx-ddd/firestore": "19.84.0",
12
+ "@nx-ddd/firestore": "19.85.0",
13
13
  "dayjs": "1.11.13",
14
14
  "rxjs": "^7.0.0",
15
15
  "firebase": "^10.7.0"
@@ -49,4 +49,3 @@ declare function provideAngularFirestoreAdapter(): Provider;
49
49
  declare function provideFirestoreAdapter(): Provider;
50
50
 
51
51
  export { AngularFirestoreAdapter, provideAngularFirestoreAdapter, provideFirestoreAdapter, unwrapCollectionLike, wrapCollectionLike, wrapDocumentReference };
52
- //# sourceMappingURL=nx-ddd-firestore-angular-adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nx-ddd-firestore-angular-adapter.mjs","sources":["../../../../../packages/@nx-ddd/firestore-angular-adapter/src/lib/angular-firestore.adapter.ts","../../../../../packages/@nx-ddd/firestore-angular-adapter/src/nx-ddd-firestore-angular-adapter.ts"],"sourcesContent":["import { inject, Injectable, Provider } from '@angular/core';\nimport { \n doc, collection, collectionGroup,\n Timestamp, setDoc, getDoc, deleteDoc, getDocs, \n onSnapshot, updateDoc, Firestore, runTransaction, writeBatch,\n limit, orderBy, query, where, QuerySnapshot, FieldPath, documentId, FieldValue, serverTimestamp,\n getCountFromServer\n} from '@angular/fire/firestore';\nimport {\n FirestoreAdapter,\n QueryFn as _QueryFn,\n WhereFilterOp,\n provideFirestoreAdapter as _provideFirestoreAdapter,\n} from '@nx-ddd/firestore';\nimport {\n DocumentSnapshot,\n CollectionReference as _CollectionReference,\n CollectionGroup as _CollectionGroup,\n Query as _Query,\n DocumentData,\n DocumentReference,\n} from '@nx-ddd/firestore';\nimport dayjs from 'dayjs';\nimport { Observable, map, tap, filter } from 'rxjs';\nimport type firestore from 'firebase/firestore';\n\ntype CollectionReference<\n AppModelType = DocumentData,\n DbModelType extends DocumentData = DocumentData,\n> = _CollectionReference<AppModelType, DbModelType, firestore.CollectionReference<AppModelType, DbModelType>>;\n\ntype CollectionGroup<\n AppModelType = DocumentData,\n DbModelType extends DocumentData = DocumentData\n> = _CollectionGroup<AppModelType, DbModelType, firestore.Query<AppModelType, DbModelType>>;\n\ntype Query<\n AppModelType = DocumentData,\n DbModelType extends DocumentData = DocumentData\n> = _Query<AppModelType, DbModelType, firestore.Query<AppModelType, DbModelType>>;\n\ntype QueryFn<\n AppModelType = DocumentData,\n DbModelType extends DocumentData = DocumentData\n> = _QueryFn<AppModelType, DbModelType, firestore.QueryConstraint>\n\ntype Origin<\n AppModelType = DocumentData,\n DbModelType extends DocumentData = DocumentData,\n> = firestore.CollectionReference<AppModelType, DbModelType>\n | firestore.Query<AppModelType, DbModelType>;\n\ntype CollectionLike<\n AppModelType = DocumentData,\n DbModelType extends DocumentData = DocumentData,\n> = CollectionReference<AppModelType, DbModelType> \n | CollectionGroup<AppModelType, DbModelType>\n | Query<AppModelType, DbModelType>;\n\n\ntype InferCollectionLike<O extends Origin> = \n O extends firestore.CollectionReference<infer A, infer B> ? CollectionReference<A, B> :\n O extends firestore.Query<infer A, infer B> ? Query<A, B> :\n never;\n\n\nfunction asObservable<T = unknown>(\n ref: Parameters<typeof onSnapshot>[0],\n _onSnapshot: typeof onSnapshot,\n): Observable<QuerySnapshot<T>> {\n return new Observable<QuerySnapshot<T>>((observer) => _onSnapshot(\n ref, \n (value: any) => observer.next(value),\n (error: any) => observer.error(error),\n () => observer.complete()),\n );\n}\n\nexport function wrapDocumentReference<\n AppModelType = DocumentData,\n DbModelType extends DocumentData = DocumentData,\n>(origin: firestore.DocumentReference<AppModelType, DbModelType>): DocumentReference<AppModelType, DbModelType> {\n return {\n __ref: origin,\n exists: () => getDoc(origin).then(snapshot => snapshot.exists()),\n set: (data) => setDoc(origin, data),\n get: () => getDoc(origin),\n update: (data) => updateDoc(origin, data as any),\n delete: () => deleteDoc(origin),\n stateChanges: () => {\n return new Observable<DocumentSnapshot<any>>((observer) => {\n return onSnapshot(origin, value => observer.next(value), error => observer.error(error), () => observer.complete());\n }).pipe(\n filter((snapshot: any) => snapshot.exists()),\n map((snapshot) => ({\n id: snapshot.id,\n ref: snapshot.ref,\n data: () => snapshot.data(),\n get: (fieldPath: string) => snapshot.get(fieldPath),\n })),\n );\n },\n }\n}\n\nexport function wrapCollectionLike<\n O extends Origin,\n>(origin: O): InferCollectionLike<O> {\n return {\n __ref: origin,\n stateChanges: () => asObservable<unknown>(origin, onSnapshot).pipe(\n map((snapshot) => snapshot.docChanges().map(change => ({\n type: change.type, payload: {doc: change.doc},\n }))),\n ),\n get: () => getDocs(origin),\n count: () => getCountFromServer(origin).then(count => count.data().count),\n } as never as InferCollectionLike<O>;\n}\n\nexport function unwrapCollectionLike<\n AppModelType = DocumentData,\n DbModelType extends DocumentData = DocumentData\n>(\n collection: CollectionLike<AppModelType, DbModelType>\n): Origin<AppModelType, DbModelType> {\n return collection.__ref!;\n}\n\n@Injectable()\nexport class AngularFirestoreAdapter extends FirestoreAdapter<dayjs.Dayjs> {\n protected readonly firestore = inject(Firestore);\n\n get FieldValue(): typeof FieldValue & {serverTimestamp: () => FieldValue} {\n return Object.assign(FieldValue, {serverTimestamp});\n }\n\n get Timestamp(): typeof Timestamp {\n return Timestamp; \n }\n\n get FieldPath(): {documentId: () => FieldPath} {\n return {\n documentId: () => documentId(),\n };\n }\n\n protected isTimestamp(v: any): v is Timestamp {\n return v instanceof Timestamp;\n }\n\n protected isFieldValue(v: any): v is FieldValue {\n return v instanceof this.FieldValue;\n }\n \n protected isDate(v: any): v is dayjs.Dayjs {\n return dayjs.isDayjs(v);\n }\n\n doc<\n AppModelType = DocumentData,\n DbModelType extends DocumentData = DocumentData,\n >(path: string): DocumentReference<AppModelType, DbModelType> {\n const docRef = doc(this.firestore, path);\n return wrapDocumentReference(docRef) as DocumentReference<AppModelType, DbModelType>;\n }\n\n collection<\n AppModelType = DocumentData,\n DbModelType extends DocumentData = DocumentData,\n >(path: string): CollectionReference<AppModelType, DbModelType> {\n const ref = collection(this.firestore, path);\n return wrapCollectionLike(ref) as CollectionReference<AppModelType, DbModelType>;\n }\n\n collectionGroup<\n AppModelType = DocumentData,\n DbModelType extends DocumentData = DocumentData,\n >(collectionId: string): CollectionGroup<AppModelType, DbModelType> {\n const ref = collectionGroup(this.firestore, collectionId);\n return wrapCollectionLike(ref) as CollectionGroup<AppModelType, DbModelType>;\n }\n\n query<\n AppModelType = DocumentData,\n DbModelType extends DocumentData = DocumentData,\n >(\n collection: CollectionReference<AppModelType, DbModelType>,\n ...queryFnArray: QueryFn[]\n ): Query<AppModelType, DbModelType> {\n const ref = unwrapCollectionLike(collection) as firestore.Query<DocumentData, DbModelType>;\n const _query = query(ref, ...queryFnArray.map(queryFn => queryFn()));\n return wrapCollectionLike(_query) as Query<AppModelType, DbModelType>;\n }\n\n where<Data>(fieldPath: string, opStr: WhereFilterOp, value: unknown): QueryFn<Data> {\n return () => where(fieldPath, opStr, value);\n }\n\n orderBy<Data>(key: string, order: 'asc' | 'desc' = 'asc'): QueryFn<Data> {\n return () => orderBy(key, order);\n }\n\n limit<Data>(n: number): QueryFn<Data> {\n return () => limit(n);\n }\n\n runTransaction(fn: Parameters<typeof runTransaction>[1]) {\n return runTransaction(this.firestore, fn);\n }\n\n batch() {\n const batch = writeBatch(this.firestore);\n const wrapBatch = (_batch: firestore.WriteBatch) => ({\n create: (ref: any, data: any) => wrapBatch(_batch.set(ref, data)),\n set: (ref: any, data: any) => wrapBatch(_batch.set(ref, data)),\n update: (ref: any, data: any) => wrapBatch(_batch.update(ref, data)),\n delete: (ref: any) => wrapBatch(_batch.delete(ref)),\n commit: () => _batch.commit(),\n })\n return wrapBatch(batch);\n }\n}\n\n\nexport function provideAngularFirestoreAdapter(): Provider {\n return { provide: FirestoreAdapter, useClass: AngularFirestoreAdapter };\n}\n\nexport function provideFirestoreAdapter(): Provider {\n return _provideFirestoreAdapter(AngularFirestoreAdapter);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["_provideFirestoreAdapter"],"mappings":";;;;;;;AAkEA,SAAS,YAAY,CACnB,GAAqC,EACrC,WAA8B,EAAA;IAE9B,OAAO,IAAI,UAAU,CAAmB,CAAC,QAAQ,KAAK,WAAW,CAC/D,GAAG,EACH,CAAC,KAAU,KAAK,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EACpC,CAAC,KAAU,KAAK,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EACrC,MAAM,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAC3B;AACH;AAEM,SAAU,qBAAqB,CAGnC,MAA8D,EAAA;IAC9D,OAAO;AACL,QAAA,KAAK,EAAE,MAAM;AACb,QAAA,MAAM,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QAChE,GAAG,EAAE,CAAC,IAAI,KAAK,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;AACnC,QAAA,GAAG,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC;QACzB,MAAM,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,M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,IAAS,KAAK,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACpE,YAAA,MAAM,EAAE,CAAC,GAAQ,KAAK,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACnD,YAAA,MAAM,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE;AAC9B,SAAA,CAAC;AACF,QAAA,OAAO,SAAS,CAAC,KAAK,CAAC;IACzB;8GA3FW,uBAAuB,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;kHAAvB,uBAAuB,EAAA,CAAA,CAAA;;2FAAvB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBADnC;;SAgGe,8BAA8B,GAAA;IAC5C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,uBAAuB,EAAE;AACzE;SAEgB,uBAAuB,GAAA;AACrC,IAAA,OAAOA,yBAAwB,CAAC,uBAAuB,CAAC;AAC1D;;ACvOA;;AAEG;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"nx-ddd-firestore-angular-adapter.d.ts","sources":["../../../../../packages/@nx-ddd/firestore-angular-adapter/src/lib/angular-firestore.adapter.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AA0BA;AAKA;AAKA;AAKA;AAKA;AAMA;AAQA;AAkBA;AA2BA;AAeA;AASA;AAEE;AAEA;;;AAIA;AAIA;;;;;;;;;AA0CA;AAYA;AAIA;;;;AAekB;AACH;AACG;;;;;;AAMnB;AAGD;AAIA;;"}