@biblioteksentralen/bmdb-search 0.0.0-beta.21 → 0.0.0-beta.22
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 +53 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,43 +2,77 @@
|
|
|
2
2
|
|
|
3
3
|
TypeScript client for searching Bibliotekenes metadatabrønn (BMDB) using [openapi-fetch](https://openapi-ts.dev/openapi-fetch/).
|
|
4
4
|
|
|
5
|
-
## Options
|
|
6
|
-
|
|
7
5
|
## Usage examples
|
|
8
6
|
|
|
9
|
-
###
|
|
7
|
+
### Setup client
|
|
10
8
|
|
|
11
9
|
```typescript
|
|
12
10
|
import { createBmdbFetchClient } from "@biblioteksentralen/bmdb-search";
|
|
13
11
|
|
|
14
12
|
const bmdbSearchClient = createBmdbFetchClient({
|
|
15
|
-
host: "https://search.
|
|
13
|
+
host: "https://search.bmdb.no/",
|
|
16
14
|
});
|
|
15
|
+
```
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
### Search works
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
const { data, error } = await bmdbSearchClient.GET("/{searchProfile}/works/search", {
|
|
21
|
+
params: {
|
|
22
|
+
path: { searchProfile: "global" },
|
|
23
|
+
query: { query: "test" },
|
|
24
|
+
},
|
|
25
|
+
});
|
|
19
26
|
```
|
|
20
27
|
|
|
21
|
-
|
|
28
|
+
### Get works
|
|
22
29
|
|
|
23
|
-
|
|
30
|
+
```typescript
|
|
31
|
+
const { data, error } = await bmdbSearchClient.GET("/{searchProfile}/works", {
|
|
32
|
+
params: {
|
|
33
|
+
path: { searchProfile: "deichman" },
|
|
34
|
+
query: { ids: "1237715,1237713" },
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
```
|
|
24
38
|
|
|
25
|
-
|
|
39
|
+
### Search agents
|
|
26
40
|
|
|
27
41
|
```typescript
|
|
28
|
-
|
|
29
|
-
|
|
42
|
+
const { data, error } = await bmdbSearchClient.GET("/{searchProfile}/agents/search", {
|
|
43
|
+
params: {
|
|
44
|
+
path: { searchProfile: "tonsberg" },
|
|
45
|
+
query: { query: "test" },
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
```
|
|
30
49
|
|
|
31
|
-
|
|
32
|
-
|
|
50
|
+
### Find all contributor roles for a given agent
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
const { data, error } = await bmdbSearchClient.GET("/{searchProfile}/agents/search", {
|
|
54
|
+
params: {
|
|
55
|
+
path: { searchProfile: "global" },
|
|
56
|
+
query: { facet: "role", size: 0, facet_terms_size: 20 },
|
|
57
|
+
},
|
|
33
58
|
});
|
|
59
|
+
```
|
|
34
60
|
|
|
35
|
-
|
|
61
|
+
The arguments and response are fully typed.
|
|
62
|
+
|
|
63
|
+
## Usage with Next.js
|
|
64
|
+
|
|
65
|
+
The queries have to happen in a server context. For this purpose we can create a server client:
|
|
36
66
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
67
|
+
```typescript
|
|
68
|
+
"server only";
|
|
69
|
+
|
|
70
|
+
import { createBmdbFetchClient } from "@biblioteksentralen/bmdb-search";
|
|
71
|
+
import { headers } from "next/headers";
|
|
43
72
|
|
|
73
|
+
export const getBmdbServerFetchClient = async () =>
|
|
74
|
+
createBmdbFetchClient({
|
|
75
|
+
host: "http://localhost:8092",
|
|
76
|
+
headers: await headers(),
|
|
77
|
+
});
|
|
44
78
|
```
|