@hyper-fetch/firebase 7.5.3 → 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/shared/constraints.shared.tests.ts +3 -3
- package/__tests__/features/firestore/shared/methods/add-doc.test.suite.ts +2 -2
- package/__tests__/features/firestore/shared/methods/delete-doc.test.suite.ts +2 -2
- package/__tests__/features/firestore/shared/methods/get-doc.test.suite.ts +2 -2
- package/__tests__/features/firestore/shared/methods/get-docs.test.suite.ts +2 -2
- package/__tests__/features/firestore/shared/methods/on-snapshot.test.suite.ts +9 -9
- package/__tests__/features/firestore/shared/methods/set-doc.test.suite.ts +2 -2
- package/__tests__/features/firestore/shared/methods/update-doc.test.suite.ts +2 -2
- package/__tests__/features/firestore/shared/methods.shared.tests.ts +1 -1
- package/__tests__/features/firestore/web/constraints.web.spec.ts +1 -1
- package/__tests__/features/firestore/web/methods.web.spec.ts +1 -1
- package/__tests__/features/firestore/web/sockets.base.spec.ts +1 -1
- package/__tests__/features/realtime/shared/constraints.shared.tests.ts +2 -5
- package/__tests__/features/realtime/shared/methods/get.test.suite.ts +2 -2
- package/__tests__/features/realtime/shared/methods/on-value.test.suite.ts +8 -8
- package/__tests__/features/realtime/shared/methods/push.test.suite.ts +3 -3
- package/__tests__/features/realtime/shared/methods/remove.test.suite.ts +4 -5
- package/__tests__/features/realtime/shared/methods/set.test.suite.ts +6 -8
- package/__tests__/features/realtime/shared/methods/update.test.suite.ts +2 -2
- package/__tests__/features/realtime/shared/methods.shared.tests.ts +1 -1
- package/__tests__/shared/request-events.shared.ts +7 -7
- package/__tests__/tsconfig.json +15 -2
- package/__tests__/utils/browser/clean.browser.ts +2 -1
- package/__tests__/utils/browser/seed.browser.ts +4 -2
- 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 +46 -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/index.d.ts +4 -0
- package/dist/adapter/types/index.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/firestore.types.d.ts +8 -0
- package/dist/firestore/firestore.types.d.ts.map +1 -0
- package/dist/firestore/index.d.ts +5 -0
- package/dist/firestore/index.d.ts.map +1 -0
- package/dist/firestore/utils/constraints.utils.d.ts +3 -0
- package/dist/firestore/utils/constraints.utils.d.ts.map +1 -0
- package/dist/firestore/utils/index.d.ts +3 -0
- package/dist/firestore/utils/index.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 -250
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +664 -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 +21 -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 +3 -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/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/misc.d.ts +4 -0
- package/dist/utils/misc.d.ts.map +1 -0
- package/package.json +8 -11
- package/src/adapter/adapter.sockets.ts +1 -1
- package/src/adapter/adapter.ts +12 -18
- package/src/adapter/types/adapter.base.types.ts +4 -4
- package/src/adapter/types/adapter.firestore.types.ts +5 -5
- package/src/adapter/types/adapter.realtime.types.ts +4 -4
- package/src/constraints/constraints.types.ts +1 -1
- package/src/constraints/firebase.constraints.ts +1 -1
- package/src/firestore/firestore.methods.ts +5 -15
- package/src/firestore/firestore.sockets.ts +7 -14
- package/src/firestore/firestore.types.ts +2 -2
- package/src/firestore/utils/constraints.utils.ts +3 -2
- package/src/firestore/utils/result.utils.ts +1 -1
- package/src/realtime/realtime.methods.ts +5 -4
- package/src/realtime/realtime.sockets.ts +4 -3
- package/src/realtime/utils/constraints.utils.ts +2 -1
- package/src/realtime/utils/result.utils.ts +1 -1
- package/tsconfig.json +1 -1
- package/vite.config.ts +45 -0
- package/.eslintrc.json +0 -11
- package/__tests__/global.d.ts +0 -1
- package/__tests__/jest.setup.ts +0 -8
- package/dist/index.js +0 -728
- package/dist/index.js.map +0 -7
- package/jest.config.ts +0 -9
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ["plugin:@nx/react", "../../.eslintrc.js"],
|
|
3
|
+
parserOptions: {
|
|
4
|
+
tsconfigRootDir: __dirname,
|
|
5
|
+
project: ["./tsconfig.json", "./__tests__/tsconfig.json"],
|
|
6
|
+
},
|
|
7
|
+
rules: {
|
|
8
|
+
"react/jsx-props-no-spreading": 0,
|
|
9
|
+
"react/require-default-props": 0,
|
|
10
|
+
},
|
|
11
|
+
ignorePatterns: ["dist/", "coverage/", "vite.config.ts", "/*.js"],
|
|
12
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Client } from "@hyper-fetch/core";
|
|
1
|
+
import type { Client } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
|
-
import { FirestoreAdapterType, FirestoreQueryParams } from "adapter";
|
|
3
|
+
import type { FirestoreAdapterType, FirestoreQueryParams } from "adapter";
|
|
4
4
|
import { $limit, $orderBy, $where } from "constraints";
|
|
5
|
-
import { Tea } from "../../../utils";
|
|
5
|
+
import type { Tea } from "../../../utils";
|
|
6
6
|
|
|
7
7
|
export const constraintsSharedTestCases = (client: Client<Error, FirestoreAdapterType>) => {
|
|
8
8
|
describe("filtering", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Client } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
|
-
import { FirebaseAdapter } from "adapter";
|
|
4
|
-
import { Tea } from "../../../../utils";
|
|
3
|
+
import type { FirebaseAdapter } from "adapter";
|
|
4
|
+
import type { Tea } from "../../../../utils";
|
|
5
5
|
|
|
6
6
|
export const addDocTestSuite = (adapterFunction: () => ReturnType<typeof FirebaseAdapter>) => {
|
|
7
7
|
describe("addDoc", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Client } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
|
-
import { FirebaseAdapter } from "adapter";
|
|
4
|
-
import { Tea } from "../../../../utils";
|
|
3
|
+
import type { FirebaseAdapter } from "adapter";
|
|
4
|
+
import type { Tea } from "../../../../utils";
|
|
5
5
|
import { testLifecycleEvents } from "../../../../shared/request-events.shared";
|
|
6
6
|
|
|
7
7
|
export const deleteDocTestSuite = (adapterFunction: () => ReturnType<typeof FirebaseAdapter>) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Client } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
|
-
import { FirebaseAdapter } from "adapter";
|
|
4
|
-
import { Tea } from "../../../../utils";
|
|
3
|
+
import type { FirebaseAdapter } from "adapter";
|
|
4
|
+
import type { Tea } from "../../../../utils";
|
|
5
5
|
import { testLifecycleEvents } from "../../../../shared/request-events.shared";
|
|
6
6
|
|
|
7
7
|
export const getDocTestSuite = (adapterFunction: () => ReturnType<typeof FirebaseAdapter>) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Client } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
|
-
import { FirebaseAdapter } from "adapter";
|
|
4
|
-
import { Tea } from "../../../../utils";
|
|
3
|
+
import type { FirebaseAdapter } from "adapter";
|
|
4
|
+
import type { Tea } from "../../../../utils";
|
|
5
5
|
import { testLifecycleEvents } from "../../../../shared/request-events.shared";
|
|
6
6
|
|
|
7
7
|
export const getDocsTestSuite = (adapterFunction: () => ReturnType<typeof FirebaseAdapter>) => {
|
|
@@ -2,20 +2,20 @@ import { Client } from "@hyper-fetch/core";
|
|
|
2
2
|
import { Socket } from "@hyper-fetch/sockets";
|
|
3
3
|
import waitForExpect from "wait-for-expect";
|
|
4
4
|
|
|
5
|
-
import { FirebaseAdapterTypes, FirebaseSocketAdapterTypes } from "adapter";
|
|
5
|
+
import type { FirebaseAdapterTypes, FirebaseSocketAdapterTypes } from "adapter";
|
|
6
6
|
import { $where } from "constraints";
|
|
7
|
-
import { Tea } from "../../../../utils";
|
|
7
|
+
import type { Tea } from "../../../../utils";
|
|
8
8
|
|
|
9
9
|
export const onSnapshotTestSuite = (
|
|
10
10
|
adapter: FirebaseSocketAdapterTypes<any>,
|
|
11
11
|
coreAdapter: () => FirebaseAdapterTypes<any>,
|
|
12
12
|
) => {
|
|
13
13
|
const newData = { origin: "Poland", type: "Green", year: 2043, name: "Pou Ran Do Cha", amount: 100 } as Tea;
|
|
14
|
-
let spy =
|
|
14
|
+
let spy = vi.fn();
|
|
15
15
|
beforeEach(() => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
spy =
|
|
16
|
+
vi.resetAllMocks();
|
|
17
|
+
vi.clearAllMocks();
|
|
18
|
+
spy = vi.fn();
|
|
19
19
|
});
|
|
20
20
|
const initialize = async () => {
|
|
21
21
|
const client = new Client({ url: "teas/" }).setAdapter(coreAdapter());
|
|
@@ -37,7 +37,7 @@ export const onSnapshotTestSuite = (
|
|
|
37
37
|
topic: "",
|
|
38
38
|
});
|
|
39
39
|
const unmount = onSnapshotReq.listen(spy);
|
|
40
|
-
expect(unmount).
|
|
40
|
+
expect(typeof unmount).toBe("function");
|
|
41
41
|
});
|
|
42
42
|
it("should unmount listeners", async () => {
|
|
43
43
|
const { socket, pushReq } = await initialize();
|
|
@@ -251,7 +251,7 @@ export const onSnapshotTestSuite = (
|
|
|
251
251
|
|
|
252
252
|
await waitForExpect(async () => {
|
|
253
253
|
expect(receivedData).toHaveLength(1);
|
|
254
|
-
expect(receivedData[0]).
|
|
254
|
+
expect(receivedData[0]).toEqual(expect.arrayContaining(initialCache));
|
|
255
255
|
}, 1000);
|
|
256
256
|
|
|
257
257
|
const shouldCacheData = newData as Tea;
|
|
@@ -283,7 +283,7 @@ export const onSnapshotTestSuite = (
|
|
|
283
283
|
|
|
284
284
|
await waitForExpect(async () => {
|
|
285
285
|
expect(receivedData).toHaveLength(2);
|
|
286
|
-
expect(receivedData[1]).
|
|
286
|
+
expect(receivedData[1]).toEqual(expect.arrayContaining([...initialCache, data]));
|
|
287
287
|
});
|
|
288
288
|
});
|
|
289
289
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Client } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
|
-
import { Tea } from "../../../../utils";
|
|
4
|
-
import { FirebaseAdapter } from "adapter";
|
|
3
|
+
import type { Tea } from "../../../../utils";
|
|
4
|
+
import type { FirebaseAdapter } from "adapter";
|
|
5
5
|
import { testLifecycleEvents } from "../../../../shared/request-events.shared";
|
|
6
6
|
|
|
7
7
|
export const setDocTestSuite = (adapterFunction: () => ReturnType<typeof FirebaseAdapter>) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Client } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
|
-
import { FirebaseAdapter } from "adapter";
|
|
4
|
-
import { Tea } from "../../../../utils";
|
|
3
|
+
import type { FirebaseAdapter } from "adapter";
|
|
4
|
+
import type { Tea } from "../../../../utils";
|
|
5
5
|
import { testLifecycleEvents } from "../../../../shared/request-events.shared";
|
|
6
6
|
|
|
7
7
|
export const updateDocTestSuite = (adapterFunction: () => ReturnType<typeof FirebaseAdapter>) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FirebaseAdapter, FirebaseAdapterTypes, FirebaseSocketAdapterTypes } from "adapter";
|
|
1
|
+
import type { FirebaseAdapter, FirebaseAdapterTypes, FirebaseSocketAdapterTypes } from "adapter";
|
|
2
2
|
import { addDocTestSuite } from "./methods/add-doc.test.suite";
|
|
3
3
|
import { onSnapshotTestSuite } from "./methods/on-snapshot.test.suite";
|
|
4
4
|
import { deleteDocTestSuite } from "./methods/delete-doc.test.suite";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Client } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
3
|
import { $endAt, $limitToFirst, $orderByChild, $startAt } from "constraints";
|
|
4
|
-
import { FirebaseAdapter } from "adapter";
|
|
5
|
-
import { Tea } from "../../../utils";
|
|
4
|
+
import type { FirebaseAdapter } from "adapter";
|
|
5
|
+
import type { Tea } from "../../../utils";
|
|
6
6
|
|
|
7
7
|
export const constraintsSharedTestCases = (adapterFunction: () => ReturnType<typeof FirebaseAdapter>) => {
|
|
8
8
|
describe("Ordering", () => {
|
|
@@ -13,7 +13,6 @@ export const constraintsSharedTestCases = (adapterFunction: () => ReturnType<typ
|
|
|
13
13
|
method: "getDocs",
|
|
14
14
|
});
|
|
15
15
|
const { data } = await req.send({
|
|
16
|
-
// TODO: Fix this
|
|
17
16
|
queryParams: { constraints: [$orderByChild("origin")] },
|
|
18
17
|
});
|
|
19
18
|
expect(data!.map((el) => el.origin)).toStrictEqual([
|
|
@@ -38,7 +37,6 @@ export const constraintsSharedTestCases = (adapterFunction: () => ReturnType<typ
|
|
|
38
37
|
method: "getDocs",
|
|
39
38
|
});
|
|
40
39
|
const { data } = await req.send({
|
|
41
|
-
// TODO: Fix this
|
|
42
40
|
queryParams: { constraints: [$orderByChild("origin"), $limitToFirst(5)] },
|
|
43
41
|
});
|
|
44
42
|
expect(data!.map((tea) => tea.origin)).toStrictEqual(["China", "China", "China", "China", "China"]);
|
|
@@ -50,7 +48,6 @@ export const constraintsSharedTestCases = (adapterFunction: () => ReturnType<typ
|
|
|
50
48
|
method: "getDocs",
|
|
51
49
|
});
|
|
52
50
|
const { data } = await req.send({
|
|
53
|
-
// TODO: Fix this
|
|
54
51
|
queryParams: { constraints: [$orderByChild("year"), $startAt(2021), $endAt(2022)] },
|
|
55
52
|
});
|
|
56
53
|
expect(data).toHaveLength(5);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Client } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
|
-
import { FirebaseAdapter } from "adapter";
|
|
3
|
+
import type { FirebaseAdapter } from "adapter";
|
|
4
4
|
import { testLifecycleEvents } from "../../../../shared/request-events.shared";
|
|
5
|
-
import { Tea } from "../../../../utils";
|
|
5
|
+
import type { Tea } from "../../../../utils";
|
|
6
6
|
|
|
7
7
|
export const getTestSuite = (adapterFunction: () => ReturnType<typeof FirebaseAdapter>) => {
|
|
8
8
|
describe("get", () => {
|
|
@@ -3,8 +3,8 @@ import { Socket } from "@hyper-fetch/sockets";
|
|
|
3
3
|
import { Client } from "@hyper-fetch/core";
|
|
4
4
|
import waitForExpect from "wait-for-expect";
|
|
5
5
|
|
|
6
|
-
import { FirebaseAdapterTypes, FirebaseDBTypes, FirebaseSocketAdapterTypes } from "adapter";
|
|
7
|
-
import { Tea } from "../../../../utils";
|
|
6
|
+
import type { FirebaseAdapterTypes, FirebaseDBTypes, FirebaseSocketAdapterTypes } from "adapter";
|
|
7
|
+
import type { Tea } from "../../../../utils";
|
|
8
8
|
|
|
9
9
|
export const onValueTestSuite = (
|
|
10
10
|
db: FirebaseDBTypes,
|
|
@@ -16,7 +16,7 @@ export const onValueTestSuite = (
|
|
|
16
16
|
let initializedSocketsAdapter: FirebaseSocketAdapterTypes<any>;
|
|
17
17
|
let initializedCoreAdapter: FirebaseAdapterTypes<any>;
|
|
18
18
|
let initializedDb: FirebaseDBTypes;
|
|
19
|
-
let spy =
|
|
19
|
+
let spy = vi.fn();
|
|
20
20
|
const newData = { origin: "Poland", type: "Green", year: 2043, name: "Pou Ran Do Cha", amount: 100 } as Tea;
|
|
21
21
|
|
|
22
22
|
beforeAll(async () => {
|
|
@@ -44,9 +44,9 @@ export const onValueTestSuite = (
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
beforeEach(() => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
spy =
|
|
47
|
+
vi.resetAllMocks();
|
|
48
|
+
vi.clearAllMocks();
|
|
49
|
+
spy = vi.fn();
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
it("should return unmount function", async () => {
|
|
@@ -55,7 +55,7 @@ export const onValueTestSuite = (
|
|
|
55
55
|
topic: "",
|
|
56
56
|
});
|
|
57
57
|
const unmount = onValueReq.listen(spy);
|
|
58
|
-
expect(unmount).
|
|
58
|
+
expect(typeof unmount).toBe("function");
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
it("should unmount listeners", async () => {
|
|
@@ -144,7 +144,7 @@ export const onValueTestSuite = (
|
|
|
144
144
|
const { data } = await pushReq.send();
|
|
145
145
|
|
|
146
146
|
await waitForExpect(async () => {
|
|
147
|
-
expect(receivedData).
|
|
147
|
+
expect(receivedData).toEqual(expect.arrayContaining([{ ...newData, __key: data?.__key }]));
|
|
148
148
|
expect(receivedExtra).toHaveProperty("snapshot");
|
|
149
149
|
expect(receivedExtra).toHaveProperty("status");
|
|
150
150
|
expect(receivedExtra).toHaveProperty("ref");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Client } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
|
-
import { FirebaseAdapter } from "adapter";
|
|
3
|
+
import type { FirebaseAdapter } from "adapter";
|
|
4
4
|
import { testLifecycleEvents } from "../../../../shared/request-events.shared";
|
|
5
|
-
import { Tea } from "../../../../utils";
|
|
5
|
+
import type { Tea } from "../../../../utils";
|
|
6
6
|
|
|
7
7
|
export const pushTestSuite = (adapterFunction: () => ReturnType<typeof FirebaseAdapter>) => {
|
|
8
8
|
describe("push", () => {
|
|
@@ -28,7 +28,7 @@ export const pushTestSuite = (adapterFunction: () => ReturnType<typeof FirebaseA
|
|
|
28
28
|
const { data } = await getReq.send();
|
|
29
29
|
|
|
30
30
|
expect(data).toHaveLength(11);
|
|
31
|
-
expect(data).toContainEqual({ ...newData, __key: pushedData
|
|
31
|
+
expect(data).toContainEqual({ ...newData, __key: pushedData!.__key });
|
|
32
32
|
expect(extra).toHaveProperty("key");
|
|
33
33
|
});
|
|
34
34
|
it("should emit lifecycle events", async () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Client } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
|
-
import { FirebaseAdapter } from "adapter";
|
|
3
|
+
import type { FirebaseAdapter, RealtimeDbGetMethodExtra } from "adapter";
|
|
4
4
|
import { testLifecycleEvents } from "../../../../shared/request-events.shared";
|
|
5
|
-
import { Tea } from "../../../../utils";
|
|
5
|
+
import type { Tea } from "../../../../utils";
|
|
6
6
|
|
|
7
7
|
export const removeTestSuite = (adapterFunction: () => ReturnType<typeof FirebaseAdapter>) => {
|
|
8
8
|
let client = new Client({ url: "teas/" }).setAdapter(adapterFunction());
|
|
@@ -28,9 +28,8 @@ export const removeTestSuite = (adapterFunction: () => ReturnType<typeof Firebas
|
|
|
28
28
|
await removeReq.send();
|
|
29
29
|
const { data, extra } = await getReq.send();
|
|
30
30
|
expect(data).toBe(null);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
expect(extra?.snapshot?.exists()).toBe(false);
|
|
31
|
+
expect(extra).not.toBeNull();
|
|
32
|
+
expect((extra as RealtimeDbGetMethodExtra).snapshot.exists()).toBe(false);
|
|
34
33
|
});
|
|
35
34
|
it("should emit lifecycle events", async () => {
|
|
36
35
|
const removeReq = client
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Client } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
|
-
import { FirebaseAdapter } from "adapter";
|
|
3
|
+
import type { FirebaseAdapter, RealtimeDbGetMethodExtra } from "adapter";
|
|
4
4
|
import { testLifecycleEvents } from "../../../../shared/request-events.shared";
|
|
5
|
-
import { Tea } from "../../../../utils";
|
|
5
|
+
import type { Tea } from "../../../../utils";
|
|
6
6
|
|
|
7
7
|
export const setTestSuite = (adapterFunction: () => ReturnType<typeof FirebaseAdapter>) => {
|
|
8
8
|
describe("set", () => {
|
|
@@ -30,9 +30,8 @@ export const setTestSuite = (adapterFunction: () => ReturnType<typeof FirebaseAd
|
|
|
30
30
|
await setReq.send();
|
|
31
31
|
const { data, extra } = await getReq.send();
|
|
32
32
|
expect(data).toStrictEqual(newData);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
expect(extra.snapshot.exists()).toBe(true);
|
|
33
|
+
expect(extra).not.toBeNull();
|
|
34
|
+
expect((extra as RealtimeDbGetMethodExtra).snapshot.exists()).toBe(true);
|
|
36
35
|
});
|
|
37
36
|
it("should allow for removing data via set", async () => {
|
|
38
37
|
const getReq = client
|
|
@@ -53,9 +52,8 @@ export const setTestSuite = (adapterFunction: () => ReturnType<typeof FirebaseAd
|
|
|
53
52
|
await setReq.send();
|
|
54
53
|
const { data, extra } = await getReq.send();
|
|
55
54
|
expect(data).toBe(null);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
expect(extra?.snapshot?.exists()).toBe(false);
|
|
55
|
+
expect(extra).not.toBeNull();
|
|
56
|
+
expect((extra as RealtimeDbGetMethodExtra).snapshot.exists()).toBe(false);
|
|
59
57
|
});
|
|
60
58
|
it("should emit lifecycle events", async () => {
|
|
61
59
|
const setReq = client
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Client } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
|
-
import { FirebaseAdapter } from "adapter";
|
|
3
|
+
import type { FirebaseAdapter } from "adapter";
|
|
4
4
|
import { testLifecycleEvents } from "../../../../shared/request-events.shared";
|
|
5
|
-
import { Tea } from "../../../../utils";
|
|
5
|
+
import type { Tea } from "../../../../utils";
|
|
6
6
|
|
|
7
7
|
export const updateTestSuite = (adapterFunction: () => ReturnType<typeof FirebaseAdapter>) => {
|
|
8
8
|
describe("update", () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable max-params */
|
|
2
|
-
import { FirebaseAdapter, FirebaseAdapterTypes, FirebaseDBTypes, FirebaseSocketAdapterTypes } from "adapter";
|
|
2
|
+
import type { FirebaseAdapter, FirebaseAdapterTypes, FirebaseDBTypes, FirebaseSocketAdapterTypes } from "adapter";
|
|
3
3
|
import { pushTestSuite } from "./methods/push.test.suite";
|
|
4
4
|
import { onValueTestSuite } from "./methods/on-value.test.suite";
|
|
5
5
|
import { getTestSuite } from "./methods/get.test.suite";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { RequestInstance } from "@hyper-fetch/core";
|
|
1
|
+
import type { RequestInstance } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
3
|
export const testLifecycleEvents = async <R extends RequestInstance>(request: R) => {
|
|
4
|
-
const spy1 =
|
|
5
|
-
const spy2 =
|
|
6
|
-
const spy3 =
|
|
7
|
-
const spy4 =
|
|
8
|
-
const spy5 =
|
|
9
|
-
const spy6 =
|
|
4
|
+
const spy1 = vi.fn();
|
|
5
|
+
const spy2 = vi.fn();
|
|
6
|
+
const spy3 = vi.fn();
|
|
7
|
+
const spy4 = vi.fn();
|
|
8
|
+
const spy5 = vi.fn();
|
|
9
|
+
const spy6 = vi.fn();
|
|
10
10
|
|
|
11
11
|
request.client.requestManager.events.onRequestStartByQueue(request.queryKey, spy1);
|
|
12
12
|
request.client.requestManager.events.onResponseStartByQueue(request.queryKey, spy2);
|
package/__tests__/tsconfig.json
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
+
"target": "esnext",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["dom", "dom.iterable", "ESNext"],
|
|
3
7
|
"strict": true,
|
|
4
8
|
"noEmit": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"allowSyntheticDefaultImports": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"noUnusedLocals": false,
|
|
15
|
+
"noUnusedParameters": false,
|
|
16
|
+
"types": ["vitest/globals", "@types/node"],
|
|
5
17
|
"baseUrl": "../src",
|
|
6
|
-
"
|
|
7
|
-
}
|
|
18
|
+
"paths": {}
|
|
19
|
+
},
|
|
20
|
+
"include": ["**/*.ts", "**/*.tsx", "../../../global.d.ts", "../../../vitest.d.ts"]
|
|
8
21
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Firestore } from "firebase/firestore";
|
|
2
|
+
import { collection, getDocs, deleteDoc } from "firebase/firestore";
|
|
2
3
|
// https://github.com/firebase/snippets-node/blob/e5f6214059bdbc63f94ba6600f7f84e96325548d/firestore/main/index.js#L889-L921
|
|
3
4
|
|
|
4
5
|
export async function deleteCollectionForBrowser(firestoreDb: Firestore, path: string) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Database
|
|
2
|
-
import {
|
|
1
|
+
import type { Database } from "firebase/database";
|
|
2
|
+
import { set, ref } from "firebase/database";
|
|
3
|
+
import type { Firestore } from "firebase/firestore";
|
|
4
|
+
import { doc, setDoc } from "firebase/firestore";
|
|
3
5
|
|
|
4
6
|
import { teas } from "../seed/seed.data";
|
|
5
7
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="vitest/globals" />
|
|
2
|
+
import { setImmediate } from "timers";
|
|
3
|
+
import { AbortController } from "abortcontroller-polyfill/dist/cjs-ponyfill";
|
|
4
|
+
|
|
5
|
+
globalThis.setImmediate = setImmediate;
|
|
6
|
+
|
|
7
|
+
if (!globalThis.AbortController) {
|
|
8
|
+
globalThis.AbortController = AbortController as any;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/adapter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAgD,MAAM,SAAS,CAAC;AAKnH,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,eAAe,EAAE,UAAU,CAAC,KAAG,oBAAoB,CAAC,CAAC,CA0D9F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.sockets.d.ts","sourceRoot":"","sources":["../../src/adapter/adapter.sockets.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAIjF,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,eAAe,EAAE,UAAU,CAAC,KAAG,0BAA0B,CAAC,CAAC,CAQ3G,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Database } from 'firebase/database';
|
|
2
|
+
import { Firestore } from 'firebase/firestore';
|
|
3
|
+
import { Adapter, Request, Client } from '@hyper-fetch/core';
|
|
4
|
+
import { RealtimeDbAdapterType, FirestoreAdapterType, RealtimeSocketAdapterType, FirestoreSocketAdapterType, RealtimeDBQueryParams, RealtimeDBMethodsUnion, FirestoreMethodsUnion, FirestoreQueryParams } from '../index';
|
|
5
|
+
export type FirebaseDBTypes = Database | Firestore;
|
|
6
|
+
export type FirebaseAdapterTypes<T> = T extends Database ? RealtimeDbAdapterType : FirestoreAdapterType;
|
|
7
|
+
export type FirebaseSocketAdapterTypes<T> = T extends Firestore ? FirestoreSocketAdapterType : RealtimeSocketAdapterType;
|
|
8
|
+
export type FirebaseRealtimeDBType = Request<any, any, RealtimeDBQueryParams, any, any, Client<any, Adapter<any, RealtimeDBMethodsUnion, any, any, any, any>>, any, any, any>;
|
|
9
|
+
export type FirestoreRequestType = Request<any, any, FirestoreQueryParams, any, any, Client<any, Adapter<any, FirestoreMethodsUnion, any, any, any, any>>, any, any, any>;
|
|
10
|
+
export type FirebaseRequestType<T> = T extends Database ? FirebaseRealtimeDBType : FirestoreRequestType;
|
|
11
|
+
//# sourceMappingURL=adapter.base.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.base.types.d.ts","sourceRoot":"","sources":["../../../src/adapter/types/adapter.base.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,SAAS,CAAC;AACnD,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,GAAG,qBAAqB,GAAG,oBAAoB,CAAC;AACxG,MAAM,MAAM,0BAA0B,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAC3D,0BAA0B,GAC1B,yBAAyB,CAAC;AAE9B,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAC1C,GAAG,EACH,GAAG,EACH,qBAAqB,EACrB,GAAG,EACH,GAAG,EACH,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,sBAAsB,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EACrE,GAAG,EACH,GAAG,EACH,GAAG,CACJ,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,OAAO,CACxC,GAAG,EACH,GAAG,EACH,oBAAoB,EACpB,GAAG,EACH,GAAG,EACH,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,qBAAqB,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EACpE,GAAG,EACH,GAAG,EACH,GAAG,CACJ,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,GAAG,sBAAsB,GAAG,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Adapter } from '@hyper-fetch/core';
|
|
2
|
+
import { Unsubscribe as FirestoreUnsubscribe, CollectionReference, DocumentReference, DocumentSnapshot, QuerySnapshot } from 'firebase/firestore';
|
|
3
|
+
import { SocketAdapter } from '@hyper-fetch/sockets';
|
|
4
|
+
import { DocumentData } from '@firebase/firestore';
|
|
5
|
+
import { FirestoreConstraintsUnion, FirestorePermittedMethods, PermittedConstraints, SharedQueryConstraints } from '../../constraints';
|
|
6
|
+
export type FirestoreSocketAdapterType = SocketAdapter<FirestoreOnSnapshotExtra, undefined, {
|
|
7
|
+
groupByChangeType?: boolean;
|
|
8
|
+
} & FirestoreQueryParams>;
|
|
9
|
+
export type FirestoreAdapterType = Adapter<Record<string, never>, "getDoc", FirestoreStatuses, FirestoreExtra, FirestoreQueryParams, FirestoreQueryParams> | Adapter<Record<string, never>, "getDocs", FirestoreStatuses, FirestoreGetDocsExtra, FirestoreQueryParams, FirestoreQueryParams> | Adapter<{
|
|
10
|
+
merge: boolean;
|
|
11
|
+
}, "setDoc", FirestoreStatuses, FirestoreRefOnlyExtra, Record<string, never>, undefined> | Adapter<Record<string, never>, "updateDoc" | "addDoc" | "deleteDoc" | "setDoc", FirestoreStatuses, FirestoreRefOnlyExtra, Record<string, never>, undefined>;
|
|
12
|
+
export type FirestoreQueryParams = {
|
|
13
|
+
constraints?: PermittedConstraints<FirestorePermittedMethods, FirestoreConstraintsUnion | SharedQueryConstraints>[];
|
|
14
|
+
};
|
|
15
|
+
export declare enum FirestoreMethods {
|
|
16
|
+
addDoc = "addDoc",
|
|
17
|
+
getDoc = "getDoc",
|
|
18
|
+
getDocs = "getDocs",
|
|
19
|
+
setDoc = "setDoc",
|
|
20
|
+
updateDoc = "updateDoc",
|
|
21
|
+
deleteDoc = "deleteDoc"
|
|
22
|
+
}
|
|
23
|
+
export type FirestoreMethodsUnion = FirestoreMethods.addDoc | FirestoreMethods.getDoc | FirestoreMethods.getDocs | FirestoreMethods.setDoc | FirestoreMethods.updateDoc | FirestoreMethods.deleteDoc;
|
|
24
|
+
export type FirestoreExtra = {
|
|
25
|
+
ref?: DocumentReference;
|
|
26
|
+
snapshot?: DocumentSnapshot;
|
|
27
|
+
};
|
|
28
|
+
export type FirestoreOnSnapshotExtra = {
|
|
29
|
+
ref?: DocumentReference | CollectionReference;
|
|
30
|
+
snapshot?: DocumentSnapshot | QuerySnapshot;
|
|
31
|
+
unsubscribe?: FirestoreUnsubscribe;
|
|
32
|
+
groupedResult: {
|
|
33
|
+
added: DocumentData[];
|
|
34
|
+
modified: DocumentData[];
|
|
35
|
+
removed: DocumentData[];
|
|
36
|
+
} | null;
|
|
37
|
+
};
|
|
38
|
+
export type FirestoreGetDocsExtra = {
|
|
39
|
+
ref?: CollectionReference;
|
|
40
|
+
snapshot?: QuerySnapshot;
|
|
41
|
+
};
|
|
42
|
+
export type FirestoreRefOnlyExtra = {
|
|
43
|
+
ref?: DocumentReference;
|
|
44
|
+
};
|
|
45
|
+
export type FirestoreStatuses = "success" | "error" | "emptyResource";
|
|
46
|
+
//# sourceMappingURL=adapter.firestore.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.firestore.types.d.ts","sourceRoot":"","sources":["../../../src/adapter/types/adapter.firestore.types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Adapter } from '@hyper-fetch/core';
|
|
2
|
+
import { DatabaseReference, DataSnapshot } from 'firebase/database';
|
|
3
|
+
import { SocketAdapter } from '@hyper-fetch/sockets';
|
|
4
|
+
import { PermittedConstraints, RealtimeConstraintsUnion, RealtimePermittedMethods, SharedQueryConstraints } from '../../constraints';
|
|
5
|
+
export type RealtimeSocketAdapterType = SocketAdapter<RealtimeDbOnValueMethodExtra, undefined, {
|
|
6
|
+
onlyOnce?: boolean;
|
|
7
|
+
} & RealtimeDBQueryParams>;
|
|
8
|
+
export type RealtimeDbAdapterType = Adapter<DefaultRealtimeDBAdapterOptions, "get", RealtimeDBStatuses, RealtimeDbGetMethodExtra, RealtimeDBQueryParams, RealtimeDBQueryParams> | Adapter<DefaultRealtimeDBAdapterOptions, "push", RealtimeDBStatuses, RealtimeDbPushMethodExtra, Record<string, never>, undefined> | Adapter<DefaultRealtimeDBAdapterOptions, "set" | "update" | "remove", RealtimeDBStatuses, RealtimeDbDefaultExtra, Record<string, never>, undefined>;
|
|
9
|
+
export type DefaultRealtimeDBAdapterOptions = {
|
|
10
|
+
priority?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare enum RealtimeDBMethods {
|
|
13
|
+
set = "set",
|
|
14
|
+
push = "push",
|
|
15
|
+
update = "update",
|
|
16
|
+
get = "get",
|
|
17
|
+
remove = "remove"
|
|
18
|
+
}
|
|
19
|
+
export type RealtimeDBMethodsUnion = RealtimeDBMethods.set | RealtimeDBMethods.push | RealtimeDBMethods.update | RealtimeDBMethods.get | RealtimeDBMethods.remove;
|
|
20
|
+
export type RealtimeDBStatuses = "success" | "error" | "emptyResource";
|
|
21
|
+
export type RealtimeDbOnValueMethodExtra = {
|
|
22
|
+
ref: DatabaseReference;
|
|
23
|
+
snapshot: DataSnapshot;
|
|
24
|
+
};
|
|
25
|
+
export type RealtimeDbGetMethodExtra = {
|
|
26
|
+
ref: DatabaseReference;
|
|
27
|
+
snapshot: DataSnapshot;
|
|
28
|
+
};
|
|
29
|
+
export type RealtimeDbDefaultExtra = {
|
|
30
|
+
ref: DatabaseReference;
|
|
31
|
+
};
|
|
32
|
+
export type RealtimeDbPushMethodExtra = {
|
|
33
|
+
ref: DatabaseReference;
|
|
34
|
+
key: string;
|
|
35
|
+
};
|
|
36
|
+
export type RealtimeDBQueryParams = {
|
|
37
|
+
constraints?: PermittedConstraints<RealtimePermittedMethods, RealtimeConstraintsUnion | SharedQueryConstraints>[];
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=adapter.realtime.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.realtime.types.d.ts","sourceRoot":"","sources":["../../../src/adapter/types/adapter.realtime.types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,yBAAyB,GAAG,aAAa,CACnD,4BAA4B,EAC5B,SAAS,EACT;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,qBAAqB,CAC/C,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAC7B,OAAO,CACL,+BAA+B,EAC/B,KAAK,EACL,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,CACtB,GACD,OAAO,CACL,+BAA+B,EAC/B,MAAM,EACN,kBAAkB,EAClB,yBAAyB,EACzB,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACrB,SAAS,CACV,GACD,OAAO,CACL,+BAA+B,EAC/B,KAAK,GAAG,QAAQ,GAAG,QAAQ,EAC3B,kBAAkB,EAClB,sBAAsB,EACtB,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACrB,SAAS,CACV,CAAC;AAEN,MAAM,MAAM,+BAA+B,GAAG;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,iBAAiB;IAC3B,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,GAAG,QAAQ;IACX,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,sBAAsB,GAC9B,iBAAiB,CAAC,GAAG,GACrB,iBAAiB,CAAC,IAAI,GACtB,iBAAiB,CAAC,MAAM,GACxB,iBAAiB,CAAC,GAAG,GACrB,iBAAiB,CAAC,MAAM,CAAC;AAE7B,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,OAAO,GAAG,eAAe,CAAC;AACvE,MAAM,MAAM,4BAA4B,GAAG;IACzC,GAAG,EAAE,iBAAiB,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,GAAG,EAAE,iBAAiB,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,EAAE,iBAAiB,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,GAAG,EAAE,iBAAiB,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,CAAC,EAAE,oBAAoB,CAAC,wBAAwB,EAAE,wBAAwB,GAAG,sBAAsB,CAAC,EAAE,CAAC;CACnH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapter/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { $endAt, $endBefore, $equalTo, $limit, $limitToFirst, $limitToLast, $orderBy, $orderByChild, $orderByKey, $orderByValue, $startAfter, $startAt, $where, FirestoreQueryConstraints, RealtimeQueryConstraints } from './firebase.constraints';
|
|
2
|
+
export type RealtimeConstraintsUnion = `${RealtimeQueryConstraints}`;
|
|
3
|
+
export type FirestoreConstraintsUnion = `${FirestoreQueryConstraints}`;
|
|
4
|
+
export type RealtimePermittedMethods = ReturnType<typeof $startAt> | ReturnType<typeof $startAfter> | ReturnType<typeof $endAt> | ReturnType<typeof $endBefore> | ReturnType<typeof $orderByChild> | ReturnType<typeof $orderByValue> | ReturnType<typeof $orderByKey> | ReturnType<typeof $limitToFirst> | ReturnType<typeof $limitToLast> | ReturnType<typeof $equalTo>;
|
|
5
|
+
export type FirestorePermittedMethods = ReturnType<typeof $where> | ReturnType<typeof $orderBy> | ReturnType<typeof $limit> | ReturnType<typeof $startAt> | ReturnType<typeof $startAfter> | ReturnType<typeof $endAt> | ReturnType<typeof $endBefore>;
|
|
6
|
+
type ExtractConstraintType<T> = T extends {
|
|
7
|
+
toString: () => string;
|
|
8
|
+
type: infer ThisType;
|
|
9
|
+
values: any;
|
|
10
|
+
} ? ThisType : never;
|
|
11
|
+
export type PermittedConstraints<T, U> = ExtractConstraintType<T> extends U ? T : never;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=constraints.types.d.ts.map
|