@hollware/client 0.4.0 → 0.5.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/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { WebhookCheck, describeSite, getEntry, getTranslations, listEntries, signWebhook, verifyWebhook } from "@hollware/core";
1
+ import { WebhookCheck, describeSite, getEntry, getTranslations, listEntries, search, signWebhook, verifyWebhook } from "@hollware/core";
2
2
  import * as z from "zod";
3
3
  //#region src/index.d.ts
4
4
  export declare const name = "@hollware/client";
@@ -6,6 +6,8 @@ type Output<Spec extends {
6
6
  output: z.ZodType;
7
7
  }> = z.output<Spec['output']>;
8
8
  export type Format = 'markdown' | 'document' | 'html';
9
+ /** How a search is made: by its words, by meaning, or both merged. */
10
+ export type SearchMode = 'fulltext' | 'semantic' | 'hybrid';
9
11
  /**
10
12
  * What a site reads from Hollware: the published content, through the four read methods. A
11
13
  * service binding to a Hollware Worker already has this shape; `createClient` gives the same over
@@ -14,6 +16,7 @@ export type Format = 'markdown' | 'document' | 'html';
14
16
  export interface HollwareReader {
15
17
  getEntry(site: string, collection: string, slug: string, locale: string, options?: {
16
18
  readonly formats?: readonly Format[];
19
+ readonly related?: boolean;
17
20
  }): Promise<Output<typeof getEntry>>;
18
21
  listEntries(site: string, collection: string, options?: {
19
22
  readonly locale?: string;
@@ -23,6 +26,13 @@ export interface HollwareReader {
23
26
  }): Promise<Output<typeof listEntries>>;
24
27
  getTranslations(site: string, collection: string, translationGroup: string): Promise<Output<typeof getTranslations>>;
25
28
  describeSite(site: string): Promise<Output<typeof describeSite>>;
29
+ /** The published entries that match `query`, best first: by its words, by meaning, or both. */
30
+ search(site: string, query: string, options?: {
31
+ readonly collection?: string;
32
+ readonly locale?: string;
33
+ readonly limit?: number;
34
+ readonly mode?: SearchMode;
35
+ }): Promise<Output<typeof search>>;
26
36
  }
27
37
  export type ClientOptions =
28
38
  /** A service binding to the `Hollware` entrypoint of a Hollware Worker. */
package/dist/index.mjs CHANGED
@@ -36,7 +36,10 @@ function httpReader(url, token, send) {
36
36
  }
37
37
  const segment = encodeURIComponent;
38
38
  return {
39
- getEntry: (_site, collection, slug, locale, options) => get(`${segment(collection)}/${segment(locale)}/${segment(slug)}`, { formats: options?.formats?.join(",") }),
39
+ getEntry: (_site, collection, slug, locale, options) => get(`${segment(collection)}/${segment(locale)}/${segment(slug)}`, {
40
+ formats: options?.formats?.join(","),
41
+ related: options?.related === true ? "true" : void 0
42
+ }),
40
43
  listEntries: (_site, collection, options = {}) => get(segment(collection), {
41
44
  locale: options.locale,
42
45
  tag: options.tag,
@@ -44,7 +47,14 @@ function httpReader(url, token, send) {
44
47
  cursor: options.cursor
45
48
  }),
46
49
  getTranslations: (_site, collection, group) => get(`${segment(collection)}/translations/${segment(group)}`),
47
- describeSite: (_site) => get("site")
50
+ describeSite: (_site) => get("site"),
51
+ search: (_site, query, options = {}) => get("search", {
52
+ q: query,
53
+ collection: options.collection,
54
+ locale: options.locale,
55
+ limit: options.limit === void 0 ? void 0 : String(options.limit),
56
+ mode: options.mode
57
+ })
48
58
  };
49
59
  }
50
60
  /**
@@ -60,7 +70,8 @@ function createClient(options) {
60
70
  getEntry: async (...args) => narrow(await reader.getEntry(...args)),
61
71
  listEntries: async (...args) => narrow(await reader.listEntries(...args)),
62
72
  getTranslations: async (...args) => narrow(await reader.getTranslations(...args)),
63
- describeSite: async (...args) => narrow(await reader.describeSite(...args))
73
+ describeSite: async (...args) => narrow(await reader.describeSite(...args)),
74
+ search: async (...args) => narrow(await reader.search(...args))
64
75
  };
65
76
  }
66
77
  /** The body of an answer, which the read API builds from the output schema of its operation. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hollware/client",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Typed Hollware client over a service binding or HTTP.",
5
5
  "homepage": "https://hollware.com",
6
6
  "bugs": {
@@ -28,7 +28,7 @@
28
28
  "provenance": true
29
29
  },
30
30
  "dependencies": {
31
- "@hollware/core": "0.4.0"
31
+ "@hollware/core": "0.5.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "24.19.2",