@biblioteksentralen/bmdb-search 0.0.0-beta.2 → 0.0.0-beta.20
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/CHANGELOG.md +8 -1
- package/README.md +22 -73
- package/dist/chunk-2QYZKLEL.js +14925 -0
- package/dist/chunk-2UT5GPVV.js +14918 -0
- package/dist/chunk-4KUQHSGO.js +14910 -0
- package/dist/chunk-4VULP744.js +14913 -0
- package/dist/chunk-5JZ4HY2B.js +14926 -0
- package/dist/chunk-BVNV6FFF.js +14904 -0
- package/dist/chunk-DVQJTRK7.js +14933 -0
- package/dist/chunk-EKMSXG47.js +14883 -0
- package/dist/chunk-FCYYVSPY.js +14921 -0
- package/dist/chunk-FGDMIEV7.js +14920 -0
- package/dist/chunk-GHEYNKFF.js +14925 -0
- package/dist/chunk-KDDO7YJH.js +14908 -0
- package/dist/chunk-M2UJFDEC.js +14882 -0
- package/dist/chunk-QMLCZJ6K.js +14912 -0
- package/dist/chunk-QT2QDC5N.js +14917 -0
- package/dist/chunk-RERLCLDA.js +14925 -0
- package/dist/chunk-RLDOKHJ3.js +14925 -0
- package/dist/chunk-SCW6JR36.js +14914 -0
- package/dist/chunk-WKMPBILR.js +14882 -0
- package/dist/chunk-YCL7ZI3P.js +14913 -0
- package/dist/chunk-YGPHHSGQ.js +14934 -0
- package/dist/index-DN1eQZzZ.d.cts +3799 -0
- package/dist/index-DN1eQZzZ.d.ts +3799 -0
- package/dist/index.cjs +14946 -10
- package/dist/index.d-0-6GpZp8.d.cts +3780 -0
- package/dist/index.d-0-6GpZp8.d.ts +3780 -0
- package/dist/index.d-6UQ5XFBK.d.cts +3788 -0
- package/dist/index.d-6UQ5XFBK.d.ts +3788 -0
- package/dist/index.d-B3mlbY2i.d.cts +3796 -0
- package/dist/index.d-B3mlbY2i.d.ts +3796 -0
- package/dist/index.d-B4s2-oCb.d.cts +3799 -0
- package/dist/index.d-B4s2-oCb.d.ts +3799 -0
- package/dist/index.d-BGTL1nsQ.d.cts +3744 -0
- package/dist/index.d-BGTL1nsQ.d.ts +3744 -0
- package/dist/index.d-BO699FkZ.d.cts +3717 -0
- package/dist/index.d-BO699FkZ.d.ts +3717 -0
- package/dist/index.d-BOCWNFjn.d.cts +3786 -0
- package/dist/index.d-BOCWNFjn.d.ts +3786 -0
- package/dist/index.d-BRVlQviG.d.cts +3714 -0
- package/dist/index.d-BRVlQviG.d.ts +3714 -0
- package/dist/index.d-BU4v5yDq.d.cts +3723 -0
- package/dist/index.d-BU4v5yDq.d.ts +3723 -0
- package/dist/index.d-BcLZJncu.d.cts +3733 -0
- package/dist/index.d-BcLZJncu.d.ts +3733 -0
- package/dist/index.d-BfxCal8r.d.cts +3809 -0
- package/dist/index.d-BfxCal8r.d.ts +3809 -0
- package/dist/index.d-Bhag4Gh8.d.cts +3786 -0
- package/dist/index.d-Bhag4Gh8.d.ts +3786 -0
- package/dist/index.d-BlocHY5f.d.cts +3783 -0
- package/dist/index.d-BlocHY5f.d.ts +3783 -0
- package/dist/index.d-Bo-CqceL.d.cts +3783 -0
- package/dist/index.d-Bo-CqceL.d.ts +3783 -0
- package/dist/index.d-Bodx7_L7.d.cts +3727 -0
- package/dist/index.d-Bodx7_L7.d.ts +3727 -0
- package/dist/index.d-C4LgMWzi.d.cts +3719 -0
- package/dist/index.d-C4LgMWzi.d.ts +3719 -0
- package/dist/index.d-C6eF-acI.d.cts +3729 -0
- package/dist/index.d-C6eF-acI.d.ts +3729 -0
- package/dist/index.d-CNblIfVJ.d.cts +3719 -0
- package/dist/index.d-CNblIfVJ.d.ts +3719 -0
- package/dist/index.d-CZ2KeHo_.d.cts +3736 -0
- package/dist/index.d-CZ2KeHo_.d.ts +3736 -0
- package/dist/index.d-Cf5CW9gT.d.cts +3794 -0
- package/dist/index.d-Cf5CW9gT.d.ts +3794 -0
- package/dist/index.d-Cus2SItb.d.cts +3757 -0
- package/dist/index.d-Cus2SItb.d.ts +3757 -0
- package/dist/index.d-D9GgnKVt.d.cts +3719 -0
- package/dist/index.d-D9GgnKVt.d.ts +3719 -0
- package/dist/index.d-DArQCHIQ.d.cts +3732 -0
- package/dist/index.d-DArQCHIQ.d.ts +3732 -0
- package/dist/index.d-DU2K2cS8.d.cts +3723 -0
- package/dist/index.d-DU2K2cS8.d.ts +3723 -0
- package/dist/index.d-DVE8OW7s.d.cts +3719 -0
- package/dist/index.d-DVE8OW7s.d.ts +3719 -0
- package/dist/index.d-DjvA_yQE.d.cts +3727 -0
- package/dist/index.d-DjvA_yQE.d.ts +3727 -0
- package/dist/index.d-DpZv9OdT.d.cts +3731 -0
- package/dist/index.d-DpZv9OdT.d.ts +3731 -0
- package/dist/index.d-DpdSdqnT.d.cts +3724 -0
- package/dist/index.d-DpdSdqnT.d.ts +3724 -0
- package/dist/index.d-DwhKG4ud.d.cts +3733 -0
- package/dist/index.d-DwhKG4ud.d.ts +3733 -0
- package/dist/index.d-FE6qJIAV.d.cts +3732 -0
- package/dist/index.d-FE6qJIAV.d.ts +3732 -0
- package/dist/index.d-NhVnbzyE.d.cts +3790 -0
- package/dist/index.d-NhVnbzyE.d.ts +3790 -0
- package/dist/index.d-PHogkINT.d.cts +3763 -0
- package/dist/index.d-PHogkINT.d.ts +3763 -0
- package/dist/index.d-TVZmpsrx.d.cts +3726 -0
- package/dist/index.d-TVZmpsrx.d.ts +3726 -0
- package/dist/index.d-jCNpGioP.d.cts +3784 -0
- package/dist/index.d-jCNpGioP.d.ts +3784 -0
- package/dist/index.d-n05R9qC0.d.cts +3784 -0
- package/dist/index.d-n05R9qC0.d.ts +3784 -0
- package/dist/index.d-sYxaQMGR.d.cts +3730 -0
- package/dist/index.d-sYxaQMGR.d.ts +3730 -0
- package/dist/index.d.cts +16 -1103
- package/dist/index.d.ts +16 -1103
- package/dist/index.js +16 -8
- package/dist/v1/index.cjs +14940 -0
- package/dist/v1/index.d.cts +2 -0
- package/dist/v1/index.d.ts +2 -0
- package/dist/v1/index.js +1 -0
- package/package.json +19 -10
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,95 +1,44 @@
|
|
|
1
1
|
# @biblioteksentralen/bmdb-search
|
|
2
2
|
|
|
3
|
-
TypeScript client for searching Bibliotekenes metadatabrønn (BMDB).
|
|
3
|
+
TypeScript client for searching Bibliotekenes metadatabrønn (BMDB) using [openapi-fetch](https://openapi-ts.dev/openapi-fetch/).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Options
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Usage examples
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Search works
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
import {
|
|
12
|
+
import { createBmdbFetchClient } from "@biblioteksentralen/bmdb-search";
|
|
13
13
|
|
|
14
|
-
const bmdbSearchClient =
|
|
15
|
-
|
|
16
|
-
baseUrl: "https://search.data.bs.no",
|
|
14
|
+
const bmdbSearchClient = createBmdbFetchClient({
|
|
15
|
+
host: "https://search.data.bs.no",
|
|
17
16
|
});
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### Browser context
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
// next.config.js or similar
|
|
26
|
-
const searchApiHost = "https://search.data.bs.no";
|
|
27
|
-
|
|
28
|
-
const config = {
|
|
29
|
-
// ... other config ...
|
|
30
|
-
rewrites() {
|
|
31
|
-
return [
|
|
32
|
-
{
|
|
33
|
-
source: "/bmdb/api/:path*",
|
|
34
|
-
destination: `${searchApiHost}/bmdb/api/:path*`,
|
|
35
|
-
},
|
|
36
|
-
];
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// File utilizing search client
|
|
41
|
-
import { createBmdbSearchClient } from "@biblioteksentralen/bmdb-search";
|
|
42
|
-
|
|
43
|
-
const bmdbSearchClient = createBmdbSearchClient({ clientIdentifier: "client-unique-description" });
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
For Next.js it might also have to be exempt from handling in middleware (e.g. internationalization):
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
// middleware.ts
|
|
50
|
-
export const config = {
|
|
51
|
-
matcher: [
|
|
52
|
-
// ...other
|
|
53
|
-
"/((?!|bmdb/api|_next/static).*)",
|
|
54
|
-
],
|
|
55
|
-
};
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Usage examples
|
|
59
|
-
|
|
60
|
-
### Search works using client
|
|
61
|
-
|
|
62
|
-
Uses [openapi-fetch](https://openapi-ts.dev/openapi-fetch/) to generate a typed search client.
|
|
63
|
-
|
|
64
|
-
```typescript
|
|
65
|
-
import { createBmdbSearchClient } from "@biblioteksentralen/bmdb-search";
|
|
66
|
-
|
|
67
|
-
const bmdbSearchClient = createBmdbSearchClient({ clientIdentifier: "client-unique-description" });
|
|
68
|
-
const { data, error } = await bmdbSearchClient.GET("/works/search", { query: { query: "test" } });
|
|
18
|
+
const { data, error } = await bmdbSearchClient.GET("/works/search", { params: { query: { query: "test" } } });
|
|
69
19
|
```
|
|
70
20
|
|
|
71
21
|
The arguments and response are fully typed.
|
|
72
22
|
|
|
73
|
-
###
|
|
23
|
+
### Usage with tanstack-query, openapi-react-query and React hooks
|
|
74
24
|
|
|
75
|
-
|
|
25
|
+
Using [tanstack](https://tanstack.com/query/latest) for fetching with state management and [openapi-react-query](https://openapi-ts.dev/openapi-react-query/) for typing.
|
|
76
26
|
|
|
77
27
|
```typescript
|
|
78
|
-
import {
|
|
28
|
+
import { createBmdbFetchClient } from "@biblioteksentralen/bmdb-search";
|
|
29
|
+
import createReactQueryClient from "openapi-react-query";
|
|
79
30
|
|
|
80
|
-
const
|
|
81
|
-
|
|
31
|
+
const bmdbSearchClient = createBmdbFetchClient({
|
|
32
|
+
host: "https://search.data.bs.no"
|
|
82
33
|
});
|
|
83
34
|
|
|
84
|
-
const
|
|
85
|
-
const { data, error, isLoading } = useQuery("/works/search", { query: { query: "test" } });
|
|
86
|
-
return <div>Hello</div>
|
|
87
|
-
};
|
|
88
|
-
```
|
|
35
|
+
const { useQuery } = createReactQueryClient(bmdbSearchClient);
|
|
89
36
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
37
|
+
const Component = () => {
|
|
38
|
+
const { data, error, isLoading } = useQuery("get", "/works/search", { params: { query: { query: "test" } } });
|
|
39
|
+
if (isLoading) return <div>Loading</div>;
|
|
40
|
+
if (error) return <div>Something went wrong</div>;
|
|
41
|
+
return <div>Found {data?.total} works</div>;
|
|
42
|
+
};
|
|
93
43
|
|
|
94
|
-
|
|
95
|
-
name and a contact address in the `clientIdentifier` string. We will only contact you about usage of the API.
|
|
44
|
+
```
|