@bowmark/web 1.20.0 → 1.22.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/README.md +18 -4
- package/dist/generated/library.d.ts +855 -16
- package/dist/generated/validators.js +875 -4
- package/dist/transport.d.ts +16 -2
- package/dist/transport.js +12 -2
- package/package.json +1 -1
package/dist/transport.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ export type FetchLike = (input: string, init?: RequestInit) => Promise<Response>
|
|
|
4
4
|
/** How a client reaches the api. Every field is optional; the defaults read the
|
|
5
5
|
* environment the same way every other CLI-shaped client does. */
|
|
6
6
|
export interface ClientOptions {
|
|
7
|
-
/** `bmk_
|
|
8
|
-
*
|
|
7
|
+
/** `bmk_…`, from https://bowmark.ai/dashboard/keys. **Required** — pass it here,
|
|
8
|
+
* or set `BOWMARK_API_KEY`. Bowmark requires an account, so a client with neither
|
|
9
|
+
* throws `BowmarkError` with `code: "no_api_key"` on its first call. */
|
|
9
10
|
apiKey?: string;
|
|
10
11
|
/** Defaults to `BOWMARK_API_URL`, else `https://api.bowmark.ai`. */
|
|
11
12
|
baseUrl?: string;
|
|
@@ -63,6 +64,19 @@ export interface RunEnvelope<T = unknown> {
|
|
|
63
64
|
handoff?: Handoff;
|
|
64
65
|
wwwAuthenticate?: string;
|
|
65
66
|
};
|
|
67
|
+
/** Present when the account owner has not accepted Bowmark's current Terms or
|
|
68
|
+
* Privacy Policy. The run is unaffected; `notice.message` is for your user. */
|
|
69
|
+
notice?: {
|
|
70
|
+
kind: "legal_update";
|
|
71
|
+
message: string;
|
|
72
|
+
acceptUrl: string;
|
|
73
|
+
documents: {
|
|
74
|
+
slug: string;
|
|
75
|
+
title: string;
|
|
76
|
+
version: string;
|
|
77
|
+
url: string;
|
|
78
|
+
}[];
|
|
79
|
+
};
|
|
66
80
|
}
|
|
67
81
|
/** Which (capability, provider) pair has no live grant. */
|
|
68
82
|
export interface AuthNeed {
|
package/dist/transport.js
CHANGED
|
@@ -50,6 +50,13 @@ export class BowmarkNeedsUserError extends BowmarkError {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
const DEFAULT_BASE_URL = "https://api.bowmark.ai";
|
|
53
|
+
/** What a client with no key is told, before it sends anything. Worded like the
|
|
54
|
+
* api's own refusal (`apps/api/src/account-required.ts`), minus the parts about
|
|
55
|
+
* other clients. */
|
|
56
|
+
const NO_API_KEY_MESSAGE = "Bowmark needs an API key, and this client has none, so nothing was sent.\n" +
|
|
57
|
+
"1. Sign up at https://bowmark.ai/sign-up (free).\n" +
|
|
58
|
+
"2. Create an API key at https://bowmark.ai/dashboard/keys.\n" +
|
|
59
|
+
'3. Pass it as `client({ apiKey: "<key>" })`, or set the `BOWMARK_API_KEY` environment variable.';
|
|
53
60
|
/** Read one environment variable without depending on `@types/node`.
|
|
54
61
|
*
|
|
55
62
|
* This package compiles with `"types": []` and must run in a browser, a worker and
|
|
@@ -85,8 +92,11 @@ async function postJson(client, path, body) {
|
|
|
85
92
|
"content-type": "application/json",
|
|
86
93
|
accept: "application/json",
|
|
87
94
|
};
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
// Refused HERE rather than sent: the api would answer 401 with the same steps,
|
|
96
|
+
// and a round trip that can only fail is a slower way to say it.
|
|
97
|
+
if (!client.apiKey)
|
|
98
|
+
throw new BowmarkError(NO_API_KEY_MESSAGE, { code: "no_api_key" });
|
|
99
|
+
headers.authorization = `Bearer ${client.apiKey}`;
|
|
90
100
|
let response;
|
|
91
101
|
try {
|
|
92
102
|
response = await client.fetch(`${client.baseUrl}${path}`, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bowmark/web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The public client for the Bowmark capability library — real TypeScript for the whole bowmark.* surface, with no Bowmark source on the caller's disk. ZERO runtime dependencies, deliberately and permanently.",
|
|
6
6
|
"license": "MIT",
|