@tatsuokaniwa/swr-firestore 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/dist/server/util/type.d.ts +3 -2
- package/dist/util/type.d.ts +7 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -161,14 +161,20 @@ import type {
|
|
|
161
161
|
startAt,
|
|
162
162
|
where,
|
|
163
163
|
} from "firebase/firestore";
|
|
164
|
+
|
|
165
|
+
type DocumentId = "id";
|
|
164
166
|
// First argument of hook, specifies options to firestore, and is also used as a key for SWR.
|
|
165
167
|
type KeyParams<T> =
|
|
166
168
|
| {
|
|
167
169
|
// The path to the collection or document of Firestore.
|
|
168
170
|
path: string;
|
|
169
171
|
// `Paths` means object's property path, including nested object
|
|
170
|
-
where?: [
|
|
171
|
-
|
|
172
|
+
where?: [
|
|
173
|
+
Paths<T> | DocumentId,
|
|
174
|
+
Parameters<typeof where>[1],
|
|
175
|
+
ValueOf<T> | unknown
|
|
176
|
+
][];
|
|
177
|
+
orderBy?: [Paths<T> | DocumentId, Parameters<typeof orderBy>[1]][];
|
|
172
178
|
startAt?: Parameters<typeof startAt>;
|
|
173
179
|
startAfter?: Parameters<typeof startAfter>;
|
|
174
180
|
endAt?: Parameters<typeof endAt>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { OrderByDirection, Query, QueryDocumentSnapshot, WhereFilterOp } from "firebase-admin/firestore";
|
|
2
2
|
import type { Paths, ValueOf } from "../../util/type.js";
|
|
3
|
+
export type DocumentId = "id";
|
|
3
4
|
export type QueryParams<T> = {
|
|
4
|
-
where?: [Paths<T
|
|
5
|
-
orderBy?: [Paths<T
|
|
5
|
+
where?: [Paths<T> | DocumentId, WhereFilterOp, ValueOf<T> | unknown][];
|
|
6
|
+
orderBy?: [Paths<T> | DocumentId, OrderByDirection][];
|
|
6
7
|
startAt?: Parameters<Query["startAt"]>;
|
|
7
8
|
startAfter?: Parameters<Query["startAfter"]>;
|
|
8
9
|
endAt?: Parameters<Query["endAt"]>;
|
package/dist/util/type.d.ts
CHANGED
|
@@ -26,13 +26,18 @@ type Prev = [
|
|
|
26
26
|
20,
|
|
27
27
|
...0[]
|
|
28
28
|
];
|
|
29
|
+
export type DocumentId = "id";
|
|
29
30
|
export type Paths<T, D extends number = 3> = [D] extends [never] ? never : T extends object ? {
|
|
30
31
|
[K in keyof T]-?: K extends string | number ? `${K}` | Join<K, Paths<T[K], Prev[D]>> : never;
|
|
31
32
|
}[keyof T] : "";
|
|
32
33
|
export type ValueOf<T> = T[keyof T];
|
|
33
34
|
export type QueryParams<T> = {
|
|
34
|
-
where?: [
|
|
35
|
-
|
|
35
|
+
where?: [
|
|
36
|
+
Paths<T> | DocumentId,
|
|
37
|
+
Parameters<typeof where>[1],
|
|
38
|
+
ValueOf<T> | unknown
|
|
39
|
+
][];
|
|
40
|
+
orderBy?: [Paths<T> | DocumentId, Parameters<typeof orderBy>[1]][];
|
|
36
41
|
startAt?: Parameters<typeof startAt>;
|
|
37
42
|
startAfter?: Parameters<typeof startAfter>;
|
|
38
43
|
endAt?: Parameters<typeof endAt>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tatsuokaniwa/swr-firestore",
|
|
3
3
|
"description": "React Hooks library for Firestore using SWR's subscription feature.",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.3",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/t-k/swr-firestore.git"
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@types/react-dom": "^18.0.11",
|
|
67
67
|
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
|
68
68
|
"@vitejs/plugin-react": "^4.0.0",
|
|
69
|
-
"@vitest/coverage-c8": "^0.
|
|
69
|
+
"@vitest/coverage-c8": "^0.32.0",
|
|
70
70
|
"c8": "^7.13.0",
|
|
71
71
|
"eslint": "^8.36.0",
|
|
72
72
|
"eslint-plugin-react": "^7.32.2",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"swr": "^2.1.0 <3.0.0",
|
|
80
80
|
"typescript": "^5.0.2",
|
|
81
81
|
"vite-tsconfig-paths": "^4.0.7",
|
|
82
|
-
"vitest": "^0.
|
|
82
|
+
"vitest": "^0.32.0"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"firebase": "^9.11.0 < 10.0.0",
|