@hyper-fetch/firebase-admin 7.5.2 → 8.0.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.
- package/.eslintrc.cjs +12 -0
- package/__tests__/features/firestore/admin/constraints.admin.spec.ts +23 -0
- package/__tests__/features/firestore/admin/methods.admin.spec.ts +20 -0
- package/__tests__/features/firestore/admin/sockets.base.spec.ts +17 -0
- package/__tests__/features/firestore/shared/constraints.shared.tests.ts +72 -0
- package/__tests__/features/firestore/shared/methods/add-doc.test.suite.ts +29 -0
- package/__tests__/features/firestore/shared/methods/delete-doc.test.suite.ts +52 -0
- package/__tests__/features/firestore/shared/methods/get-doc.test.suite.ts +60 -0
- package/__tests__/features/firestore/shared/methods/get-docs.test.suite.ts +45 -0
- package/__tests__/features/firestore/shared/methods/on-snapshot.test.suite.ts +290 -0
- package/__tests__/features/firestore/shared/methods/set-doc.test.suite.ts +70 -0
- package/__tests__/features/firestore/shared/methods/update-doc.test.suite.ts +40 -0
- package/__tests__/features/firestore/shared/methods.shared.tests.ts +24 -0
- package/__tests__/features/realtime/admin/constraints.admin.spec.ts +15 -0
- package/__tests__/features/realtime/admin/methods.admin.spec.ts +24 -0
- package/__tests__/features/realtime/admin/sockets.base.spec.ts +15 -0
- package/__tests__/features/realtime/shared/constraints.shared.tests.ts +57 -0
- package/__tests__/features/realtime/shared/methods/get.test.suite.ts +64 -0
- package/__tests__/features/realtime/shared/methods/on-value.test.suite.ts +190 -0
- package/__tests__/features/realtime/shared/methods/push.test.suite.ts +48 -0
- package/__tests__/features/realtime/shared/methods/remove.test.suite.ts +46 -0
- package/__tests__/features/realtime/shared/methods/set.test.suite.ts +70 -0
- package/__tests__/features/realtime/shared/methods/update.test.suite.ts +42 -0
- package/__tests__/features/realtime/shared/methods.shared.tests.ts +25 -0
- package/__tests__/shared/request-events.shared.ts +32 -0
- package/__tests__/tsconfig.json +21 -0
- package/__tests__/utils/database.rules.json +11 -0
- package/__tests__/utils/index.ts +3 -0
- package/__tests__/utils/initialize.firestore.admin.ts +16 -0
- package/__tests__/utils/initialize.realtime.admin.ts +19 -0
- package/__tests__/utils/seed/seed.data.ts +21 -0
- package/__tests__/utils/seed.admin.ts +23 -0
- package/__tests__/vitest.setup.ts +9 -0
- package/dist/adapter/adapter.d.ts +3 -0
- package/dist/adapter/adapter.d.ts.map +1 -0
- package/dist/adapter/adapter.sockets.d.ts +3 -0
- package/dist/adapter/adapter.sockets.d.ts.map +1 -0
- package/dist/adapter/index.d.ts +4 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/types/adapter.base.types.d.ts +11 -0
- package/dist/adapter/types/adapter.base.types.d.ts.map +1 -0
- package/dist/adapter/types/adapter.firestore.types.d.ts +45 -0
- package/dist/adapter/types/adapter.firestore.types.d.ts.map +1 -0
- package/dist/adapter/types/adapter.realtime.types.d.ts +39 -0
- package/dist/adapter/types/adapter.realtime.types.d.ts.map +1 -0
- package/dist/adapter/types/firestore.socket.types.d.ts +17 -0
- package/dist/adapter/types/firestore.socket.types.d.ts.map +1 -0
- package/dist/adapter/types/index.d.ts +6 -0
- package/dist/adapter/types/index.d.ts.map +1 -0
- package/dist/adapter/types/realtime.socket.types.d.ts +12 -0
- package/dist/adapter/types/realtime.socket.types.d.ts.map +1 -0
- package/dist/constraints/constraints.types.d.ts +13 -0
- package/dist/constraints/constraints.types.d.ts.map +1 -0
- package/dist/constraints/firebase.constraints.d.ts +86 -0
- package/dist/constraints/firebase.constraints.d.ts.map +1 -0
- package/dist/constraints/index.d.ts +3 -0
- package/dist/constraints/index.d.ts.map +1 -0
- package/dist/firestore/firestore.methods.d.ts +21 -0
- package/dist/firestore/firestore.methods.d.ts.map +1 -0
- package/dist/firestore/firestore.sockets.d.ts +4 -0
- package/dist/firestore/firestore.sockets.d.ts.map +1 -0
- package/dist/firestore/index.d.ts +4 -0
- package/dist/firestore/index.d.ts.map +1 -0
- package/dist/firestore/utils/constraints.utils.d.ts +5 -0
- package/dist/firestore/utils/constraints.utils.d.ts.map +1 -0
- package/dist/firestore/utils/index.d.ts +4 -0
- package/dist/firestore/utils/index.d.ts.map +1 -0
- package/dist/firestore/utils/ref.utils.d.ts +3 -0
- package/dist/firestore/utils/ref.utils.d.ts.map +1 -0
- package/dist/firestore/utils/result.utils.d.ts +10 -0
- package/dist/firestore/utils/result.utils.d.ts.map +1 -0
- package/dist/index.d.ts +5 -271
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +670 -0
- package/dist/index.mjs.map +1 -0
- package/dist/realtime/index.d.ts +4 -0
- package/dist/realtime/index.d.ts.map +1 -0
- package/dist/realtime/realtime.methods.d.ts +19 -0
- package/dist/realtime/realtime.methods.d.ts.map +1 -0
- package/dist/realtime/realtime.sockets.d.ts +4 -0
- package/dist/realtime/realtime.sockets.d.ts.map +1 -0
- package/dist/realtime/utils/constraints.utils.d.ts +5 -0
- package/dist/realtime/utils/constraints.utils.d.ts.map +1 -0
- package/dist/realtime/utils/index.d.ts +3 -0
- package/dist/realtime/utils/index.d.ts.map +1 -0
- package/dist/realtime/utils/result.utils.d.ts +3 -0
- package/dist/realtime/utils/result.utils.d.ts.map +1 -0
- package/dist/utils/cache.utils.d.ts +11 -0
- package/dist/utils/cache.utils.d.ts.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/misc.d.ts +3 -0
- package/dist/utils/misc.d.ts.map +1 -0
- package/package.json +8 -11
- package/project.json +4 -0
- package/src/adapter/adapter.sockets.ts +1 -1
- package/src/adapter/adapter.ts +13 -14
- package/src/adapter/types/adapter.base.types.ts +4 -4
- package/src/adapter/types/adapter.firestore.types.ts +4 -4
- package/src/adapter/types/adapter.realtime.types.ts +4 -4
- package/src/adapter/types/firestore.socket.types.ts +3 -3
- package/src/adapter/types/realtime.socket.types.ts +3 -3
- package/src/constraints/constraints.types.ts +1 -1
- package/src/constraints/firebase.constraints.ts +1 -1
- package/src/firestore/firestore.methods.ts +4 -4
- package/src/firestore/firestore.sockets.ts +3 -9
- package/src/firestore/utils/constraints.utils.ts +4 -3
- package/src/firestore/utils/ref.utils.ts +1 -1
- package/src/firestore/utils/result.utils.ts +1 -1
- package/src/realtime/realtime.methods.ts +4 -4
- package/src/realtime/realtime.sockets.ts +2 -2
- package/src/realtime/utils/constraints.utils.ts +3 -2
- package/src/realtime/utils/result.utils.ts +1 -1
- package/src/utils/cache.utils.ts +4 -2
- package/tsconfig.json +1 -1
- package/vite.config.ts +45 -0
- package/.eslintrc.json +0 -11
- package/dist/index.js +0 -686
- package/dist/index.js.map +0 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/adapter/types/adapter.firestore.types.ts","../src/adapter/types/adapter.realtime.types.ts","../src/firestore/utils/result.utils.ts","../src/firestore/utils/ref.utils.ts","../src/constraints/firebase.constraints.ts","../src/firestore/utils/constraints.utils.ts","../src/utils/misc.ts","../src/firestore/firestore.sockets.ts","../src/firestore/firestore.methods.ts","../src/realtime/utils/result.utils.ts","../src/realtime/utils/constraints.utils.ts","../src/realtime/realtime.methods.ts","../src/realtime/realtime.sockets.ts","../src/adapter/adapter.sockets.ts","../src/adapter/adapter.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport type { Adapter } from \"@hyper-fetch/core\";\nimport type {\n Unsubscribe as FirestoreUnsubscribe,\n CollectionReference,\n DocumentReference,\n DocumentSnapshot,\n QuerySnapshot,\n} from \"firebase/firestore\";\nimport type { SocketAdapter } from \"@hyper-fetch/sockets\";\n\nimport type {\n FirestoreConstraintsUnion,\n FirestorePermittedMethods,\n PermittedConstraints,\n SharedQueryConstraints,\n} from \"constraints\";\n\nexport type FirestoreSocketAdapterType = SocketAdapter<\n never,\n FirestoreOnSnapshotExtra,\n { groupByChangeType?: boolean } & FirestoreQueryParams\n>;\n\nexport type FirestoreAdapterType =\n | Adapter<\n Record<string, never>,\n \"getDoc\",\n FirestoreStatuses,\n FirestoreExtra,\n FirestoreQueryParams,\n FirestoreQueryParams\n >\n | Adapter<\n Record<string, never>,\n \"getDocs\",\n FirestoreStatuses,\n FirestoreGetDocsExtra,\n FirestoreQueryParams,\n FirestoreQueryParams\n >\n | Adapter<{ merge: boolean }, \"setDoc\", FirestoreStatuses, FirestoreRefOnlyExtra, Record<string, never>, undefined>\n | Adapter<\n Record<string, never>,\n \"updateDoc\" | \"addDoc\" | \"deleteDoc\" | \"setDoc\",\n FirestoreStatuses,\n FirestoreRefOnlyExtra,\n Record<string, never>,\n undefined\n >;\n\nexport type FirestoreQueryParams = {\n constraints?: PermittedConstraints<FirestorePermittedMethods, FirestoreConstraintsUnion | SharedQueryConstraints>[];\n};\n\nexport enum FirestoreMethods {\n addDoc = \"addDoc\",\n getDoc = \"getDoc\",\n getDocs = \"getDocs\",\n setDoc = \"setDoc\",\n updateDoc = \"updateDoc\",\n deleteDoc = \"deleteDoc\",\n}\n\nexport type FirestoreMethodsUnion =\n | FirestoreMethods.addDoc\n | FirestoreMethods.getDoc\n | FirestoreMethods.getDocs\n | FirestoreMethods.setDoc\n | FirestoreMethods.updateDoc\n | FirestoreMethods.deleteDoc;\n\nexport type FirestoreExtra = {\n ref?: DocumentReference;\n snapshot?: DocumentSnapshot;\n};\n\nexport type FirestoreOnSnapshotExtra = {\n ref?: DocumentReference | CollectionReference;\n snapshot?: DocumentSnapshot;\n unsubscribe?: FirestoreUnsubscribe;\n groupedResult?: { added: DocumentSnapshot[]; modified: DocumentSnapshot[]; removed: DocumentSnapshot[] };\n};\n\nexport type FirestoreGetDocsExtra = {\n ref?: CollectionReference;\n snapshot?: QuerySnapshot;\n};\n\nexport type FirestoreRefOnlyExtra = {\n ref?: DocumentReference;\n};\n\nexport type FirestoreStatuses = \"success\" | \"error\" | \"emptyResource\";\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport type { Adapter } from \"@hyper-fetch/core\";\nimport type { DatabaseReference, DataSnapshot } from \"firebase/database\";\nimport type { SocketAdapter } from \"@hyper-fetch/sockets\";\n\nimport type {\n PermittedConstraints,\n RealtimeConstraintsUnion,\n RealtimePermittedMethods,\n SharedQueryConstraints,\n} from \"constraints\";\n\nexport type RealtimeSocketAdapterType = SocketAdapter<\n never,\n RealtimeDbOnValueMethodExtra,\n { onlyOnce?: boolean } & RealtimeDBQueryParams\n>;\n\nexport type RealtimeDbAdapterType =\n | Adapter<\n DefaultRealtimeDBAdapterOptions,\n \"get\",\n RealtimeDBStatuses,\n RealtimeDbGetMethodExtra,\n RealtimeDBQueryParams,\n RealtimeDBQueryParams\n >\n | Adapter<\n DefaultRealtimeDBAdapterOptions,\n \"push\",\n RealtimeDBStatuses,\n RealtimeDbPushMethodExtra,\n Record<string, never>,\n undefined\n >\n | Adapter<\n DefaultRealtimeDBAdapterOptions,\n \"set\" | \"update\" | \"remove\",\n RealtimeDBStatuses,\n RealtimeDbDefaultExtra,\n Record<string, never>,\n undefined\n >;\n\nexport type DefaultRealtimeDBAdapterOptions = {\n priority?: number;\n};\n\nexport enum RealtimeDBMethods {\n set = \"set\",\n push = \"push\",\n update = \"update\",\n get = \"get\",\n remove = \"remove\",\n}\n\nexport type RealtimeDBMethodsUnion =\n | RealtimeDBMethods.set\n | RealtimeDBMethods.push\n | RealtimeDBMethods.update\n | RealtimeDBMethods.get\n | RealtimeDBMethods.remove;\n\nexport type RealtimeDBStatuses = \"success\" | \"error\" | \"emptyResource\";\nexport type RealtimeDbOnValueMethodExtra = {\n ref: DatabaseReference;\n snapshot: DataSnapshot;\n};\n\nexport type RealtimeDbGetMethodExtra = {\n ref: DatabaseReference;\n snapshot: DataSnapshot;\n};\n\nexport type RealtimeDbDefaultExtra = {\n ref: DatabaseReference;\n};\n\nexport type RealtimeDbPushMethodExtra = {\n ref: DatabaseReference;\n key: string;\n};\n\nexport type RealtimeDBQueryParams = {\n constraints?: PermittedConstraints<RealtimePermittedMethods, RealtimeConstraintsUnion | SharedQueryConstraints>[];\n};\n","import type { QuerySnapshot, DocumentData } from \"firebase-admin/firestore\";\n\nexport const getOrderedResultFirestore = (snapshot: QuerySnapshot) => {\n const result: (DocumentData & { __key: string })[] = [];\n snapshot.docs.forEach((d) => {\n result.push({ ...d.data(), __key: d.id });\n });\n return result;\n};\n\nexport const getGroupedResultFirestore = (snapshot: QuerySnapshot) => {\n const groupedResult: { added: DocumentData[]; modified: DocumentData[]; removed: DocumentData[] } = {\n added: [],\n modified: [],\n removed: [],\n };\n snapshot.docChanges().forEach((change) => {\n groupedResult[change.type].push(change.doc.data());\n });\n return [...groupedResult.added, ...groupedResult.modified, ...groupedResult.removed].length > 0\n ? groupedResult\n : null;\n};\n","import type { CollectionReference, DocumentReference, Firestore } from \"firebase-admin/firestore\";\n\nexport const getRef = (db: Firestore, fullUrl: string) => {\n const withoutSurroundingSlashes = fullUrl.replace(/^\\/|\\/$/g, \"\");\n const urlParts = withoutSurroundingSlashes.split(\"/\").map((element, index) => {\n return index % 2 === 0 ? [\"collection\", element] : [\"doc\", element];\n });\n\n return urlParts.reduce(\n (_db, value) => {\n const [method, pathPart] = value;\n if (method === \"doc\" && \"doc\" in _db) {\n return _db.doc(pathPart);\n }\n if (method === \"collection\" && \"collection\" in _db) {\n return _db.collection(pathPart);\n }\n return _db;\n },\n db as unknown as Firestore | CollectionReference | DocumentReference,\n ) as CollectionReference | DocumentReference;\n};\n","import type { OrderByDirection, WhereFilterOp } from \"firebase-admin/firestore\";\n\nexport enum SharedQueryConstraints {\n START_AT = \"startAt\",\n START_AFTER = \"startAfter\",\n END_AT = \"endAt\",\n END_BEFORE = \"endBefore\",\n}\nexport enum RealtimeQueryConstraints {\n ORDER_BY_CHILD = \"orderByChild\",\n ORDER_BY_KEY = \"orderByKey\",\n ORDER_BY_VALUE = \"orderByValue\",\n LIMIT_TO_FIRST = \"limitToFirst\",\n LIMIT_TO_LAST = \"limitToLast\",\n EQUAL_TO = \"equalTo\",\n}\n\nexport enum FirestoreQueryConstraints {\n WHERE = \"where\",\n ORDER_BY = \"orderBy\",\n LIMIT = \"limit\",\n}\n\nexport const $where = (fieldPath: string, opStr: WhereFilterOp, value: any) => {\n return {\n toString: () => `${FirestoreQueryConstraints.WHERE}_${fieldPath}${opStr}${value}`,\n type: FirestoreQueryConstraints.WHERE as const,\n values: [fieldPath, opStr, value],\n };\n};\n\nexport const $orderBy = (fieldPath: string, directionStr?: OrderByDirection) => {\n return {\n toString: () => `${FirestoreQueryConstraints.ORDER_BY}_${fieldPath}_${directionStr || \"\"}`,\n type: FirestoreQueryConstraints.ORDER_BY as const,\n values: [fieldPath, directionStr],\n };\n};\n\nexport const $limit = (num: number) => {\n return {\n toString: () => `${FirestoreQueryConstraints.LIMIT}_${num}`,\n type: FirestoreQueryConstraints.LIMIT as const,\n values: [num],\n };\n};\n\nconst startEndConstraintsImpl = (constraintType: SharedQueryConstraints) => {\n return (...docOrFields: any[]) => {\n if (docOrFields.length === 1 && docOrFields[0].query) {\n return {\n toString: () => `${constraintType}_${docOrFields[0].query?._query?.memoizedTarget?.memoizedCanonicalId}`,\n type: constraintType,\n values: [docOrFields],\n };\n }\n return {\n toString: () => `${constraintType}_${docOrFields}`,\n type: constraintType,\n values: [docOrFields],\n };\n };\n};\n\nexport const $startAt = startEndConstraintsImpl(SharedQueryConstraints.START_AT as const);\nexport const $startAfter = startEndConstraintsImpl(SharedQueryConstraints.START_AFTER as const);\n\nexport const $endAt = startEndConstraintsImpl(SharedQueryConstraints.END_AT as const);\nexport const $endBefore = startEndConstraintsImpl(SharedQueryConstraints.END_BEFORE as const);\n\nexport const $orderByChild = (path: string) => {\n return {\n toString: () => `${RealtimeQueryConstraints.ORDER_BY_CHILD}_${path}`,\n type: RealtimeQueryConstraints.ORDER_BY_CHILD as const,\n values: [path],\n };\n};\n\nexport const $orderByKey = () => {\n return {\n toString: () => `${RealtimeQueryConstraints.ORDER_BY_KEY}`,\n type: RealtimeQueryConstraints.ORDER_BY_KEY as const,\n values: [],\n };\n};\n\nexport const $orderByValue = () => {\n return {\n toString: () => `${RealtimeQueryConstraints.ORDER_BY_VALUE}`,\n type: RealtimeQueryConstraints.ORDER_BY_VALUE as const,\n values: [],\n };\n};\n\nexport const $limitToFirst = (num: number) => {\n return {\n toString: () => `${RealtimeQueryConstraints.LIMIT_TO_FIRST}_${num}`,\n type: RealtimeQueryConstraints.LIMIT_TO_FIRST as const,\n values: [num],\n };\n};\n\nexport const $limitToLast = (num: number) => {\n return {\n toString: () => `${RealtimeQueryConstraints.LIMIT_TO_LAST}_${num}`,\n type: RealtimeQueryConstraints.LIMIT_TO_LAST as const,\n values: [num],\n };\n};\n\nexport const $equalTo = (value: any) => {\n return {\n toString: () => `${RealtimeQueryConstraints.LIMIT_TO_LAST}_${value}`,\n type: RealtimeQueryConstraints.EQUAL_TO as const,\n values: [value],\n };\n};\n","import type { Query } from \"firebase-admin/firestore\";\nimport type { OrderByDirection } from \"firebase/firestore\";\n\nimport type { FirestorePermittedMethods } from \"../../constraints\";\nimport { FirestoreQueryConstraints, SharedQueryConstraints } from \"../../constraints\";\n\nexport const applyFireStoreAdminConstraint = (collectionRef: Query, { type, values }: FirestorePermittedMethods) => {\n switch (type) {\n case FirestoreQueryConstraints.WHERE: {\n const [fieldPath, strOp, value] = values;\n return collectionRef.where(fieldPath, strOp, value);\n }\n case FirestoreQueryConstraints.ORDER_BY: {\n const [field, ord] = values;\n return collectionRef.orderBy(field!, ord as OrderByDirection);\n }\n case FirestoreQueryConstraints.LIMIT: {\n const [limitValue] = values;\n return collectionRef.limit(limitValue);\n }\n case SharedQueryConstraints.START_AT: {\n const [docOrFields] = values;\n return collectionRef.startAt(docOrFields);\n }\n case SharedQueryConstraints.START_AFTER: {\n const [docOrFields] = values;\n return collectionRef.startAfter(docOrFields);\n }\n case SharedQueryConstraints.END_AT: {\n const [docOrFields] = values;\n return collectionRef.endAt(docOrFields);\n }\n case SharedQueryConstraints.END_BEFORE: {\n const [docOrFields] = values;\n return collectionRef.endBefore(docOrFields);\n }\n default:\n throw new Error(`Unknown method ${type}`);\n }\n};\n\nexport const applyFireStoreAdminConstraints = (collectionRef: Query, constraints: FirestorePermittedMethods[]) => {\n return constraints.reduce((collection, constraint) => {\n return applyFireStoreAdminConstraint(collection, constraint);\n }, collectionRef);\n};\n","export const getStatus = (res: any) => {\n // Deliberate == instead of ===\n return (Array.isArray(res) && res.length === 0) || res == null ? \"emptyResource\" : \"success\";\n};\n\nexport const isDocOrQuery = (fullUrl: string): string => {\n const withoutSurroundingSlashes = fullUrl.replace(/^\\/|\\/$/g, \"\");\n const pathElements = withoutSurroundingSlashes.split(\"/\").length;\n return pathElements % 2 === 0 ? \"doc\" : \"query\";\n};\n","import type { DocumentReference, Firestore, Query, QuerySnapshot } from \"firebase-admin/firestore\";\nimport { CollectionReference, DocumentSnapshot } from \"firebase-admin/firestore\";\nimport { SocketAdapter } from \"@hyper-fetch/sockets\";\n\nimport { getGroupedResultFirestore, getOrderedResultFirestore, getRef, applyFireStoreAdminConstraints } from \"./utils\";\nimport type { FirestoreAdminSocketAdapterType } from \"adapter\";\nimport { getStatus } from \"utils\";\n\nexport const firestoreAdminSockets = (database: Firestore) => {\n return (\n new SocketAdapter({\n name: \"firebase-admin-firestore\",\n defaultConnected: true,\n }) as unknown as FirestoreAdminSocketAdapterType\n ).setConnector(({ socket, onReconnect, onListen, onEvent, onError }) => {\n const connect = () => {\n throw new Error(\"Connect function is not implemented for Firestore Admin socket.\");\n };\n\n const disconnect = () => {\n throw new Error(\"Cannot disconnect from Firestore database socket. Use 'app.delete()' instead.\");\n };\n\n const reconnect = () => {\n onReconnect({ disconnect, connect });\n };\n\n const listen: FirestoreAdminSocketAdapterType[\"listen\"] = (listener, callback) => {\n const fullUrl = socket.url + listener.topic;\n const { options } = listener;\n let pathRef: DocumentReference | Query = getRef(database, fullUrl);\n if (pathRef instanceof CollectionReference) {\n pathRef = applyFireStoreAdminConstraints(pathRef, options?.constraints || []);\n }\n let unsubscribe = () => {};\n let unmount = () => {};\n let clearListeners = () => {};\n\n unsubscribe = pathRef.onSnapshot(\n (snapshot) => {\n const getSnapshotData = (s: DocumentSnapshot) => (s.data() ? { ...s.data(), __key: s.id } : null);\n const response =\n snapshot instanceof DocumentSnapshot\n ? getSnapshotData(snapshot)\n : getOrderedResultFirestore(snapshot as QuerySnapshot);\n const status = getStatus(response);\n const groupedResult =\n options?.groupByChangeType === true ? getGroupedResultFirestore(snapshot as QuerySnapshot) : null;\n const extra = { ref: pathRef, snapshot, unsubscribe, groupedResult, status };\n callback({ data: response, extra });\n onEvent({ topic: listener.topic, data: response, extra });\n },\n (error) => {\n onError({ error });\n },\n );\n unmount = onListen({ listener, callback, onUnmount: unsubscribe });\n clearListeners = () => {\n unsubscribe();\n unmount();\n };\n\n return clearListeners;\n };\n\n const emit = async () => {\n throw new Error(\"Cannot emit from Firestore database socket.\");\n };\n\n return {\n connect,\n reconnect,\n disconnect,\n emit,\n listen,\n };\n });\n};\n","/* eslint-disable max-params */\nimport type { CollectionReference, DocumentReference, DocumentSnapshot, Firestore } from \"firebase-admin/firestore\";\nimport type { getAdapterBindings } from \"@hyper-fetch/core\";\n\nimport type { FirestoreMethodsUnion } from \"adapter\";\nimport { getStatus } from \"utils\";\nimport { applyFireStoreAdminConstraints, getOrderedResultFirestore, getRef } from \"./utils\";\nimport type {\n FirestoreConstraintsUnion,\n FirestorePermittedMethods,\n PermittedConstraints,\n SharedQueryConstraints,\n} from \"constraints\";\n\ntype DataType = {\n constraints?: PermittedConstraints<FirestorePermittedMethods, FirestoreConstraintsUnion | SharedQueryConstraints>[];\n payload?: any;\n options?: Record<string, any>;\n};\n\nexport const getFirestoreAdminMethods = ({\n database,\n url,\n onSuccess,\n onError,\n onResponseStart,\n onRequestStart,\n onRequestEnd,\n onResponseEnd,\n}: {\n database: Firestore;\n url: string;\n onSuccess: Awaited<ReturnType<typeof getAdapterBindings>>[\"onSuccess\"];\n onError: Awaited<ReturnType<typeof getAdapterBindings>>[\"onError\"];\n onResponseStart: Awaited<ReturnType<typeof getAdapterBindings>>[\"onResponseStart\"];\n onRequestStart: Awaited<ReturnType<typeof getAdapterBindings>>[\"onRequestStart\"];\n onRequestEnd: Awaited<ReturnType<typeof getAdapterBindings>>[\"onRequestEnd\"];\n onResponseEnd: Awaited<ReturnType<typeof getAdapterBindings>>[\"onResponseEnd\"];\n}): ((methodName: FirestoreMethodsUnion, data: DataType) => Promise<void>) => {\n const [cleanUrl] = url.split(\"?\");\n const methods = {\n getDoc: async () => {\n const path = getRef(database, cleanUrl);\n const snapshot = (await path.get()) as DocumentSnapshot;\n const result = snapshot.data() ? { ...snapshot.data(), __key: snapshot.id } : null;\n const status = result ? \"success\" : \"emptyResource\";\n return { result, status, extra: { ref: path, snapshot } };\n },\n getDocs: async ({\n constraints = [],\n }: {\n constraints?: PermittedConstraints<\n FirestorePermittedMethods,\n FirestoreConstraintsUnion | SharedQueryConstraints\n >[];\n }) => {\n const path = getRef(database, cleanUrl) as CollectionReference;\n const query = applyFireStoreAdminConstraints(path, constraints);\n const querySnapshot = await query.get();\n const result = getOrderedResultFirestore(querySnapshot);\n const status = getStatus(result);\n\n return { result, status, extra: { ref: path, snapshot: querySnapshot } };\n },\n setDoc: async ({ data, options }: { data?: any; options?: any }) => {\n const path = getRef(database, cleanUrl) as DocumentReference;\n const merge = options?.merge === true;\n const res = await path.set(data, { merge });\n return { result: res, status: \"success\", extra: { ref: path } };\n },\n addDoc: async ({ data }: { data?: any }) => {\n const ref = getRef(database, cleanUrl) as CollectionReference;\n const docRef = await ref.add(data);\n return { result: { ...data, __key: docRef.id }, status: \"success\", extra: { ref: docRef } };\n },\n updateDoc: async ({ data }: { data?: any }) => {\n const path = getRef(database, cleanUrl) as DocumentReference;\n await path.update(data);\n return { result: data, status: \"success\", extra: { ref: path } };\n },\n deleteDoc: async () => {\n const path = getRef(database, cleanUrl) as DocumentReference;\n await path.delete();\n return { result: null, status: \"success\", extra: { ref: path } };\n },\n };\n\n return async (methodName: FirestoreMethodsUnion, data: DataType) => {\n try {\n onRequestStart();\n const { result, status, extra } = await methods[methodName](data);\n onRequestEnd();\n onResponseStart();\n onSuccess({ data: result, status, extra });\n onResponseEnd();\n } catch (error) {\n onRequestEnd();\n onResponseStart();\n onError({ error, status: \"error\", extra: {} });\n onResponseEnd();\n }\n };\n};\n","import type { DataSnapshot } from \"firebase-admin/database\";\n\nexport const getOrderedResultRealtime = (snapshot: DataSnapshot) => {\n const res: any = [];\n snapshot.forEach((child) => {\n res.push({ ...child.val(), __key: child.key });\n });\n return res.length > 0 ? res : null;\n};\n","import type { Query } from \"firebase-admin/database\";\n\nimport type { RealtimePermittedMethods } from \"constraints\";\nimport { RealtimeQueryConstraints, SharedQueryConstraints } from \"constraints\";\n\nexport const applyRealtimeAdminConstraint = (ref: Query, { type, values }: RealtimePermittedMethods) => {\n switch (type) {\n case RealtimeQueryConstraints.ORDER_BY_CHILD: {\n const [value] = values;\n return ref.orderByChild(value);\n }\n case RealtimeQueryConstraints.ORDER_BY_KEY: {\n return ref.orderByKey();\n }\n case RealtimeQueryConstraints.ORDER_BY_VALUE: {\n return ref.orderByValue();\n }\n case SharedQueryConstraints.START_AT: {\n const [[value]] = values;\n return ref.startAt(value);\n }\n case SharedQueryConstraints.START_AFTER: {\n const [[value]] = values;\n return ref.startAfter(value);\n }\n case SharedQueryConstraints.END_AT: {\n const [[value]] = values;\n return ref.endAt(value);\n }\n case SharedQueryConstraints.END_BEFORE: {\n const [[value]] = values;\n return ref.endBefore(value);\n }\n case RealtimeQueryConstraints.LIMIT_TO_FIRST: {\n const [value] = values;\n return ref.limitToFirst(value);\n }\n case RealtimeQueryConstraints.LIMIT_TO_LAST: {\n const [value] = values;\n return ref.limitToLast(value);\n }\n case RealtimeQueryConstraints.EQUAL_TO: {\n const [value] = values;\n return ref.equalTo(value);\n }\n default:\n throw new Error(`Unknown method ${type}`);\n }\n};\n\nexport const applyRealtimeAdminConstraints = (ref: Query, constraints: RealtimePermittedMethods[]) => {\n return constraints.reduce((collection, constraint) => {\n return applyRealtimeAdminConstraint(collection, constraint);\n }, ref);\n};\n","/* eslint-disable max-params */\nimport type { Database } from \"firebase-admin/database\";\nimport type { getAdapterBindings } from \"@hyper-fetch/core\";\n\nimport type { RealtimeDBMethodsUnion } from \"adapter/types\";\nimport { getStatus, isDocOrQuery } from \"utils\";\nimport { applyRealtimeAdminConstraints, getOrderedResultRealtime } from \"realtime/index\";\nimport type {\n PermittedConstraints,\n RealtimeConstraintsUnion,\n RealtimePermittedMethods,\n SharedQueryConstraints,\n} from \"constraints\";\n\nexport const getRealtimeDbAdminMethods = ({\n database,\n url,\n onSuccess,\n onError,\n onResponseStart,\n onRequestStart,\n onRequestEnd,\n onResponseEnd,\n}: {\n database: Database;\n url: string;\n onSuccess: Awaited<ReturnType<typeof getAdapterBindings>>[\"onSuccess\"];\n onError: Awaited<ReturnType<typeof getAdapterBindings>>[\"onError\"];\n onResponseStart: Awaited<ReturnType<typeof getAdapterBindings>>[\"onResponseStart\"];\n onRequestStart: Awaited<ReturnType<typeof getAdapterBindings>>[\"onRequestStart\"];\n onRequestEnd: Awaited<ReturnType<typeof getAdapterBindings>>[\"onRequestEnd\"];\n onResponseEnd: Awaited<ReturnType<typeof getAdapterBindings>>[\"onResponseEnd\"];\n}): ((\n methodName: RealtimeDBMethodsUnion,\n data: {\n constraints: PermittedConstraints<RealtimePermittedMethods, RealtimeConstraintsUnion | SharedQueryConstraints>[];\n payload: any;\n options: Record<string, any>;\n },\n) => Promise<void>) => {\n const [fullUrl] = url.split(\"?\");\n const path = database.ref(fullUrl);\n const methods = {\n get: async ({ constraints = [] }) => {\n const docOrQuery = isDocOrQuery(fullUrl);\n const q = applyRealtimeAdminConstraints(path, constraints);\n const snapshot = await q.get();\n const res = docOrQuery === \"doc\" ? snapshot.val() : getOrderedResultRealtime(snapshot);\n const status = getStatus(res);\n return { result: res, status, extra: { ref: path, snapshot } };\n },\n set: async ({ data }: { data?: any }) => {\n await path.set(data);\n return { result: data, status: \"success\", extra: { ref: path } };\n },\n push: async ({ data }: { data?: any }) => {\n const resRef = await path.push(data);\n return { result: { ...data, __key: resRef.key }, status: \"success\", extra: { ref: resRef, key: resRef.key } };\n },\n update: async ({ data }: { data?: any }) => {\n await path.update(data);\n return { result: data, status: \"success\", extra: { ref: path } };\n },\n remove: async () => {\n await path.remove();\n return { result: null, status: \"success\", extra: { ref: path } };\n },\n };\n\n return async (methodName: RealtimeDBMethodsUnion, data) => {\n try {\n onRequestStart();\n const { result, status, extra } = await methods[methodName](data as any);\n onRequestEnd();\n onResponseStart();\n onSuccess({ data: result, status, extra });\n onResponseEnd();\n } catch (error) {\n onRequestEnd();\n onResponseStart();\n onError({ error, status: \"error\", extra: {} });\n onResponseEnd();\n }\n };\n};\n","import type { Database, DataSnapshot } from \"firebase-admin/database\";\nimport { SocketAdapter } from \"@hyper-fetch/sockets\";\n\nimport { applyRealtimeAdminConstraints, getOrderedResultRealtime } from \"./utils\";\nimport { getStatus, isDocOrQuery } from \"utils\";\nimport type { RealtimeAdminOnValueMethodExtra, RealtimeAdminSocketAdapterType } from \"adapter\";\n\nexport const realtimeSocketsAdmin = (database: Database) => {\n return (\n new SocketAdapter({\n name: \"firebase-admin-realtime\",\n defaultConnected: true,\n }) as unknown as RealtimeAdminSocketAdapterType\n ).setConnector(\n ({ socket, onReconnect, onConnect, onConnected, onDisconnect, onDisconnected, onListen, onEvent, onError }) => {\n const connect = async () => {\n const enabled = onConnect();\n\n if (enabled) {\n database.goOnline();\n onConnected();\n }\n };\n\n const disconnect = async () => {\n database.goOffline();\n onDisconnect();\n onDisconnected();\n };\n\n const reconnect = () => {\n onReconnect({ disconnect, connect });\n };\n\n const listen: RealtimeAdminSocketAdapterType[\"listen\"] = (listener, callback) => {\n const fullUrl = socket.url + listener.topic;\n const path = database.ref(fullUrl);\n const { options } = listener;\n const onlyOnce = options?.onlyOnce || false;\n const q = applyRealtimeAdminConstraints(path, options?.constraints || []);\n const method = onlyOnce === true ? \"once\" : \"on\";\n q[method](\n \"value\",\n (snapshot) => {\n const getSnapshotData = (s: DataSnapshot) => (s.val() ? { ...s.val(), __key: s.key } : null);\n const response =\n isDocOrQuery(fullUrl) === \"doc\" ? getSnapshotData(snapshot) : getOrderedResultRealtime(snapshot);\n const status = getStatus(response);\n const extra: RealtimeAdminOnValueMethodExtra = { ref: path, snapshot, status };\n callback({ data: response, extra });\n onEvent({ topic: listener.topic, data: response, extra });\n },\n (error) => {\n onError({ error });\n },\n );\n const unsubscribe = () => q.off(\"value\");\n const unmount = onListen({ listener, callback, onUnmount: unsubscribe });\n\n const clearListeners = () => {\n unsubscribe();\n unmount();\n };\n\n return clearListeners;\n };\n\n const emit = async () => {\n throw new Error(\"Cannot emit from Realtime database socket.\");\n };\n\n return {\n connect,\n reconnect,\n disconnect,\n listen,\n emit,\n };\n },\n );\n};\n","import { Firestore } from \"firebase-admin/firestore\";\n\nimport type { FirebaseAdminDBTypes, FirebaseAdminSocketAdapterTypes } from \"./types\";\nimport { firestoreAdminSockets } from \"../firestore\";\nimport { realtimeSocketsAdmin } from \"../realtime\";\n\nexport const FirebaseSocketsAdminAdapter = <T extends FirebaseAdminDBTypes>(\n database: T,\n): FirebaseAdminSocketAdapterTypes<T> => {\n if (database instanceof Firestore) {\n return firestoreAdminSockets(database) as unknown as FirebaseAdminSocketAdapterTypes<T>;\n }\n return realtimeSocketsAdmin(database) as unknown as FirebaseAdminSocketAdapterTypes<T>;\n};\n","import { Adapter } from \"@hyper-fetch/core\";\nimport { Firestore } from \"firebase-admin/firestore\";\n\nimport type {\n FirebaseAdminDBTypes,\n FirebaseAdminAdapterTypes,\n FirestoreRequestType,\n RealtimeDBRequestType,\n} from \"adapter\";\nimport { FirestoreMethods, RealtimeDBMethods } from \"adapter\";\nimport { getFirestoreAdminMethods } from \"../firestore\";\nimport { getRealtimeDbAdminMethods } from \"../realtime\";\n\nexport const FirebaseAdminAdapter = <T extends FirebaseAdminDBTypes>(database: T): FirebaseAdminAdapterTypes<T> => {\n const adapter = new Adapter({\n name: \"firebase-admin\",\n defaultMethod: \"getDoc\",\n defaultExtra: {},\n systemErrorStatus: \"error\",\n systemErrorExtra: {},\n }).setFetcher(\n async ({ request, onSuccess, onError, onResponseStart, onResponseEnd, onRequestStart, onRequestEnd }) => {\n const fullUrl = `${request.client.url}${request.endpoint}`;\n if (database instanceof Firestore) {\n const { method = FirestoreMethods.getDocs, queryParams, payload, options } = request as FirestoreRequestType;\n const availableMethods = getFirestoreAdminMethods({\n database,\n url: fullUrl,\n onSuccess,\n onError,\n onRequestStart,\n onResponseEnd,\n onResponseStart,\n onRequestEnd,\n });\n if (!Object.values(FirestoreMethods).includes(method)) {\n throw new Error(`Cannot find method ${method} in Firestore available methods.`);\n }\n availableMethods(method, {\n constraints: queryParams?.constraints ? queryParams.constraints : [],\n payload,\n options,\n });\n } else {\n const { method = RealtimeDBMethods.get, queryParams, payload, options } = request as RealtimeDBRequestType;\n const availableMethods = getRealtimeDbAdminMethods({\n database,\n url: fullUrl,\n onSuccess,\n onError,\n onRequestStart,\n onResponseEnd,\n onResponseStart,\n onRequestEnd,\n });\n if (!Object.values(RealtimeDBMethods).includes(method)) {\n throw new Error(`Cannot find method ${method} in Realtime database available methods.`);\n }\n availableMethods(method, {\n constraints: queryParams?.constraints ? queryParams.constraints : [],\n options,\n payload,\n });\n }\n },\n );\n\n return adapter as unknown as FirebaseAdminAdapterTypes<T>;\n};\n"],"mappings":";;;;AAuDA,IAAY,mBAAL,yBAAA,kBAAA;AACL,kBAAA,YAAA;AACA,kBAAA,YAAA;AACA,kBAAA,aAAA;AACA,kBAAA,YAAA;AACA,kBAAA,eAAA;AACA,kBAAA,eAAA;;KACD;;;ACdD,IAAY,oBAAL,yBAAA,mBAAA;AACL,mBAAA,SAAA;AACA,mBAAA,UAAA;AACA,mBAAA,YAAA;AACA,mBAAA,SAAA;AACA,mBAAA,YAAA;;KACD;;;ACpDD,IAAa,6BAA6B,aAA4B;CACpE,MAAM,SAA+C,EAAE;AACvD,UAAS,KAAK,SAAS,MAAM;AAC3B,SAAO,KAAK;GAAE,G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B,MAAM;EACN,eAAe;EACf,cAAc,EAAE;EAChB,mBAAmB;EACnB,kBAAkB,EAAE;EACrB,CAAC,CAAC,WACD,OAAO,EAAE,SAAS,WAAW,SAAS,iBAAiB,eAAe,gBAAgB,mBAAmB;EACvG,MAAM,UAAU,GAAG,QAAQ,OAAO,MAAM,QAAQ;AAChD,MAAI,oBAAoB,WAAW;GACjC,MAAM,EAAE,SAAS,iBAAiB,SAAS,aAAa,SAAS,YAAY;GAC7E,MAAM,mBAAmB,yBAAyB;IAChD;IACA,KAAK;IACL;IACA;IACA;IACA;IACA;IACA;IACD,CAAC;AACF,OAAI,CAAC,OAAO,OAAO,iBAAiB,CAAC,SAAS,OAAO,CACnD,OAAM,IAAI,MAAM,sBAAsB,OAAO,kCAAkC;AAEjF,oBAAiB,QAAQ;IACvB,aAAa,aAAa,cAAc,YAAY,cAAc,EAAE;IACpE;IACA;IACD,CAAC;SACG;GACL,MAAM,EAAE,SAAS,kBAAkB,KAAK,aAAa,SAAS,YAAY;GAC1E,MAAM,mBAAmB,0BAA0B;IACjD;IACA,KAAK;IACL;IACA;IACA;IACA;IACA;IACA;IACD,CAAC;AACF,OAAI,CAAC,OAAO,OAAO,kBAAkB,CAAC,SAAS,OAAO,CACpD,OAAM,IAAI,MAAM,sBAAsB,OAAO,0CAA0C;AAEzF,oBAAiB,QAAQ;IACvB,aAAa,aAAa,cAAc,YAAY,cAAc,EAAE;IACpE;IACA;IACD,CAAC;;GAGP"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/realtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Database } from 'firebase-admin/database';
|
|
2
|
+
import { getAdapterBindings } from '@hyper-fetch/core';
|
|
3
|
+
import { RealtimeDBMethodsUnion } from '../adapter/types';
|
|
4
|
+
import { PermittedConstraints, RealtimeConstraintsUnion, RealtimePermittedMethods, SharedQueryConstraints } from '../constraints';
|
|
5
|
+
export declare const getRealtimeDbAdminMethods: ({ database, url, onSuccess, onError, onResponseStart, onRequestStart, onRequestEnd, onResponseEnd, }: {
|
|
6
|
+
database: Database;
|
|
7
|
+
url: string;
|
|
8
|
+
onSuccess: Awaited<ReturnType<typeof getAdapterBindings>>["onSuccess"];
|
|
9
|
+
onError: Awaited<ReturnType<typeof getAdapterBindings>>["onError"];
|
|
10
|
+
onResponseStart: Awaited<ReturnType<typeof getAdapterBindings>>["onResponseStart"];
|
|
11
|
+
onRequestStart: Awaited<ReturnType<typeof getAdapterBindings>>["onRequestStart"];
|
|
12
|
+
onRequestEnd: Awaited<ReturnType<typeof getAdapterBindings>>["onRequestEnd"];
|
|
13
|
+
onResponseEnd: Awaited<ReturnType<typeof getAdapterBindings>>["onResponseEnd"];
|
|
14
|
+
}) => ((methodName: RealtimeDBMethodsUnion, data: {
|
|
15
|
+
constraints: PermittedConstraints<RealtimePermittedMethods, RealtimeConstraintsUnion | SharedQueryConstraints>[];
|
|
16
|
+
payload: any;
|
|
17
|
+
options: Record<string, any>;
|
|
18
|
+
}) => Promise<void>);
|
|
19
|
+
//# sourceMappingURL=realtime.methods.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtime.methods.d.ts","sourceRoot":"","sources":["../../src/realtime/realtime.methods.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAG5D,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,yBAAyB,GAAI,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,0 +1,5 @@
|
|
|
1
|
+
import { Query } from 'firebase-admin/database';
|
|
2
|
+
import { RealtimePermittedMethods } from '../../constraints';
|
|
3
|
+
export declare const applyRealtimeAdminConstraint: (ref: Query, { type, values }: RealtimePermittedMethods) => Query;
|
|
4
|
+
export declare const applyRealtimeAdminConstraints: (ref: Query, constraints: RealtimePermittedMethods[]) => Query;
|
|
5
|
+
//# sourceMappingURL=constraints.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraints.utils.d.ts","sourceRoot":"","sources":["../../../src/realtime/utils/constraints.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAG5D,eAAO,MAAM,4BAA4B,GAAI,KAAK,KAAK,EAAE,kBAAkB,wBAAwB,UA2ClG,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,KAAK,KAAK,EAAE,aAAa,wBAAwB,EAAE,UAIhG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/realtime/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.utils.d.ts","sourceRoot":"","sources":["../../../src/realtime/utils/result.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,eAAO,MAAM,wBAAwB,GAAI,UAAU,YAAY,QAM9D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ClientInstance, RequestInstance } from '@hyper-fetch/core';
|
|
2
|
+
import { FirestoreAdapterType } from '../adapter';
|
|
3
|
+
export declare const setCacheManually: (request: RequestInstance<{
|
|
4
|
+
client: ClientInstance<{
|
|
5
|
+
adapter: FirestoreAdapterType;
|
|
6
|
+
}>;
|
|
7
|
+
}>, response: {
|
|
8
|
+
value: any;
|
|
9
|
+
status: "success" | "error" | "emptyResource";
|
|
10
|
+
}, extra: any) => void;
|
|
11
|
+
//# sourceMappingURL=cache.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.utils.d.ts","sourceRoot":"","sources":["../../src/utils/cache.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,eAAO,MAAM,gBAAgB,GAC3B,SAAS,eAAe,CAAC;IACvB,MAAM,EAAE,cAAc,CAAC;QACrB,OAAO,EAAE,oBAAoB,CAAC;KAC/B,CAAC,CAAC;CACJ,CAAC,EACF,UAAU;IAAE,KAAK,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,eAAe,CAAA;CAAE,EACvE,OAAO,GAAG,SAmCX,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../src/utils/misc.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GAAI,KAAK,GAAG,gCAGjC,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,MAI9C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyper-fetch/firebase-admin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "First class Firebase Admin adapter for Hyper Fetch",
|
|
5
5
|
"author": "Maciej Pyrc <maciekpyrc@gmail.com>, Kacper Skawina <kacper.skawina@gmail.com>",
|
|
6
6
|
"homepage": "https://hyperfetch.bettertyped.com/",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
|
-
"main": "dist/index.
|
|
9
|
-
"module": "dist/index.
|
|
8
|
+
"main": "dist/index.mjs",
|
|
9
|
+
"module": "dist/index.mjs",
|
|
10
10
|
"types": "dist/index.d.ts",
|
|
11
11
|
"source": "src/index.ts",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"coverage": "firebase emulators:exec 'jest --watchAll=false --coverage --detectOpenHandles --forceExit --runInBand'",
|
|
16
|
-
"test:pipeline": "./test.sh",
|
|
13
|
+
"test": "firebase emulators:exec 'npx vitest run'",
|
|
14
|
+
"coverage": "firebase emulators:exec 'npx vitest run --coverage'",
|
|
17
15
|
"start": "yarn build && npx run-when-changed --watch 'src/**/*.ts' --exec 'yarn build'",
|
|
18
16
|
"start:emulator": "firebase emulators:start --project demo-test --only firestore,database",
|
|
19
|
-
"build": "
|
|
20
|
-
"postbuild": "yarn rollup -c ../../rollup.config.js",
|
|
17
|
+
"build": "vite build",
|
|
21
18
|
"lint": "eslint . --ext .js,.jsx,.tsx,.ts --fix",
|
|
22
19
|
"format": "prettier --write .",
|
|
23
|
-
"
|
|
24
|
-
"tests": "firebase emulators:exec '
|
|
20
|
+
"typecheck": "tsc --noEmit --emitDeclarationOnly false && tsc --noEmit -p __tests__/tsconfig.json",
|
|
21
|
+
"tests": "firebase emulators:exec 'npx vitest run'",
|
|
25
22
|
"release": "yarn semantic-release --extends ../../release.config.js -t 'hyper-fetch-firebase-admin-v${version}'"
|
|
26
23
|
},
|
|
27
24
|
"publishConfig": {
|
package/project.json
ADDED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Firestore } from "firebase-admin/firestore";
|
|
2
2
|
|
|
3
|
-
import { FirebaseAdminDBTypes, FirebaseAdminSocketAdapterTypes } from "./types";
|
|
3
|
+
import type { FirebaseAdminDBTypes, FirebaseAdminSocketAdapterTypes } from "./types";
|
|
4
4
|
import { firestoreAdminSockets } from "../firestore";
|
|
5
5
|
import { realtimeSocketsAdmin } from "../realtime";
|
|
6
6
|
|
package/src/adapter/adapter.ts
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
import { Adapter } from "@hyper-fetch/core";
|
|
2
2
|
import { Firestore } from "firebase-admin/firestore";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type {
|
|
5
5
|
FirebaseAdminDBTypes,
|
|
6
|
-
|
|
7
|
-
RealtimeDBMethods,
|
|
6
|
+
FirebaseAdminAdapterTypes,
|
|
8
7
|
FirestoreRequestType,
|
|
9
8
|
RealtimeDBRequestType,
|
|
10
|
-
FirestoreAdapterType,
|
|
11
9
|
} from "adapter";
|
|
10
|
+
import { FirestoreMethods, RealtimeDBMethods } from "adapter";
|
|
12
11
|
import { getFirestoreAdminMethods } from "../firestore";
|
|
13
12
|
import { getRealtimeDbAdminMethods } from "../realtime";
|
|
14
13
|
|
|
15
|
-
export const FirebaseAdminAdapter = <T extends FirebaseAdminDBTypes>(database: T) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}) as unknown as FirestoreAdapterType
|
|
24
|
-
).setFetcher(
|
|
14
|
+
export const FirebaseAdminAdapter = <T extends FirebaseAdminDBTypes>(database: T): FirebaseAdminAdapterTypes<T> => {
|
|
15
|
+
const adapter = new Adapter({
|
|
16
|
+
name: "firebase-admin",
|
|
17
|
+
defaultMethod: "getDoc",
|
|
18
|
+
defaultExtra: {},
|
|
19
|
+
systemErrorStatus: "error",
|
|
20
|
+
systemErrorExtra: {},
|
|
21
|
+
}).setFetcher(
|
|
25
22
|
async ({ request, onSuccess, onError, onResponseStart, onResponseEnd, onRequestStart, onRequestEnd }) => {
|
|
26
23
|
const fullUrl = `${request.client.url}${request.endpoint}`;
|
|
27
24
|
if (database instanceof Firestore) {
|
|
@@ -67,4 +64,6 @@ export const FirebaseAdminAdapter = <T extends FirebaseAdminDBTypes>(database: T
|
|
|
67
64
|
}
|
|
68
65
|
},
|
|
69
66
|
);
|
|
67
|
+
|
|
68
|
+
return adapter as unknown as FirebaseAdminAdapterTypes<T>;
|
|
70
69
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Database } from "firebase-admin/database";
|
|
2
|
-
import { Firestore } from "firebase-admin/firestore";
|
|
3
|
-
import { Adapter, Request, Client } from "@hyper-fetch/core";
|
|
1
|
+
import type { Database } from "firebase-admin/database";
|
|
2
|
+
import type { Firestore } from "firebase-admin/firestore";
|
|
3
|
+
import type { Adapter, Request, Client } from "@hyper-fetch/core";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import type {
|
|
6
6
|
RealtimeDbAdapterType,
|
|
7
7
|
FirestoreAdapterType,
|
|
8
8
|
FirestoreAdminSocketAdapterType,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
-
import { Adapter } from "@hyper-fetch/core";
|
|
3
|
-
import {
|
|
2
|
+
import type { Adapter } from "@hyper-fetch/core";
|
|
3
|
+
import type {
|
|
4
4
|
Unsubscribe as FirestoreUnsubscribe,
|
|
5
5
|
CollectionReference,
|
|
6
6
|
DocumentReference,
|
|
7
7
|
DocumentSnapshot,
|
|
8
8
|
QuerySnapshot,
|
|
9
9
|
} from "firebase/firestore";
|
|
10
|
-
import { SocketAdapter } from "@hyper-fetch/sockets";
|
|
10
|
+
import type { SocketAdapter } from "@hyper-fetch/sockets";
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import type {
|
|
13
13
|
FirestoreConstraintsUnion,
|
|
14
14
|
FirestorePermittedMethods,
|
|
15
15
|
PermittedConstraints,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
-
import { Adapter } from "@hyper-fetch/core";
|
|
3
|
-
import { DatabaseReference, DataSnapshot } from "firebase/database";
|
|
4
|
-
import { SocketAdapter } from "@hyper-fetch/sockets";
|
|
2
|
+
import type { Adapter } from "@hyper-fetch/core";
|
|
3
|
+
import type { DatabaseReference, DataSnapshot } from "firebase/database";
|
|
4
|
+
import type { SocketAdapter } from "@hyper-fetch/sockets";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import type {
|
|
7
7
|
PermittedConstraints,
|
|
8
8
|
RealtimeConstraintsUnion,
|
|
9
9
|
RealtimePermittedMethods,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DocumentReference, DocumentSnapshot, DocumentData, Query, QuerySnapshot } from "firebase-admin/firestore";
|
|
2
|
-
import { SocketAdapter } from "@hyper-fetch/sockets";
|
|
1
|
+
import type { DocumentReference, DocumentSnapshot, DocumentData, Query, QuerySnapshot } from "firebase-admin/firestore";
|
|
2
|
+
import type { SocketAdapter } from "@hyper-fetch/sockets";
|
|
3
3
|
|
|
4
|
-
import { FirestoreQueryParams } from "adapter";
|
|
4
|
+
import type { FirestoreQueryParams } from "adapter";
|
|
5
5
|
|
|
6
6
|
export type FirestoreAdminSocketAdapterType = SocketAdapter<
|
|
7
7
|
FirestoreAdminOnSnapshotExtra,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SocketAdapter } from "@hyper-fetch/sockets";
|
|
2
|
-
import { Reference, DataSnapshot } from "firebase-admin/database";
|
|
1
|
+
import type { SocketAdapter } from "@hyper-fetch/sockets";
|
|
2
|
+
import type { Reference, DataSnapshot } from "firebase-admin/database";
|
|
3
3
|
|
|
4
|
-
import { RealtimeDBQueryParams, RealtimeDBStatuses } from "adapter/index";
|
|
4
|
+
import type { RealtimeDBQueryParams, RealtimeDBStatuses } from "adapter/index";
|
|
5
5
|
|
|
6
6
|
export type RealtimeAdminSocketAdapterType = SocketAdapter<
|
|
7
7
|
any,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable max-params */
|
|
2
|
-
import { CollectionReference, DocumentReference, DocumentSnapshot, Firestore } from "firebase-admin/firestore";
|
|
3
|
-
import { getAdapterBindings } from "@hyper-fetch/core";
|
|
2
|
+
import type { CollectionReference, DocumentReference, DocumentSnapshot, Firestore } from "firebase-admin/firestore";
|
|
3
|
+
import type { getAdapterBindings } from "@hyper-fetch/core";
|
|
4
4
|
|
|
5
|
-
import { FirestoreMethodsUnion } from "adapter";
|
|
5
|
+
import type { FirestoreMethodsUnion } from "adapter";
|
|
6
6
|
import { getStatus } from "utils";
|
|
7
7
|
import { applyFireStoreAdminConstraints, getOrderedResultFirestore, getRef } from "./utils";
|
|
8
|
-
import {
|
|
8
|
+
import type {
|
|
9
9
|
FirestoreConstraintsUnion,
|
|
10
10
|
FirestorePermittedMethods,
|
|
11
11
|
PermittedConstraints,
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
DocumentReference,
|
|
4
|
-
DocumentSnapshot,
|
|
5
|
-
Firestore,
|
|
6
|
-
Query,
|
|
7
|
-
QuerySnapshot,
|
|
8
|
-
} from "firebase-admin/firestore";
|
|
1
|
+
import type { DocumentReference, Firestore, Query, QuerySnapshot } from "firebase-admin/firestore";
|
|
2
|
+
import { CollectionReference, DocumentSnapshot } from "firebase-admin/firestore";
|
|
9
3
|
import { SocketAdapter } from "@hyper-fetch/sockets";
|
|
10
4
|
|
|
11
5
|
import { getGroupedResultFirestore, getOrderedResultFirestore, getRef, applyFireStoreAdminConstraints } from "./utils";
|
|
12
|
-
import { FirestoreAdminSocketAdapterType } from "adapter";
|
|
6
|
+
import type { FirestoreAdminSocketAdapterType } from "adapter";
|
|
13
7
|
import { getStatus } from "utils";
|
|
14
8
|
|
|
15
9
|
export const firestoreAdminSockets = (database: Firestore) => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Query } from "firebase-admin/firestore";
|
|
2
|
-
import { OrderByDirection } from "firebase/firestore";
|
|
1
|
+
import type { Query } from "firebase-admin/firestore";
|
|
2
|
+
import type { OrderByDirection } from "firebase/firestore";
|
|
3
3
|
|
|
4
|
-
import { FirestorePermittedMethods
|
|
4
|
+
import type { FirestorePermittedMethods } from "../../constraints";
|
|
5
|
+
import { FirestoreQueryConstraints, SharedQueryConstraints } from "../../constraints";
|
|
5
6
|
|
|
6
7
|
export const applyFireStoreAdminConstraint = (collectionRef: Query, { type, values }: FirestorePermittedMethods) => {
|
|
7
8
|
switch (type) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CollectionReference, DocumentReference, Firestore } from "firebase-admin/firestore";
|
|
1
|
+
import type { CollectionReference, DocumentReference, Firestore } from "firebase-admin/firestore";
|
|
2
2
|
|
|
3
3
|
export const getRef = (db: Firestore, fullUrl: string) => {
|
|
4
4
|
const withoutSurroundingSlashes = fullUrl.replace(/^\/|\/$/g, "");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QuerySnapshot, DocumentData } from "firebase-admin/firestore";
|
|
1
|
+
import type { QuerySnapshot, DocumentData } from "firebase-admin/firestore";
|
|
2
2
|
|
|
3
3
|
export const getOrderedResultFirestore = (snapshot: QuerySnapshot) => {
|
|
4
4
|
const result: (DocumentData & { __key: string })[] = [];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable max-params */
|
|
2
|
-
import { Database } from "firebase-admin/database";
|
|
3
|
-
import { getAdapterBindings } from "@hyper-fetch/core";
|
|
2
|
+
import type { Database } from "firebase-admin/database";
|
|
3
|
+
import type { getAdapterBindings } from "@hyper-fetch/core";
|
|
4
4
|
|
|
5
|
-
import { RealtimeDBMethodsUnion } from "adapter/types";
|
|
5
|
+
import type { RealtimeDBMethodsUnion } from "adapter/types";
|
|
6
6
|
import { getStatus, isDocOrQuery } from "utils";
|
|
7
7
|
import { applyRealtimeAdminConstraints, getOrderedResultRealtime } from "realtime/index";
|
|
8
|
-
import {
|
|
8
|
+
import type {
|
|
9
9
|
PermittedConstraints,
|
|
10
10
|
RealtimeConstraintsUnion,
|
|
11
11
|
RealtimePermittedMethods,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Database, DataSnapshot } from "firebase-admin/database";
|
|
1
|
+
import type { Database, DataSnapshot } from "firebase-admin/database";
|
|
2
2
|
import { SocketAdapter } from "@hyper-fetch/sockets";
|
|
3
3
|
|
|
4
4
|
import { applyRealtimeAdminConstraints, getOrderedResultRealtime } from "./utils";
|
|
5
5
|
import { getStatus, isDocOrQuery } from "utils";
|
|
6
|
-
import { RealtimeAdminOnValueMethodExtra, RealtimeAdminSocketAdapterType } from "adapter";
|
|
6
|
+
import type { RealtimeAdminOnValueMethodExtra, RealtimeAdminSocketAdapterType } from "adapter";
|
|
7
7
|
|
|
8
8
|
export const realtimeSocketsAdmin = (database: Database) => {
|
|
9
9
|
return (
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Query } from "firebase-admin/database";
|
|
1
|
+
import type { Query } from "firebase-admin/database";
|
|
2
2
|
|
|
3
|
-
import { RealtimePermittedMethods
|
|
3
|
+
import type { RealtimePermittedMethods } from "constraints";
|
|
4
|
+
import { RealtimeQueryConstraints, SharedQueryConstraints } from "constraints";
|
|
4
5
|
|
|
5
6
|
export const applyRealtimeAdminConstraint = (ref: Query, { type, values }: RealtimePermittedMethods) => {
|
|
6
7
|
switch (type) {
|
package/src/utils/cache.utils.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ClientInstance, RequestInstance } from "@hyper-fetch/core";
|
|
1
|
+
import type { ClientInstance, RequestInstance } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
|
-
import { FirestoreAdapterType } from "adapter";
|
|
3
|
+
import type { FirestoreAdapterType } from "adapter";
|
|
4
4
|
|
|
5
5
|
export const setCacheManually = (
|
|
6
6
|
request: RequestInstance<{
|
|
@@ -20,6 +20,7 @@ export const setCacheManually = (
|
|
|
20
20
|
extra,
|
|
21
21
|
isCanceled: false,
|
|
22
22
|
isOffline: false,
|
|
23
|
+
willRetry: false,
|
|
23
24
|
retries: 0,
|
|
24
25
|
requestTimestamp: +new Date(),
|
|
25
26
|
responseTimestamp: +new Date(),
|
|
@@ -35,6 +36,7 @@ export const setCacheManually = (
|
|
|
35
36
|
extra,
|
|
36
37
|
isCanceled: false,
|
|
37
38
|
isOffline: false,
|
|
39
|
+
willRetry: false,
|
|
38
40
|
retries: 0,
|
|
39
41
|
requestTimestamp: +new Date(),
|
|
40
42
|
responseTimestamp: +new Date(),
|
package/tsconfig.json
CHANGED
package/vite.config.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="vitest/config" />
|
|
2
|
+
import { defineConfig } from "vite";
|
|
3
|
+
import dts from "vite-plugin-dts";
|
|
4
|
+
import tsconfigPaths from "vite-tsconfig-paths";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { getDtsCompilerOptionsForPackage } from "../../scripts/vite-dts-internal-paths";
|
|
7
|
+
import { getRollupExternalsFromPackageJson } from "../../scripts/vite-lib-externals-from-package";
|
|
8
|
+
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
build: {
|
|
11
|
+
lib: {
|
|
12
|
+
entry: "src/index.ts",
|
|
13
|
+
formats: ["es"],
|
|
14
|
+
fileName: "index",
|
|
15
|
+
},
|
|
16
|
+
sourcemap: true,
|
|
17
|
+
minify: false,
|
|
18
|
+
rollupOptions: {
|
|
19
|
+
external: getRollupExternalsFromPackageJson(__dirname),
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
plugins: [
|
|
23
|
+
dts({
|
|
24
|
+
entryRoot: "src",
|
|
25
|
+
compilerOptions: getDtsCompilerOptionsForPackage(__dirname),
|
|
26
|
+
}),
|
|
27
|
+
tsconfigPaths(),
|
|
28
|
+
],
|
|
29
|
+
test: {
|
|
30
|
+
globals: true,
|
|
31
|
+
environment: "node",
|
|
32
|
+
setupFiles: ["./__tests__/vitest.setup.ts"],
|
|
33
|
+
include: ["__tests__/**/*.spec.{ts,tsx}", "src/**/*.spec.{ts,tsx}"],
|
|
34
|
+
coverage: {
|
|
35
|
+
provider: "v8",
|
|
36
|
+
include: ["src/**/*.{ts,tsx}"],
|
|
37
|
+
exclude: ["**/*.spec.*", "**/types.*", "**/constants.*", "**/index.ts"],
|
|
38
|
+
},
|
|
39
|
+
alias: {
|
|
40
|
+
"@hyper-fetch/core": path.resolve(__dirname, "../core/src/index.ts"),
|
|
41
|
+
"@hyper-fetch/sockets": path.resolve(__dirname, "../sockets/src/index.ts"),
|
|
42
|
+
"@hyper-fetch/testing": path.resolve(__dirname, "../testing/src/index.ts"),
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
package/.eslintrc.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": ["plugin:@nx/react", "../../.eslintrc.js"],
|
|
3
|
-
"parserOptions": {
|
|
4
|
-
"project": ["./tsconfig.json"]
|
|
5
|
-
},
|
|
6
|
-
"rules": {
|
|
7
|
-
"react/jsx-props-no-spreading": 0,
|
|
8
|
-
"react/require-default-props": 0
|
|
9
|
-
},
|
|
10
|
-
"ignorePatterns": ["dist/", "coverage/", "jest.config.ts", "/*.js"]
|
|
11
|
-
}
|