@litbase/react 4.1.64 → 4.1.71
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/hooks/use-query.js.map +1 -1
- package/package.json +4 -4
package/hooks/use-query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/use-query.ts"],"sourcesContent":["import {\n BaseQueryObject,\n DocumentInterface,\n litql,\n MultiObservableQueryObject,\n MultiPromiseQueryObject,\n QueryOptions,\n QueryTypeBody,\n SingleObservableQueryObject,\n SinglePromiseQueryObject,\n} from \"@litbase/core\";\nimport fastDeepEqual from \"fast-deep-equal\";\nimport { distinctUntilChanged, switchMap } from \"rxjs/operators\";\nimport { useObservable } from \"@litbase/use-observable\";\nimport { of } from \"rxjs\";\n\nexport function useQueryTypeOne<TDoc extends DocumentInterface>(\n typeName: string,\n query: QueryTypeBody | null,\n options?: QueryOptions
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-query.ts"],"sourcesContent":["import {\n BaseQueryObject,\n DocumentInterface,\n litql,\n MultiObservableQueryObject,\n MultiPromiseQueryObject,\n QueryOptions,\n QueryTypeBody,\n SingleObservableQueryObject,\n SinglePromiseQueryObject,\n} from \"@litbase/core\";\nimport fastDeepEqual from \"fast-deep-equal\";\nimport { distinctUntilChanged, switchMap } from \"rxjs/operators\";\nimport { useObservable } from \"@litbase/use-observable\";\nimport { of } from \"rxjs\";\n\nexport function useQueryTypeOne<TDoc extends DocumentInterface>(\n typeName: string,\n query: QueryTypeBody | null,\n options?: QueryOptions,\n): [TDoc | null, boolean, Error | null, boolean] {\n // Rewrite $matches to $matchAll-s for useQueryType\n if (query?.$match) {\n const { $match, ...other } = query;\n\n query = {\n ...other,\n\n $matchAll: $match,\n };\n }\n\n const modifiedQuery = !query || \"$limit\" in query ? query : { ...query, $limit: 1 };\n\n const [items, isLoading, error, isComplete] = useQueryType<TDoc>(typeName, modifiedQuery, options);\n\n return [items.length ? items[0] : null, isLoading, error, isComplete];\n}\n\nexport function useQueryType<TDoc extends DocumentInterface>(\n typeName: string,\n query: QueryTypeBody | null,\n options?: QueryOptions,\n) {\n return useObservable(\n (inputs$) => {\n return inputs$.pipe(\n distinctUntilChanged((a, b) => fastDeepEqual(a, b)),\n switchMap(([collection_, query_, options_]) => {\n if (!query_) return of([]);\n\n // Add $matchAll if missing\n if (!query_.$matchAll) {\n query_ = {\n ...query_,\n $matchAll: {},\n };\n }\n\n return litql.queryType<TDoc>(collection_, {\n ...query_,\n $live: !options_?.once,\n $context: options_?.context,\n });\n }),\n );\n },\n [],\n [typeName, query, options] as const,\n );\n}\n\nexport function useQuery<T extends DocumentInterface>(\n name: string,\n query: SinglePromiseQueryObject | null,\n): [T | null, boolean, Error | null, boolean];\nexport function useQuery<T extends DocumentInterface>(\n name: string,\n query: MultiPromiseQueryObject | null,\n): [T[], boolean, Error | null, boolean];\nexport function useQuery<T extends DocumentInterface>(\n name: string,\n query: SingleObservableQueryObject | null,\n): [T | null, boolean, Error | null, boolean];\nexport function useQuery<T extends DocumentInterface>(\n name: string,\n query: MultiObservableQueryObject | null,\n): [T[], boolean, Error | null, boolean];\nexport function useQuery<T extends DocumentInterface>(\n name: string,\n query: BaseQueryObject | null,\n): [T | T[] | null, boolean, Error | null, boolean] {\n return useObservable(\n (inputs$) =>\n inputs$.pipe(\n distinctUntilChanged((a, b) => fastDeepEqual(a, b)),\n switchMap(([name_, query_]) => (query_ ? litql.query<T>(name_, query_ as BaseQueryObject) : of([]))),\n ),\n (query && \"$match\" in query ? null : []) as T | T[] | null,\n [name, query] as const,\n );\n}\n"],"mappings":"AAAA;AAAA,EAGE;AAAA,OAOK;AACP,OAAO,mBAAmB;AAC1B,SAAS,sBAAsB,iBAAiB;AAChD,SAAS,qBAAqB;AAC9B,SAAS,UAAU;AAEZ,SAAS,gBACd,UACA,OACA,SAC+C;AAE/C,MAAI,OAAO,QAAQ;AACjB,UAAM,EAAE,QAAQ,GAAG,MAA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AA,EACd;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litbase/react",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.71",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"directory": "dist"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@litbase/client": "^4.1.
|
|
33
|
-
"@litbase/core": "^4.1.
|
|
32
|
+
"@litbase/client": "^4.1.71",
|
|
33
|
+
"@litbase/core": "^4.1.71",
|
|
34
34
|
"rxjs": "^7.8.0",
|
|
35
35
|
"tsup": "^6.6.3",
|
|
36
36
|
"typescript": "^5.1.6"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "47ca246b4cd5107882875f6c28ccc7b61d1d6a29"
|
|
39
39
|
}
|