@bowmark/web 1.24.1 → 1.25.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 +59 -7
- package/dist/generated/library.d.ts +6326 -419
- package/dist/generated/validators.js +12473 -4116
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/session.d.ts +35 -1
- package/dist/session.js +117 -16
- package/dist/transport.d.ts +63 -1
- package/dist/transport.js +81 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -119,6 +119,52 @@ literal gets no typechecking, so the generated types cover `session()` and `bowm
|
|
|
119
119
|
and never this. It returns the envelope rather than throwing, because a script is
|
|
120
120
|
composite: `status`, `logs` and `result` are read together.
|
|
121
121
|
|
|
122
|
+
### Signing in — `login()`, `{ connection }`, and `bm.connections.*`
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import { session } from "@bowmark/web";
|
|
126
|
+
|
|
127
|
+
await session(async (bm) => {
|
|
128
|
+
const a = await bm.providers.reddit.login({ username: "u1", password: "p1" });
|
|
129
|
+
const b = await bm.providers.reddit.login({ username: "u2", password: "p2" });
|
|
130
|
+
|
|
131
|
+
await bm.providers.reddit.vote({ id: "t3_x", direction: "up" }, { connection: a.connection });
|
|
132
|
+
await bm.providers.reddit.vote({ id: "t3_y", direction: "up" }, { connection: b.connection });
|
|
133
|
+
|
|
134
|
+
await bm.connections.update(a.connection, { keepAlive: { everyHours: 6 } });
|
|
135
|
+
await bm.connections.logout(a.connection); // ends the site session, keeps the entry
|
|
136
|
+
await bm.connections.delete(b.connection); // forgets the entry, site session untouched
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**`login()` exists on any provider with login adapters, and every login is a NEW,
|
|
141
|
+
separate connection** — calling it twice never replaces the first. Pass `connection: id`
|
|
142
|
+
in its argument to sign back in to an existing one instead (its id and settings are kept; a
|
|
143
|
+
`logged_out` one is revived). The returned `connection` works on the very next call, and
|
|
144
|
+
`warnings` names your other connections to that site. Its `username` /
|
|
145
|
+
`password` / `totpCode` / `totpSeed` are plain strings, unlike the `bowmark.secret()`
|
|
146
|
+
references a `run()` script must use: this client's transport lifts each one into a
|
|
147
|
+
per-request `x-bowmark-credential-<name>` header before the call leaves your process,
|
|
148
|
+
so the value never rides in the request body a run row, a log or a trace could carry.
|
|
149
|
+
`keepAlive`/`expiresAt` are ordinary values and travel in the body unchanged — absent
|
|
150
|
+
means a 12-hour keep-alive.
|
|
151
|
+
|
|
152
|
+
**Every signed-in function accepts a trailing `{ connection }`.** Omit it and the call
|
|
153
|
+
uses the provider's default connection; several live and none marked default throws a
|
|
154
|
+
caller-fixable `ConnectionAmbiguous` error listing them. `login()`'s own return value
|
|
155
|
+
is `{ connection, account, expiresAt }` — pass `connection` straight into a later call.
|
|
156
|
+
|
|
157
|
+
**`bm.connections.list/logout/delete/update`** are REST over `/v1/connections`, not part
|
|
158
|
+
of the generic capability dispatch. `logout` drops Bowmark's cookies, ends the session on
|
|
159
|
+
the site where the provider can (`siteSignedOut: true` is checked, not assumed;
|
|
160
|
+
`siteLogout: "unsupported"` says the site offers no way), and KEEPS the entry as
|
|
161
|
+
`logged_out` so `login({ connection: id })` can revive it. `delete` forgets Bowmark's own
|
|
162
|
+
row and cookies; it does **not** sign the account out on the site.
|
|
163
|
+
|
|
164
|
+
**Python note:** `bowmark_web-stubs` types `login()` and `{ connection }` for parity,
|
|
165
|
+
but the Python **runtime** does not yet lift credentials into a header the way this
|
|
166
|
+
client does — see `packages/bowmark-web/python/README.md` if you hit this from Python.
|
|
167
|
+
|
|
122
168
|
### What it throws
|
|
123
169
|
|
|
124
170
|
| Class | When | What to do |
|
|
@@ -139,7 +185,13 @@ takes them — or set `BOWMARK_API_KEY` and `BOWMARK_API_URL`, read at CALL time
|
|
|
139
185
|
is required**: without one the first call throws `code: "no_api_key"` and sends nothing.
|
|
140
186
|
A caller header cannot displace the key.
|
|
141
187
|
|
|
142
|
-
##
|
|
188
|
+
## Internals — how this package is built, generated and published
|
|
189
|
+
|
|
190
|
+
Everything above is what you need to call the library. Everything below is for someone
|
|
191
|
+
working on this package itself — the generator, the guards, the publish pipeline. Skip
|
|
192
|
+
it unless you're changing how the SDK is built.
|
|
193
|
+
|
|
194
|
+
### The two halves, and why they are split
|
|
143
195
|
|
|
144
196
|
- **`src/{index,session,transport,guard,validate}.ts`** — hand-written, ~700 lines,
|
|
145
197
|
changes almost never.
|
|
@@ -174,7 +226,7 @@ argument the wire cannot carry.
|
|
|
174
226
|
that, `await bowmark.music` would find a callable `then`, invoke it as a thenable, and
|
|
175
227
|
hang forever waiting for a resolve a path segment can never call.
|
|
176
228
|
|
|
177
|
-
|
|
229
|
+
### The wire guard is a checked COPY
|
|
178
230
|
|
|
179
231
|
`src/guard.ts` duplicates `wireProblem` from `packages/schema/src/wire.ts`, because
|
|
180
232
|
importing the workspace package would break the tarball for everyone outside this repo.
|
|
@@ -188,7 +240,7 @@ things (a circular structure and a `BigInt`) and silently mangles everything els
|
|
|
188
240
|
→ dropped. Temporal shipped that exact bug, diagnosed it as a typing problem, and closed
|
|
189
241
|
it won't-fix.
|
|
190
242
|
|
|
191
|
-
|
|
243
|
+
### The argument guard is TWO guards, in this order
|
|
192
244
|
|
|
193
245
|
`assertWireSafeArgs` asks whether the value can cross at all — a `Date`, a `Map`, a
|
|
194
246
|
function, a circular structure. `assertArgShape` asks whether it matches what the
|
|
@@ -244,7 +296,7 @@ refuses one, with no exception set — an exception would be a declaration that
|
|
|
244
296
|
parameter is uncallable. Found once, on `pizzahut.priceOrder`, by generating validators
|
|
245
297
|
for all 253 typed parameters.
|
|
246
298
|
|
|
247
|
-
|
|
299
|
+
### What ships is compiled, not `src/` verbatim
|
|
248
300
|
|
|
249
301
|
`main`/`types` point at `dist/index.{js,d.ts}`. `dist/` is never committed — it does not
|
|
250
302
|
exist in this workspace and does not exist in the public mirror's git history either — it
|
|
@@ -273,7 +325,7 @@ all and `BowmarkLibrary` — the type this package exists to ship — reads as `
|
|
|
273
325
|
name`. `build.mjs` re-inserts the reference line and copies `library.d.ts` into
|
|
274
326
|
`dist/generated/` verbatim (it has nothing to compile).
|
|
275
327
|
|
|
276
|
-
|
|
328
|
+
### Regenerating
|
|
277
329
|
|
|
278
330
|
```bash
|
|
279
331
|
pnpm run gen:public-types # writes src/generated/{library.d.ts,validators.ts}
|
|
@@ -297,7 +349,7 @@ TypeScript with no build step, so a generate-at-build artifact leaves `tsc` and
|
|
|
297
349
|
with nothing to read on a fresh clone. Committed plus a staleness gate is the only shape
|
|
298
350
|
that works. Never hand-edit it.
|
|
299
351
|
|
|
300
|
-
|
|
352
|
+
### Four things the generator does that look like bugs and are not
|
|
301
353
|
|
|
302
354
|
**One namespace per unit.** `music` and `flights` both declare `CallOptions`; `Track` and
|
|
303
355
|
`Store` are names any provider may take. Each unit's `types` block is emitted VERBATIM
|
|
@@ -334,7 +386,7 @@ declare is refused, so their interface is empty. The generated file says so in w
|
|
|
334
386
|
because an empty interface reads as "this unit does nothing", which is a different and
|
|
335
387
|
wronger claim than "we can make no typed claim about anything it does".
|
|
336
388
|
|
|
337
|
-
|
|
389
|
+
### Scale
|
|
338
390
|
|
|
339
391
|
Measured 2026-08-05 on synthetic units, one namespace each:
|
|
340
392
|
|