@hyper-fetch/firebase 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.
Files changed (110) hide show
  1. package/.eslintrc.cjs +12 -0
  2. package/__tests__/features/firestore/shared/constraints.shared.tests.ts +72 -0
  3. package/__tests__/features/firestore/shared/methods/add-doc.test.suite.ts +32 -0
  4. package/__tests__/features/firestore/shared/methods/delete-doc.test.suite.ts +52 -0
  5. package/__tests__/features/firestore/shared/methods/get-doc.test.suite.ts +60 -0
  6. package/__tests__/features/firestore/shared/methods/get-docs.test.suite.ts +45 -0
  7. package/__tests__/features/firestore/shared/methods/on-snapshot.test.suite.ts +290 -0
  8. package/__tests__/features/firestore/shared/methods/set-doc.test.suite.ts +70 -0
  9. package/__tests__/features/firestore/shared/methods/update-doc.test.suite.ts +40 -0
  10. package/__tests__/features/firestore/shared/methods.shared.tests.ts +24 -0
  11. package/__tests__/features/firestore/web/constraints.web.spec.ts +24 -0
  12. package/__tests__/features/firestore/web/methods.web.spec.ts +21 -0
  13. package/__tests__/features/firestore/web/sockets.base.spec.ts +18 -0
  14. package/__tests__/features/realtime/browser/constraints.web.spec.ts +14 -0
  15. package/__tests__/features/realtime/browser/methods.web.spec.ts +19 -0
  16. package/__tests__/features/realtime/browser/sockets.base.spec.ts +12 -0
  17. package/__tests__/features/realtime/shared/constraints.shared.tests.ts +57 -0
  18. package/__tests__/features/realtime/shared/methods/get.test.suite.ts +64 -0
  19. package/__tests__/features/realtime/shared/methods/on-value.test.suite.ts +189 -0
  20. package/__tests__/features/realtime/shared/methods/push.test.suite.ts +47 -0
  21. package/__tests__/features/realtime/shared/methods/remove.test.suite.ts +45 -0
  22. package/__tests__/features/realtime/shared/methods/set.test.suite.ts +70 -0
  23. package/__tests__/features/realtime/shared/methods/update.test.suite.ts +42 -0
  24. package/__tests__/features/realtime/shared/methods.shared.tests.ts +25 -0
  25. package/__tests__/shared/request-events.shared.ts +32 -0
  26. package/__tests__/tsconfig.json +21 -0
  27. package/__tests__/utils/browser/clean.browser.ts +18 -0
  28. package/__tests__/utils/browser/initialize.firestore.browser.ts +20 -0
  29. package/__tests__/utils/browser/initialize.realtime.browser.ts +20 -0
  30. package/__tests__/utils/browser/seed.browser.ts +25 -0
  31. package/__tests__/utils/index.ts +4 -0
  32. package/__tests__/utils/seed/seed.data.ts +21 -0
  33. package/__tests__/vitest.setup.ts +9 -0
  34. package/dist/adapter/adapter.d.ts +3 -0
  35. package/dist/adapter/adapter.d.ts.map +1 -0
  36. package/dist/adapter/adapter.sockets.d.ts +3 -0
  37. package/dist/adapter/adapter.sockets.d.ts.map +1 -0
  38. package/dist/adapter/index.d.ts +4 -0
  39. package/dist/adapter/index.d.ts.map +1 -0
  40. package/dist/adapter/types/adapter.base.types.d.ts +11 -0
  41. package/dist/adapter/types/adapter.base.types.d.ts.map +1 -0
  42. package/dist/adapter/types/adapter.firestore.types.d.ts +46 -0
  43. package/dist/adapter/types/adapter.firestore.types.d.ts.map +1 -0
  44. package/dist/adapter/types/adapter.realtime.types.d.ts +39 -0
  45. package/dist/adapter/types/adapter.realtime.types.d.ts.map +1 -0
  46. package/dist/adapter/types/index.d.ts +4 -0
  47. package/dist/adapter/types/index.d.ts.map +1 -0
  48. package/dist/constraints/constraints.types.d.ts +13 -0
  49. package/dist/constraints/constraints.types.d.ts.map +1 -0
  50. package/dist/constraints/firebase.constraints.d.ts +86 -0
  51. package/dist/constraints/firebase.constraints.d.ts.map +1 -0
  52. package/dist/constraints/index.d.ts +3 -0
  53. package/dist/constraints/index.d.ts.map +1 -0
  54. package/dist/firestore/firestore.methods.d.ts +21 -0
  55. package/dist/firestore/firestore.methods.d.ts.map +1 -0
  56. package/dist/firestore/firestore.sockets.d.ts +4 -0
  57. package/dist/firestore/firestore.sockets.d.ts.map +1 -0
  58. package/dist/firestore/firestore.types.d.ts +8 -0
  59. package/dist/firestore/firestore.types.d.ts.map +1 -0
  60. package/dist/firestore/index.d.ts +5 -0
  61. package/dist/firestore/index.d.ts.map +1 -0
  62. package/dist/firestore/utils/constraints.utils.d.ts +3 -0
  63. package/dist/firestore/utils/constraints.utils.d.ts.map +1 -0
  64. package/dist/firestore/utils/index.d.ts +3 -0
  65. package/dist/firestore/utils/index.d.ts.map +1 -0
  66. package/dist/firestore/utils/result.utils.d.ts +10 -0
  67. package/dist/firestore/utils/result.utils.d.ts.map +1 -0
  68. package/dist/index.d.ts +5 -250
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.mjs +664 -0
  71. package/dist/index.mjs.map +1 -0
  72. package/dist/realtime/index.d.ts +4 -0
  73. package/dist/realtime/index.d.ts.map +1 -0
  74. package/dist/realtime/realtime.methods.d.ts +21 -0
  75. package/dist/realtime/realtime.methods.d.ts.map +1 -0
  76. package/dist/realtime/realtime.sockets.d.ts +4 -0
  77. package/dist/realtime/realtime.sockets.d.ts.map +1 -0
  78. package/dist/realtime/utils/constraints.utils.d.ts +3 -0
  79. package/dist/realtime/utils/constraints.utils.d.ts.map +1 -0
  80. package/dist/realtime/utils/index.d.ts +3 -0
  81. package/dist/realtime/utils/index.d.ts.map +1 -0
  82. package/dist/realtime/utils/result.utils.d.ts +3 -0
  83. package/dist/realtime/utils/result.utils.d.ts.map +1 -0
  84. package/dist/utils/index.d.ts +2 -0
  85. package/dist/utils/index.d.ts.map +1 -0
  86. package/dist/utils/misc.d.ts +4 -0
  87. package/dist/utils/misc.d.ts.map +1 -0
  88. package/package.json +8 -11
  89. package/project.json +4 -0
  90. package/src/adapter/adapter.sockets.ts +1 -1
  91. package/src/adapter/adapter.ts +12 -18
  92. package/src/adapter/types/adapter.base.types.ts +4 -4
  93. package/src/adapter/types/adapter.firestore.types.ts +5 -5
  94. package/src/adapter/types/adapter.realtime.types.ts +4 -4
  95. package/src/constraints/constraints.types.ts +1 -1
  96. package/src/constraints/firebase.constraints.ts +1 -1
  97. package/src/firestore/firestore.methods.ts +5 -15
  98. package/src/firestore/firestore.sockets.ts +7 -14
  99. package/src/firestore/firestore.types.ts +2 -2
  100. package/src/firestore/utils/constraints.utils.ts +3 -2
  101. package/src/firestore/utils/result.utils.ts +1 -1
  102. package/src/realtime/realtime.methods.ts +5 -4
  103. package/src/realtime/realtime.sockets.ts +4 -3
  104. package/src/realtime/utils/constraints.utils.ts +2 -1
  105. package/src/realtime/utils/result.utils.ts +1 -1
  106. package/tsconfig.json +1 -1
  107. package/vite.config.ts +45 -0
  108. package/.eslintrc.json +0 -11
  109. package/dist/index.js +0 -728
  110. 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/realtime/utils/result.utils.ts","../src/constraints/firebase.constraints.ts","../src/realtime/utils/constraints.utils.ts","../src/firestore/firestore.types.ts","../src/utils/misc.ts","../src/realtime/realtime.sockets.ts","../src/realtime/realtime.methods.ts","../src/firestore/utils/result.utils.ts","../src/firestore/utils/constraints.utils.ts","../src/firestore/firestore.methods.ts","../src/firestore/firestore.sockets.ts","../src/adapter/adapter.ts","../src/adapter/adapter.sockets.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\";\nimport type { DocumentData } from \"@firebase/firestore\";\n\nimport type {\n FirestoreConstraintsUnion,\n FirestorePermittedMethods,\n PermittedConstraints,\n SharedQueryConstraints,\n} from \"constraints\";\n\nexport type FirestoreSocketAdapterType = SocketAdapter<\n FirestoreOnSnapshotExtra,\n undefined,\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 | QuerySnapshot;\n unsubscribe?: FirestoreUnsubscribe;\n groupedResult: { added: DocumentData[]; modified: DocumentData[]; removed: DocumentData[] } | null;\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 RealtimeDbOnValueMethodExtra,\n undefined,\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 { DataSnapshot } from \"@firebase/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 { OrderByDirection, WhereFilterOp } from \"firebase/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 {\n endAt,\n endBefore,\n equalTo,\n limitToFirst,\n limitToLast,\n orderByChild,\n orderByKey,\n orderByValue,\n startAfter,\n startAt,\n} from \"firebase/database\";\n\nimport type { RealtimePermittedMethods } from \"constraints\";\nimport { RealtimeQueryConstraints, SharedQueryConstraints } from \"constraints\";\n\nexport const mapRealtimeConstraint = ({ type, values }: RealtimePermittedMethods) => {\n switch (type) {\n case RealtimeQueryConstraints.ORDER_BY_CHILD: {\n const [value] = values;\n return orderByChild(value);\n }\n case RealtimeQueryConstraints.ORDER_BY_KEY: {\n return orderByKey();\n }\n case RealtimeQueryConstraints.ORDER_BY_VALUE: {\n return orderByValue();\n }\n case SharedQueryConstraints.START_AT: {\n const [[value]] = values;\n return startAt(value);\n }\n case SharedQueryConstraints.START_AFTER: {\n const [[value]] = values;\n return startAfter(value);\n }\n case SharedQueryConstraints.END_AT: {\n const [[value]] = values;\n return endAt(value);\n }\n case SharedQueryConstraints.END_BEFORE: {\n const [[value]] = values;\n return endBefore(value);\n }\n case RealtimeQueryConstraints.LIMIT_TO_FIRST: {\n const [value] = values;\n return limitToFirst(value);\n }\n case RealtimeQueryConstraints.LIMIT_TO_LAST: {\n const [value] = values;\n return limitToLast(value);\n }\n case RealtimeQueryConstraints.EQUAL_TO: {\n const [value] = values;\n return equalTo(value);\n }\n default:\n throw new Error(`Unknown method ${type}`);\n }\n};\n","import type { DocumentSnapshot } from \"@firebase/firestore\";\nimport type { QuerySnapshot } from \"firebase/firestore\";\n\nexport enum FirestoreDocOrQuery {\n DOC = \"doc\",\n QUERY = \"query\",\n}\n\nexport type FirestoreSnapshotType<T extends FirestoreDocOrQuery> = T extends FirestoreDocOrQuery.DOC\n ? DocumentSnapshot\n : QuerySnapshot;\n","import { FirestoreDocOrQuery } from \"../firestore/firestore.types\";\n\nexport 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): FirestoreDocOrQuery => {\n const withoutSurroundingSlashes = fullUrl.replace(/^\\/|\\/$/g, \"\");\n const pathElements = withoutSurroundingSlashes.split(\"/\").length;\n return pathElements % 2 === 0 ? FirestoreDocOrQuery.DOC : FirestoreDocOrQuery.QUERY;\n};\n","import { SocketAdapter } from \"@hyper-fetch/sockets\";\nimport type { Database } from \"firebase/database\";\nimport { onValue, query, ref, goOffline, goOnline } from \"firebase/database\";\n\nimport { getOrderedResultRealtime, mapRealtimeConstraint } from \"./utils\";\nimport { getStatus, isDocOrQuery } from \"utils\";\nimport type { RealtimeDbOnValueMethodExtra, RealtimeDBQueryParams, RealtimeSocketAdapterType } from \"adapter\";\nimport type { RealtimePermittedMethods } from \"../constraints\";\n\nexport const realtimeSockets = (database: Database): RealtimeSocketAdapterType => {\n return new SocketAdapter<RealtimeDbOnValueMethodExtra, undefined, { onlyOnce?: boolean } & RealtimeDBQueryParams>({\n name: \"firebase-realtime\",\n defaultConnected: true,\n }).setConnector(\n ({ socket, onConnect, onReconnect, onDisconnect, onListen, onConnected, onDisconnected, onEvent, onError }) => {\n const connect = async () => {\n const enabled = onConnect();\n\n if (enabled) {\n goOnline(database);\n onConnected();\n }\n };\n\n const disconnect = async () => {\n goOffline(database);\n onDisconnect();\n onDisconnected();\n };\n\n const reconnect = () => {\n onReconnect({ disconnect, connect });\n };\n\n const listen: RealtimeSocketAdapterType[\"listen\"] = (listener, callback) => {\n const fullUrl = socket.url + listener.topic;\n const path = ref(database, fullUrl);\n\n const { options } = listener;\n const onlyOnce = options?.onlyOnce || false;\n const params =\n options?.constraints?.map((constraint: RealtimePermittedMethods) => mapRealtimeConstraint(constraint)) || [];\n const queryConstraints = query(path, ...params);\n let unsubscribe = () => {};\n let unmount = () => {};\n let clearListeners = () => {};\n unsubscribe = onValue(\n queryConstraints,\n (snapshot) => {\n const response = isDocOrQuery(fullUrl) === \"doc\" ? snapshot.val() : getOrderedResultRealtime(snapshot);\n const status = getStatus(response);\n const extra = { 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 { onlyOnce },\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 Realtime database socket.\");\n };\n\n return {\n connect,\n reconnect,\n disconnect,\n listen,\n emit,\n };\n },\n );\n};\n","/* eslint-disable max-params */\nimport type { Database } from \"firebase/database\";\nimport { get, push, query, ref, remove, set, update } from \"firebase/database\";\nimport type { getAdapterBindings } from \"@hyper-fetch/core\";\n\nimport type { RealtimeDBMethodsUnion, RealtimeDBStatuses } from \"adapter/types\";\nimport { mapRealtimeConstraint, getOrderedResultRealtime } from \"./utils\";\nimport { getStatus, isDocOrQuery } from \"utils\";\nimport type {\n PermittedConstraints,\n RealtimeConstraintsUnion,\n RealtimePermittedMethods,\n SharedQueryConstraints,\n} from \"constraints\";\n\ntype DataType = {\n constraints: PermittedConstraints<RealtimePermittedMethods, RealtimeConstraintsUnion | SharedQueryConstraints>[];\n payload: any;\n options: Record<string, any>;\n};\n\nexport const getRealtimeDbBrowserMethods = ({\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}): ((methodName: RealtimeDBMethodsUnion, data: DataType) => Promise<void>) => {\n const [fullUrl] = url.split(\"?\");\n const path = ref(database, fullUrl);\n const methods = {\n get: async ({\n constraints = [],\n }: {\n constraints?: PermittedConstraints<RealtimePermittedMethods, RealtimeConstraintsUnion | SharedQueryConstraints>[];\n }) => {\n const params = constraints.map((constraint) => mapRealtimeConstraint(constraint));\n const q = query(path, ...params);\n const snapshot = await get(q);\n const res = isDocOrQuery(fullUrl) === \"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 set(path, data);\n return { result: data, status: \"success\", extra: { ref: path } };\n },\n push: async ({ data }: { data?: any }) => {\n const resRef = await push(path, 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 update(path, data);\n return { result: data, status: \"success\", extra: { ref: path } };\n },\n remove: async () => {\n await remove(path);\n return { result: null, status: \"success\", extra: { ref: path } };\n },\n };\n\n return async (methodName: RealtimeDBMethodsUnion, data: DataType) => {\n try {\n onRequestStart();\n const { result, status, extra } = await methods[methodName](data);\n onRequestEnd();\n onResponseStart();\n onSuccess({ data: result, status: status as RealtimeDBStatuses, extra });\n onResponseEnd();\n } catch (error) {\n onRequestEnd();\n onResponseStart();\n onError({\n error,\n status: \"error\",\n // TODO - fix this\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n extra: {},\n });\n onResponseEnd();\n }\n };\n};\n","import type { QuerySnapshot, DocumentData } from \"@firebase/firestore\";\n\nexport const getOrderedResultFirestore = (snapshot: QuerySnapshot<any>) => {\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 { endAt, endBefore, limit, orderBy, startAfter, startAt, where } from \"firebase/firestore\";\nimport type { OrderByDirection } from \"@firebase/firestore\";\n\nimport type { FirestorePermittedMethods } from \"constraints\";\nimport { FirestoreQueryConstraints, SharedQueryConstraints } from \"constraints\";\n\nexport const mapConstraint = ({ type, values }: FirestorePermittedMethods) => {\n switch (type) {\n case FirestoreQueryConstraints.WHERE: {\n const [fieldPath, strOp, value] = values;\n return where(fieldPath, strOp, value);\n }\n case FirestoreQueryConstraints.ORDER_BY: {\n const [field, ord] = values;\n return orderBy(field as string, ord as OrderByDirection);\n }\n case FirestoreQueryConstraints.LIMIT: {\n const [limitValue] = values;\n return limit(limitValue);\n }\n case SharedQueryConstraints.START_AT: {\n const [docOrFields] = values;\n return startAt(docOrFields);\n }\n case SharedQueryConstraints.START_AFTER: {\n const [docOrFields] = values;\n return startAfter(docOrFields);\n }\n case SharedQueryConstraints.END_AT: {\n const [docOrFields] = values;\n return endAt(docOrFields);\n }\n case SharedQueryConstraints.END_BEFORE: {\n const [docOrFields] = values;\n return endBefore(docOrFields);\n }\n default:\n throw new Error(`Unknown method ${type}`);\n }\n};\n","/* eslint-disable max-params */\nimport type { Firestore } from \"firebase/firestore\";\nimport { addDoc, collection, deleteDoc, doc, getDoc, getDocs, query, setDoc, updateDoc } from \"firebase/firestore\";\nimport type { getAdapterBindings } from \"@hyper-fetch/core\";\n\nimport type { FirestoreMethodsUnion } from \"adapter/types\";\nimport type {\n FirestoreConstraintsUnion,\n FirestorePermittedMethods,\n PermittedConstraints,\n SharedQueryConstraints,\n} from \"constraints\";\nimport { getStatus } from \"utils\";\nimport { getOrderedResultFirestore, mapConstraint } from \"./utils\";\n\ntype DataType = {\n constraints?: PermittedConstraints<FirestorePermittedMethods, FirestoreConstraintsUnion | SharedQueryConstraints>[];\n payload?: any;\n options?: Record<string, any>;\n};\n\nexport const getFirestoreBrowserMethods = ({\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 = doc(database, cleanUrl);\n const snapshot = await getDoc(path);\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 queryConstraints = constraints.map((constr) => mapConstraint(constr));\n const path = collection(database, cleanUrl);\n const q = query(path, ...queryConstraints);\n const querySnapshot = await getDocs(q);\n const result = getOrderedResultFirestore(querySnapshot);\n const status = getStatus(result);\n return { result, status, extra: { ref: path, snapshot: querySnapshot } };\n },\n setDoc: async ({ data, options }: { data?: any; options?: any }) => {\n const path = doc(database, cleanUrl);\n const merge = options?.merge === true;\n await setDoc(path, data, { merge });\n return { result: data, status: \"success\", extra: { ref: path } };\n },\n addDoc: async ({ data }: { data?: any }) => {\n const path = collection(database, cleanUrl);\n const docRef = await addDoc(path, data);\n return { result: { ...data, __key: docRef.id }, status: \"success\", extra: { ref: docRef } };\n },\n updateDoc: async ({ data }: { data?: any }) => {\n const path = doc(database, cleanUrl);\n await updateDoc(path, data);\n return { result: data, status: \"success\", extra: { ref: path } };\n },\n deleteDoc: async () => {\n const path = doc(database, cleanUrl);\n await deleteDoc(path);\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 { SocketAdapter } from \"@hyper-fetch/sockets\";\nimport type { Firestore, QuerySnapshot } from \"firebase/firestore\";\nimport { collection, disableNetwork, doc, enableNetwork, onSnapshot, query } from \"firebase/firestore\";\nimport type { DocumentSnapshot } from \"@firebase/firestore\";\n\nimport { getStatus, isDocOrQuery } from \"utils\";\nimport { getGroupedResultFirestore, getOrderedResultFirestore, mapConstraint } from \"./utils\";\nimport type { FirestoreOnSnapshotExtra, FirestoreQueryParams, FirestoreSocketAdapterType } from \"adapter\";\nimport type { FirestoreSnapshotType } from \"./firestore.types\";\nimport { FirestoreDocOrQuery } from \"./firestore.types\";\nimport type { FirestorePermittedMethods } from \"../constraints\";\n\nexport const firestoreSockets = (database: Firestore): FirestoreSocketAdapterType => {\n return new SocketAdapter<FirestoreOnSnapshotExtra, undefined, { groupByChangeType?: boolean } & FirestoreQueryParams>(\n {\n name: \"firebase-firestore\",\n defaultConnected: true,\n },\n ).setConnector(\n ({ socket, onConnect, onReconnect, onDisconnect, onListen, onConnected, onDisconnected, onEvent, onError }) => {\n const connect = async () => {\n const enabled = onConnect();\n\n if (enabled) {\n enableNetwork(database);\n onConnected();\n }\n };\n\n const disconnect = async () => {\n disableNetwork(database);\n onDisconnect();\n onDisconnected();\n };\n\n const reconnect = () => {\n onReconnect({ disconnect, connect });\n };\n\n const listen: FirestoreSocketAdapterType[\"listen\"] = (listener, callback) => {\n const fullUrl = socket.url + listener.topic;\n const { options } = listener;\n\n let path: any;\n const queryType = isDocOrQuery(fullUrl);\n if (queryType === FirestoreDocOrQuery.DOC) {\n path = doc(database, fullUrl);\n } else {\n const constraints = options?.constraints || [];\n const queryConstraints = constraints.map((constr: FirestorePermittedMethods) => mapConstraint(constr)) || [];\n path = query(collection(database, fullUrl), ...queryConstraints);\n }\n let unsubscribe = () => {};\n let unmount = () => {};\n let clearListeners = () => {};\n\n unsubscribe = onSnapshot(\n path,\n (snapshot: FirestoreSnapshotType<typeof queryType>) => {\n const getDocData = (s: DocumentSnapshot) => (s.data() ? { ...s.data(), __key: s.id } : null);\n const response =\n queryType === FirestoreDocOrQuery.DOC\n ? getDocData(snapshot as DocumentSnapshot)\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: path, snapshot, 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 listen,\n emit,\n };\n },\n );\n};\n","import { Adapter } from \"@hyper-fetch/core\";\nimport { Database } from \"firebase/database\";\n\nimport type { FirebaseDBTypes, FirebaseAdapterTypes, FirebaseRealtimeDBType, FirestoreRequestType } from \"adapter\";\nimport { FirestoreMethods, RealtimeDBMethods } from \"adapter\";\nimport { getRealtimeDbBrowserMethods } from \"realtime\";\nimport { getFirestoreBrowserMethods } from \"firestore\";\n\nexport const FirebaseAdapter = <T extends FirebaseDBTypes>(database: T): FirebaseAdapterTypes<T> => {\n const adapter = new Adapter({\n name: \"firebase\",\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\n if (database instanceof Database) {\n const { method = RealtimeDBMethods.get, queryParams, payload, options } = request as FirebaseRealtimeDBType;\n\n const availableMethods = getRealtimeDbBrowserMethods({\n database,\n url: fullUrl,\n onSuccess,\n onError,\n onResponseStart,\n onResponseEnd,\n onRequestStart,\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 || [],\n options,\n payload,\n });\n } else {\n const { method = FirestoreMethods.getDocs, queryParams, payload, options } = request as FirestoreRequestType;\n const availableMethods = getFirestoreBrowserMethods({\n database,\n url: fullUrl,\n onSuccess,\n onError,\n onResponseStart,\n onResponseEnd,\n onRequestStart,\n onRequestEnd,\n });\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 }\n },\n );\n\n return adapter as unknown as FirebaseAdapterTypes<T>;\n};\n","import { Database } from \"firebase/database\";\nimport { Firestore } from \"firebase/firestore\";\n\nimport type { FirebaseDBTypes, FirebaseSocketAdapterTypes } from \"adapter/index\";\nimport { realtimeSockets } from \"realtime\";\nimport { firestoreSockets } from \"firestore\";\n\nexport const FirebaseSocketsAdapter = <T extends FirebaseDBTypes>(database: T): FirebaseSocketAdapterTypes<T> => {\n if (database instanceof Database) {\n return realtimeSockets(database) as unknown as FirebaseSocketAdapterTypes<T>;\n }\n if (database instanceof Firestore) {\n return firestoreSockets(database) as unknown as FirebaseSocketAdapterTypes<T>;\n }\n throw new Error(\"Unknown database type\");\n};\n"],"mappings":";;;;;AAwDA,IAAY,mBAAL,yBAAA,kBAAA;AACL,kBAAA,YAAA;AACA,kBAAA,YAAA;AACA,kBAAA,aAAA;AACA,kBAAA,YAAA;AACA,kBAAA,eAAA;AACA,kBAAA,eAAA;;KACD;;;ACfD,IAAY,oBAAL,yBAAA,mBAAA;AACL,mBAAA,SAAA;AACA,mBAAA,UAAA;AAC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;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,eAAe,EAAE;IAC3C;IACA;IACD,CAAC;SACG;GACL,MAAM,EAAE,SAAS,iBAAiB,SAAS,aAAa,SAAS,YAAY;GAC7E,MAAM,mBAAmB,2BAA2B;IAClD;IACA,KAAK;IACL;IACA;IACA;IACA;IACA;IACA;IACD,CAAC;AAEF,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;;GAGP;;;;ACxDH,IAAa,0BAAqD,aAA+C;AAC/G,KAAI,oBAAoB,SACtB,QAAO,gBAAgB,SAAS;AAElC,KAAI,oBAAoB,UACtB,QAAO,iBAAiB,SAAS;AAEnC,OAAM,IAAI,MAAM,wBAAwB"}
@@ -0,0 +1,4 @@
1
+ export * from './utils';
2
+ export * from './realtime.sockets';
3
+ export * from './realtime.methods';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -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,21 @@
1
+ import { Database } from 'firebase/database';
2
+ import { getAdapterBindings } from '@hyper-fetch/core';
3
+ import { RealtimeDBMethodsUnion } from '../adapter/types';
4
+ import { PermittedConstraints, RealtimeConstraintsUnion, RealtimePermittedMethods, SharedQueryConstraints } from '../constraints';
5
+ type DataType = {
6
+ constraints: PermittedConstraints<RealtimePermittedMethods, RealtimeConstraintsUnion | SharedQueryConstraints>[];
7
+ payload: any;
8
+ options: Record<string, any>;
9
+ };
10
+ export declare const getRealtimeDbBrowserMethods: ({ database, url, onSuccess, onError, onResponseStart, onRequestStart, onRequestEnd, onResponseEnd, }: {
11
+ database: Database;
12
+ url: string;
13
+ onSuccess: Awaited<ReturnType<typeof getAdapterBindings>>["onSuccess"];
14
+ onError: Awaited<ReturnType<typeof getAdapterBindings>>["onError"];
15
+ onResponseStart: Awaited<ReturnType<typeof getAdapterBindings>>["onResponseStart"];
16
+ onRequestStart: Awaited<ReturnType<typeof getAdapterBindings>>["onRequestStart"];
17
+ onRequestEnd: Awaited<ReturnType<typeof getAdapterBindings>>["onRequestEnd"];
18
+ onResponseEnd: Awaited<ReturnType<typeof getAdapterBindings>>["onResponseEnd"];
19
+ }) => ((methodName: RealtimeDBMethodsUnion, data: DataType) => Promise<void>);
20
+ export {};
21
+ //# 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,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,KAAK,EAAE,sBAAsB,EAAsB,MAAM,eAAe,CAAC;AAGhF,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAErB,KAAK,QAAQ,GAAG;IACd,WAAW,EAAE,oBAAoB,CAAC,wBAAwB,EAAE,wBAAwB,GAAG,sBAAsB,CAAC,EAAE,CAAC;IACjH,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,sGASzC;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACvE,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACnE,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACnF,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;IACjF,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;IAC7E,aAAa,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;CAChF,KAAG,CAAC,CAAC,UAAU,EAAE,sBAAsB,EAAE,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAwDzE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Database } from 'firebase/database';
2
+ import { RealtimeSocketAdapterType } from '../adapter';
3
+ export declare const realtimeSockets: (database: Database) => RealtimeSocketAdapterType;
4
+ //# sourceMappingURL=realtime.sockets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"realtime.sockets.d.ts","sourceRoot":"","sources":["../../src/realtime/realtime.sockets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAKlD,OAAO,KAAK,EAAuD,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAG9G,eAAO,MAAM,eAAe,GAAI,UAAU,QAAQ,KAAG,yBAyEpD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { RealtimePermittedMethods } from '../../constraints';
2
+ export declare const mapRealtimeConstraint: ({ type, values }: RealtimePermittedMethods) => import('@firebase/database').QueryConstraint;
3
+ //# 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,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAG5D,eAAO,MAAM,qBAAqB,GAAI,kBAAkB,wBAAwB,iDA2C/E,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './result.utils';
2
+ export * from './constraints.utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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,3 @@
1
+ import { DataSnapshot } from '@firebase/database';
2
+ export declare const getOrderedResultRealtime: (snapshot: DataSnapshot) => any[] | null;
3
+ //# sourceMappingURL=result.utils.d.ts.map
@@ -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,oBAAoB,CAAC;AAEvD,eAAO,MAAM,wBAAwB,GAAI,UAAU,YAAY,iBAM9D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './misc';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { FirestoreDocOrQuery } from '../firestore/firestore.types';
2
+ export declare const getStatus: (res: any) => "success" | "emptyResource";
3
+ export declare const isDocOrQuery: (fullUrl: string) => FirestoreDocOrQuery;
4
+ //# sourceMappingURL=misc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../src/utils/misc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,eAAO,MAAM,SAAS,GAAI,KAAK,GAAG,gCAGjC,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,mBAI9C,CAAC"}
package/package.json CHANGED
@@ -1,27 +1,24 @@
1
1
  {
2
2
  "name": "@hyper-fetch/firebase",
3
- "version": "7.5.2",
3
+ "version": "8.0.0",
4
4
  "description": "First class Firebase Web 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.js",
9
- "module": "dist/index.js",
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
- "clean": "npx rimraf dist",
14
- "test": "firebase emulators:exec 'jest --watchAll=false --detectOpenHandles --forceExit --runInBand'",
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": "yarn clean && node ../../scripts/build.js",
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
- "typescheck": "tsc --noEmit --emitDeclarationOnly false",
24
- "tests": "firebase emulators:exec 'jest --watchAll=false --detectOpenHandles --forceExit --runInBand'",
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-v${version}'"
26
23
  },
27
24
  "publishConfig": {
package/project.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "firebase",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json"
4
+ }
@@ -1,7 +1,7 @@
1
1
  import { Database } from "firebase/database";
2
2
  import { Firestore } from "firebase/firestore";
3
3
 
4
- import { FirebaseDBTypes, FirebaseSocketAdapterTypes } from "adapter/index";
4
+ import type { FirebaseDBTypes, FirebaseSocketAdapterTypes } from "adapter/index";
5
5
  import { realtimeSockets } from "realtime";
6
6
  import { firestoreSockets } from "firestore";
7
7
 
@@ -1,27 +1,19 @@
1
1
  import { Adapter } from "@hyper-fetch/core";
2
2
  import { Database } from "firebase/database";
3
3
 
4
- import {
5
- FirebaseDBTypes,
6
- FirestoreMethods,
7
- RealtimeDBMethods,
8
- FirebaseRealtimeDBType,
9
- FirestoreRequestType,
10
- FirestoreAdapterType,
11
- } from "adapter";
4
+ import type { FirebaseDBTypes, FirebaseAdapterTypes, FirebaseRealtimeDBType, FirestoreRequestType } from "adapter";
5
+ import { FirestoreMethods, RealtimeDBMethods } from "adapter";
12
6
  import { getRealtimeDbBrowserMethods } from "realtime";
13
7
  import { getFirestoreBrowserMethods } from "firestore";
14
8
 
15
- export const FirebaseAdapter = <T extends FirebaseDBTypes>(database: T): FirestoreAdapterType => {
16
- return (
17
- new Adapter({
18
- name: "firebase",
19
- defaultMethod: "getDoc",
20
- defaultExtra: {},
21
- systemErrorStatus: "error",
22
- systemErrorExtra: {},
23
- }) as unknown as FirestoreAdapterType
24
- ).setFetcher(
9
+ export const FirebaseAdapter = <T extends FirebaseDBTypes>(database: T): FirebaseAdapterTypes<T> => {
10
+ const adapter = new Adapter({
11
+ name: "firebase",
12
+ defaultMethod: "getDoc",
13
+ defaultExtra: {},
14
+ systemErrorStatus: "error",
15
+ systemErrorExtra: {},
16
+ }).setFetcher(
25
17
  async ({ request, onSuccess, onError, onResponseStart, onResponseEnd, onRequestStart, onRequestEnd }) => {
26
18
  const fullUrl = `${request.client.url}${request.endpoint}`;
27
19
 
@@ -70,4 +62,6 @@ export const FirebaseAdapter = <T extends FirebaseDBTypes>(database: T): Firesto
70
62
  }
71
63
  },
72
64
  );
65
+
66
+ return adapter as unknown as FirebaseAdapterTypes<T>;
73
67
  };
@@ -1,8 +1,8 @@
1
- import { Database } from "firebase/database";
2
- import { Firestore } from "firebase/firestore";
3
- import { Adapter, Request, Client } from "@hyper-fetch/core";
1
+ import type { Database } from "firebase/database";
2
+ import type { Firestore } from "firebase/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
  RealtimeSocketAdapterType,
@@ -1,16 +1,16 @@
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";
11
- import { DocumentData } from "@firebase/firestore";
10
+ import type { SocketAdapter } from "@hyper-fetch/sockets";
11
+ import type { DocumentData } from "@firebase/firestore";
12
12
 
13
- import {
13
+ import type {
14
14
  FirestoreConstraintsUnion,
15
15
  FirestorePermittedMethods,
16
16
  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,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  $endAt,
3
3
  $endBefore,
4
4
  $equalTo,
@@ -1,4 +1,4 @@
1
- import { OrderByDirection, WhereFilterOp } from "firebase/firestore";
1
+ import type { OrderByDirection, WhereFilterOp } from "firebase/firestore";
2
2
 
3
3
  export enum SharedQueryConstraints {
4
4
  START_AT = "startAt",
@@ -1,20 +1,10 @@
1
1
  /* eslint-disable max-params */
2
- import {
3
- addDoc,
4
- collection,
5
- deleteDoc,
6
- doc,
7
- Firestore,
8
- getDoc,
9
- getDocs,
10
- query,
11
- setDoc,
12
- updateDoc,
13
- } from "firebase/firestore";
14
- import { getAdapterBindings } from "@hyper-fetch/core";
2
+ import type { Firestore } from "firebase/firestore";
3
+ import { addDoc, collection, deleteDoc, doc, getDoc, getDocs, query, setDoc, updateDoc } from "firebase/firestore";
4
+ import type { getAdapterBindings } from "@hyper-fetch/core";
15
5
 
16
- import { FirestoreMethodsUnion } from "adapter/types";
17
- import {
6
+ import type { FirestoreMethodsUnion } from "adapter/types";
7
+ import type {
18
8
  FirestoreConstraintsUnion,
19
9
  FirestorePermittedMethods,
20
10
  PermittedConstraints,
@@ -1,21 +1,14 @@
1
1
  import { SocketAdapter } from "@hyper-fetch/sockets";
2
- import {
3
- collection,
4
- disableNetwork,
5
- doc,
6
- enableNetwork,
7
- Firestore,
8
- onSnapshot,
9
- query,
10
- QuerySnapshot,
11
- } from "firebase/firestore";
12
- import { DocumentSnapshot } from "@firebase/firestore";
2
+ import type { Firestore, QuerySnapshot } from "firebase/firestore";
3
+ import { collection, disableNetwork, doc, enableNetwork, onSnapshot, query } from "firebase/firestore";
4
+ import type { DocumentSnapshot } from "@firebase/firestore";
13
5
 
14
6
  import { getStatus, isDocOrQuery } from "utils";
15
7
  import { getGroupedResultFirestore, getOrderedResultFirestore, mapConstraint } from "./utils";
16
- import { FirestoreOnSnapshotExtra, FirestoreQueryParams, FirestoreSocketAdapterType } from "adapter";
17
- import { FirestoreDocOrQuery, FirestoreSnapshotType } from "./firestore.types";
18
- import { FirestorePermittedMethods } from "../constraints";
8
+ import type { FirestoreOnSnapshotExtra, FirestoreQueryParams, FirestoreSocketAdapterType } from "adapter";
9
+ import type { FirestoreSnapshotType } from "./firestore.types";
10
+ import { FirestoreDocOrQuery } from "./firestore.types";
11
+ import type { FirestorePermittedMethods } from "../constraints";
19
12
 
20
13
  export const firestoreSockets = (database: Firestore): FirestoreSocketAdapterType => {
21
14
  return new SocketAdapter<FirestoreOnSnapshotExtra, undefined, { groupByChangeType?: boolean } & FirestoreQueryParams>(
@@ -1,5 +1,5 @@
1
- import { DocumentSnapshot } from "@firebase/firestore";
2
- import { QuerySnapshot } from "firebase/firestore";
1
+ import type { DocumentSnapshot } from "@firebase/firestore";
2
+ import type { QuerySnapshot } from "firebase/firestore";
3
3
 
4
4
  export enum FirestoreDocOrQuery {
5
5
  DOC = "doc",
@@ -1,7 +1,8 @@
1
1
  import { endAt, endBefore, limit, orderBy, startAfter, startAt, where } from "firebase/firestore";
2
- import { OrderByDirection } from "@firebase/firestore";
2
+ import type { OrderByDirection } from "@firebase/firestore";
3
3
 
4
- import { FirestorePermittedMethods, FirestoreQueryConstraints, SharedQueryConstraints } from "constraints";
4
+ import type { FirestorePermittedMethods } from "constraints";
5
+ import { FirestoreQueryConstraints, SharedQueryConstraints } from "constraints";
5
6
 
6
7
  export const mapConstraint = ({ type, values }: FirestorePermittedMethods) => {
7
8
  switch (type) {
@@ -1,4 +1,4 @@
1
- import { QuerySnapshot, DocumentData } from "@firebase/firestore";
1
+ import type { QuerySnapshot, DocumentData } from "@firebase/firestore";
2
2
 
3
3
  export const getOrderedResultFirestore = (snapshot: QuerySnapshot<any>) => {
4
4
  const result: (DocumentData & { __key: string })[] = [];
@@ -1,11 +1,12 @@
1
1
  /* eslint-disable max-params */
2
- import { Database, get, push, query, ref, remove, set, update } from "firebase/database";
3
- import { getAdapterBindings } from "@hyper-fetch/core";
2
+ import type { Database } from "firebase/database";
3
+ import { get, push, query, ref, remove, set, update } from "firebase/database";
4
+ import type { getAdapterBindings } from "@hyper-fetch/core";
4
5
 
5
- import { RealtimeDBMethodsUnion, RealtimeDBStatuses } from "adapter/types";
6
+ import type { RealtimeDBMethodsUnion, RealtimeDBStatuses } from "adapter/types";
6
7
  import { mapRealtimeConstraint, getOrderedResultRealtime } from "./utils";
7
8
  import { getStatus, isDocOrQuery } from "utils";
8
- import {
9
+ import type {
9
10
  PermittedConstraints,
10
11
  RealtimeConstraintsUnion,
11
12
  RealtimePermittedMethods,
@@ -1,10 +1,11 @@
1
1
  import { SocketAdapter } from "@hyper-fetch/sockets";
2
- import { onValue, query, Database, ref, goOffline, goOnline } from "firebase/database";
2
+ import type { Database } from "firebase/database";
3
+ import { onValue, query, ref, goOffline, goOnline } from "firebase/database";
3
4
 
4
5
  import { getOrderedResultRealtime, mapRealtimeConstraint } from "./utils";
5
6
  import { getStatus, isDocOrQuery } from "utils";
6
- import { RealtimeDbOnValueMethodExtra, RealtimeDBQueryParams, RealtimeSocketAdapterType } from "adapter";
7
- import { RealtimePermittedMethods } from "../constraints";
7
+ import type { RealtimeDbOnValueMethodExtra, RealtimeDBQueryParams, RealtimeSocketAdapterType } from "adapter";
8
+ import type { RealtimePermittedMethods } from "../constraints";
8
9
 
9
10
  export const realtimeSockets = (database: Database): RealtimeSocketAdapterType => {
10
11
  return new SocketAdapter<RealtimeDbOnValueMethodExtra, undefined, { onlyOnce?: boolean } & RealtimeDBQueryParams>({
@@ -11,7 +11,8 @@ import {
11
11
  startAt,
12
12
  } from "firebase/database";
13
13
 
14
- import { RealtimePermittedMethods, RealtimeQueryConstraints, SharedQueryConstraints } from "constraints";
14
+ import type { RealtimePermittedMethods } from "constraints";
15
+ import { RealtimeQueryConstraints, SharedQueryConstraints } from "constraints";
15
16
 
16
17
  export const mapRealtimeConstraint = ({ type, values }: RealtimePermittedMethods) => {
17
18
  switch (type) {
@@ -1,4 +1,4 @@
1
- import { DataSnapshot } from "@firebase/database";
1
+ import type { DataSnapshot } from "@firebase/database";
2
2
 
3
3
  export const getOrderedResultRealtime = (snapshot: DataSnapshot) => {
4
4
  const res: any[] = [];
package/tsconfig.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "rootDir": ".",
5
5
  "baseUrl": "./src"
6
6
  },
7
- "exclude": ["node_modules", "dist", "jest.config.ts", "__tests__"]
7
+ "exclude": ["node_modules", "dist", "vite.config.ts", "__tests__"]
8
8
  }
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
- }