@farthershore/farthershore-js 0.0.0 → 0.1.1

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +97 -18
  3. package/dist/catalog.d.ts +2 -2
  4. package/dist/catalog.d.ts.map +1 -1
  5. package/dist/catalog.js +15 -5
  6. package/dist/catalog.js.map +1 -1
  7. package/dist/client.d.ts +62 -2
  8. package/dist/client.d.ts.map +1 -1
  9. package/dist/client.js +50 -3
  10. package/dist/client.js.map +1 -1
  11. package/dist/config.d.ts.map +1 -1
  12. package/dist/config.js +3 -2
  13. package/dist/config.js.map +1 -1
  14. package/dist/errors.d.ts +30 -6
  15. package/dist/errors.d.ts.map +1 -1
  16. package/dist/errors.js +34 -7
  17. package/dist/errors.js.map +1 -1
  18. package/dist/http.d.ts +3 -0
  19. package/dist/http.d.ts.map +1 -1
  20. package/dist/http.js +12 -1
  21. package/dist/http.js.map +1 -1
  22. package/dist/index.d.ts +5 -4
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +2 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/react/hooks.d.ts +5 -1
  27. package/dist/react/hooks.d.ts.map +1 -1
  28. package/dist/react/hooks.js +7 -11
  29. package/dist/react/hooks.js.map +1 -1
  30. package/dist/react/index.d.ts +2 -0
  31. package/dist/react/index.d.ts.map +1 -1
  32. package/dist/react/index.js +4 -0
  33. package/dist/react/index.js.map +1 -1
  34. package/dist/react/provider.d.ts.map +1 -1
  35. package/dist/react/provider.js +3 -3
  36. package/dist/react/provider.js.map +1 -1
  37. package/dist/react/use-async.d.ts +4 -2
  38. package/dist/react/use-async.d.ts.map +1 -1
  39. package/dist/react/use-async.js +11 -2
  40. package/dist/react/use-async.js.map +1 -1
  41. package/dist/resources/auth.d.ts +4 -1
  42. package/dist/resources/auth.d.ts.map +1 -1
  43. package/dist/resources/auth.js +2 -1
  44. package/dist/resources/auth.js.map +1 -1
  45. package/dist/resources/billing.d.ts +6 -5
  46. package/dist/resources/billing.d.ts.map +1 -1
  47. package/dist/resources/billing.js +5 -6
  48. package/dist/resources/billing.js.map +1 -1
  49. package/dist/resources/keys.d.ts +5 -1
  50. package/dist/resources/keys.d.ts.map +1 -1
  51. package/dist/resources/keys.js +2 -1
  52. package/dist/resources/keys.js.map +1 -1
  53. package/dist/resources/usage.d.ts +12 -6
  54. package/dist/resources/usage.d.ts.map +1 -1
  55. package/dist/resources/usage.js +27 -18
  56. package/dist/resources/usage.js.map +1 -1
  57. package/dist/types.d.ts +13 -0
  58. package/dist/types.d.ts.map +1 -1
  59. package/package.json +8 -4
  60. package/dist/resources/analytics.d.ts +0 -8
  61. package/dist/resources/analytics.d.ts.map +0 -1
  62. package/dist/resources/analytics.js +0 -9
  63. package/dist/resources/analytics.js.map +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@farthershore/farthershore-js` are documented here.
4
+ This project adheres to Semantic Versioning (pre-1.0: minors may break).
5
+
6
+ ## [Unreleased]
7
+
8
+ ## [0.1.1] - 2026-06-09
9
+
10
+ ### Added
11
+
12
+ - `createServerClient()` — a documented SSR/server entry point (explicit `portalHost` + injectable `fetch` + per-request `getToken`; no `window`/`location` assumption).
13
+ - Request cancellation: the read methods (`auth.getSession`, `keys.list`, `usage.*`, `billing.subscription`/`creditBalance`) accept `{ signal }`, and the React hooks abort the in-flight request on unmount / dep-change.
14
+ - `FartherShoreAbortError` — mapped from a fetch `AbortError`; ignored by the hooks (a cancelled read is never a user-facing error).
15
+ - `FartherShoreConfigError` for construction/misconfiguration; an ESLint guard on `src/**` ensures every failure stays a typed `FartherShore*` error.
16
+ - Contract **drift-detection** test that guards the SDK's mapped shapes against `@farthershore/contracts` (compile-time + runtime), plus exhaustive unit coverage (35 → 65 tests) and a tree-shaking verification test.
17
+ - Docs: Getting Started, Versioning & stability sections, and this CHANGELOG.
18
+
19
+ ## [0.1.0] - 2026-06-08
20
+
21
+ ### Added
22
+
23
+ - Initial public release: a framework-agnostic client + `/react` hooks + `catalog.ts` display helpers; the `auth` (Clerk `setToken` + persona `signIn`), `keys`, `usage`, `billing`, `plans`, `product`, and Gateway `feature()` resources. ESM, tree-shakeable (`sideEffects: false`), with the domain types re-exported from the `/react` subpath.
package/README.md CHANGED
@@ -4,11 +4,16 @@ The **Farther Shore Frontend SDK** — the canonical browser integration layer
4
4
  between a static frontend artifact (the default dev-portal template, generated
5
5
  frontends, managed components, custom frontends) and the Farther Shore platform.
6
6
 
7
- > **Internal & experimental.** Not published to npm yet (`private: true`).
8
- > Breaking changes are expected while we validate the API against the dev portal,
9
- > managed components, and a real builder-defined feature. The eventual public
10
- > name is `@farthershore/farthershore-js` (the `@stripe/stripe-js` analog to the
11
- > server-side `@farthershore/sdk`).
7
+ > **Status: `0.1.0` (early release).** Published to npm. Pre-1.0, so minor
8
+ > versions may include breaking changes while the API stabilizes against the dev
9
+ > portal, managed template, and real builder features. See [`PUBLISHING.md`](./PUBLISHING.md)
10
+ > for the gates to `1.0.0` (wire-contract lock, browser token exchange, gateway
11
+ > CORS, stage e2e). The `@stripe/stripe-js` analog to the server-side
12
+ > `@farthershore/sdk`.
13
+
14
+ ```bash
15
+ pnpm add @farthershore/farthershore-js # React is an optional peer (for /react)
16
+ ```
12
17
 
13
18
  ## Philosophy
14
19
 
@@ -31,6 +36,45 @@ The SDK decides **where** each request goes (Core for platform concerns, the
31
36
  Gateway for builder features), **how** it's authenticated, and the host/env
32
37
  scoping headers Core needs.
33
38
 
39
+ ## Getting started
40
+
41
+ ```bash
42
+ pnpm add @farthershore/farthershore-js
43
+ ```
44
+
45
+ ```ts
46
+ import { createFartherShoreClient } from "@farthershore/farthershore-js";
47
+
48
+ // 1. Create the client. In the browser, `coreUrl` is usually the only required
49
+ // field — `portalHost` defaults to `window.location.host`.
50
+ const fs = createFartherShoreClient({
51
+ coreUrl: "https://core.farthershore.com",
52
+ });
53
+
54
+ // 2. Discover the product/env/plans for this host (memoized; safe to re-call).
55
+ const { product, plans } = await fs.bootstrap();
56
+
57
+ // 3. Authenticate. In a preview/test env, exchange a persona access key for a
58
+ // session (Clerk envs instead pass `getToken` to the config / `setToken`).
59
+ await fs.auth.signIn({ apiKey: "fsk_test_…" });
60
+
61
+ // 4. Read platform state through the typed resources (→ Core).
62
+ const keys = await fs.keys.list(); // ApiKey[]
63
+ const usage = await fs.usage.snapshot(); // { summary, events, billingBasis }
64
+
65
+ // 5. Call a builder-defined feature (→ Gateway). Set the consumer API key once,
66
+ // then express intent by feature name + path — no Gateway URL in app code.
67
+ fs.setApiKey("fsk_live_…");
68
+ const forecast = await fs.feature("weather").json("/forecast?city=NYC");
69
+ ```
70
+
71
+ In React, the same calls are hooks that return `{ data, loading, error, refresh }`
72
+ (plus mutations) — see [React](#react-farthershorefarthershore-jsreact) below:
73
+
74
+ ```tsx
75
+ const { data, loading, error, refresh } = useApiKeys();
76
+ ```
77
+
34
78
  ## Surface
35
79
 
36
80
  | Namespace | Routes to | Methods |
@@ -39,15 +83,11 @@ scoping headers Core needs.
39
83
  | `fs.product` | (bootstrap) | `get()` |
40
84
  | `fs.auth` | Core | `getSession()`, `signIn({apiKey})` (persona), `signOut()`, `setToken()` |
41
85
  | `fs.keys` | Core | `list()`, `create()`, `revoke()`, `rotate()` |
42
- | `fs.usage` | Core | `summary()`, `events()`, ~~`timeseries()`~~ |
43
- | `fs.billing` | Core | `subscription()`, `openBillingPortal()`, ~~`invoices()`~~ |
44
- | `fs.analytics` | Core | ~~`requests()`~~ |
86
+ | `fs.usage` | Core | `summary()`, `events()`, `snapshot()` |
87
+ | `fs.billing` | Core | `subscription()`, `openBillingPortal()`, `creditBalance()` |
88
+ | `fs.plans` | Core / (bootstrap) | `list()`, `subscribe()` |
45
89
  | `fs.feature(name)` / `fs.invoke(path)` | **Gateway** | `fetch(path)`, `json(path)` |
46
90
 
47
- Struck-through methods have **no platform endpoint yet** and throw
48
- `FartherShoreNotImplementedError` (the SDK never silently no-ops a missing
49
- capability) — see Deferred.
50
-
51
91
  ## Auth
52
92
 
53
93
  - **Core** calls use the consumer **session token** as `Authorization: Bearer`.
@@ -76,6 +116,29 @@ createFartherShoreClient({
76
116
  });
77
117
  ```
78
118
 
119
+ ## SSR / server usage
120
+
121
+ On a server there is no `window`/`location` to infer the portal host from and no
122
+ ambient browser session — so use `createServerClient`, a documented alias for
123
+ `createFartherShoreClient` that makes that contract explicit. Pass `portalHost`
124
+ and `fetch` instead of relying on globals, and resolve the per-request session
125
+ via `getToken` (each request authenticates as a different user). Behaviour is
126
+ identical to the browser client — the config already guards `globalThis.location`
127
+ and requires an injectable `fetch` — so this is purely a discoverable entry point.
128
+
129
+ ```ts
130
+ import { createServerClient } from "@farthershore/farthershore-js";
131
+
132
+ const fs = createServerClient({
133
+ coreUrl: process.env.FS_CORE_URL!,
134
+ portalHost: "weather.farthershore.com", // no window.location on the server
135
+ getToken: () => sessionTokenForThisRequest, // per-request bearer
136
+ fetch, // Node 18+ global, or an injected impl
137
+ });
138
+
139
+ const sub = await fs.billing.subscription();
140
+ ```
141
+
79
142
  ## React (`@farthershore/farthershore-js/react`)
80
143
 
81
144
  The hooks live in a **subpath** of the same package — `react` is an _optional_
@@ -117,17 +180,33 @@ client. They're thin wrappers over the client — no duplicated logic.
117
180
 
118
181
  ## Deferred (no platform endpoint yet)
119
182
 
120
- - `usage.timeseries()` — Core exposes `summary` + recent `events` only; derive a
121
- series client-side or add a Core timeseries route.
122
- - `billing.invoices()` — invoices are viewed through `billing.openBillingPortal()`
123
- (Stripe-hosted); there's no JSON invoice list.
124
- - `analytics.requests()` — no consumer analytics endpoint; closest is
125
- `usage.events()` + audit logs.
126
183
  - **Clerk browser sign-in** is host-app-driven (pass `getToken`); the SDK doesn't
127
184
  bundle `@clerk/clerk-js`.
128
185
  - A browser-safe **short-lived gateway token** (vs. a long-lived `fsk_` key in the
129
186
  page) — the platform's `fsc_` context token is server-minted today.
130
187
 
188
+ ## Versioning & stability
189
+
190
+ This package is **pre-1.0 (`0.x`)**. Under SemVer's 0.x rules a **minor** bump
191
+ (`0.1.x` → `0.2.0`) may include **breaking changes**, so the usual caret range is
192
+ unsafe here:
193
+
194
+ - ❌ `^0.1` / `^0.1.0` — caret does **not** lock the minor across `0.x`; it would
195
+ silently accept a breaking `0.2.0`.
196
+ - ✅ Pin **exact** (`0.1.0`) or use a patch-only tilde (`~0.1.0`) until `1.0.0`.
197
+
198
+ Breaking changes within `0.x` are recorded in [`CHANGELOG.md`](./CHANGELOG.md)
199
+ (Keep a Changelog format) — read it before bumping.
200
+
201
+ **Path to `1.0.0`:** the API graduates to a stable major once the
202
+ [`PUBLISHING.md`](./PUBLISHING.md) gates clear — wire-contract lock (generated
203
+ from / pinned to `@farthershore/contracts`), the browser-safe gateway token
204
+ exchange, gateway CORS for product origins, and a live-stage e2e. At `1.0.0`,
205
+ caret ranges become safe again.
206
+
207
+ The `/react` subpath ships in the same package and version; **`react` is an
208
+ _optional_ peer dependency**, so non-React consumers never pull it in.
209
+
131
210
  ## Scripts
132
211
 
133
212
  ```bash
package/dist/catalog.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Grant, Meter, Plan, PlanMeter } from "./types.js";
1
+ import type { Grant, Meter, Plan, PlanMeter, UsageBillingBasis } from "./types.js";
2
2
  export type PlanKind = "free" | "pay_as_you_go" | "subscription" | "hybrid" | "prepaid" | "trial" | "custom";
3
3
  /**
4
4
  * Classify a plan into a single canonical kind — mirrors the shared
@@ -77,5 +77,5 @@ export type MeterUsageRow = {
77
77
  * `meters` is the product-level meter catalog (for labels/units); when empty,
78
78
  * the summary keys are used directly.
79
79
  */
80
- export declare function buildMeterUsageRows(plan: Plan | null, summary: Record<string, number>, meters: Meter[]): MeterUsageRow[];
80
+ export declare function buildMeterUsageRows(plan: Plan | null, summary: Record<string, number>, meters: Meter[], billingBasis?: UsageBillingBasis): MeterUsageRow[];
81
81
  //# sourceMappingURL=catalog.d.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AED,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,EAAE,CAMrD;AAwED,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CAKf;AAED,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,IAAI,GAAG,SAAS,GAAG,OAAO,CAAA;CAAE,CAIrD;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,MAAM,EAAE,KAAK,EAAE,EACf,YAAY,CAAC,EAAE,iBAAiB,GAC/B,aAAa,EAAE,CA0CjB"}
package/dist/catalog.js CHANGED
@@ -244,14 +244,20 @@ export function computeProgressBar(used, total) {
244
244
  * `meters` is the product-level meter catalog (for labels/units); when empty,
245
245
  * the summary keys are used directly.
246
246
  */
247
- export function buildMeterUsageRows(plan, summary, meters) {
248
- // Union of catalog dimensions and any dimension present in the summary.
247
+ export function buildMeterUsageRows(plan, summary, meters, billingBasis) {
248
+ // Union of catalog dimensions and any builder-metered dimension present in the
249
+ // summary. The built-in `dollars` credit/cost dimension the gateway records is
250
+ // NOT a product meter — only surface it if the builder explicitly defined a
251
+ // meter for it (then it's already in the catalog above). (`bandwidth_bytes`
252
+ // was removed from the meter model — `requests` is the only native meter.)
253
+ const TELEMETRY_DIMENSIONS = new Set(["dollars"]);
249
254
  const byKey = new Map();
250
255
  for (const m of meters)
251
256
  byKey.set(m.key, m);
252
257
  for (const key of Object.keys(summary)) {
253
- if (!byKey.has(key))
254
- byKey.set(key, { key, display: key });
258
+ if (byKey.has(key) || TELEMETRY_DIMENSIONS.has(key))
259
+ continue;
260
+ byKey.set(key, { key, display: key });
255
261
  }
256
262
  const rows = [];
257
263
  for (const meter of byKey.values()) {
@@ -260,7 +266,11 @@ export function buildMeterUsageRows(plan, summary, meters) {
260
266
  if (quota != null || used > 0) {
261
267
  rows.push({
262
268
  key: meter.key,
263
- label: meter.display,
269
+ // A weighted/usage-billed product relabels the bare `requests` count as
270
+ // "Usage" (a call can cost >1 unit); every other meter keeps its name.
271
+ label: meter.key === "requests" && billingBasis === "usage"
272
+ ? "Usage"
273
+ : meter.display,
264
274
  used,
265
275
  quota,
266
276
  ...(meter.unit ? { unit: meter.unit } : {}),
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,qEAAqE;AACrE,gFAAgF;AAChF,EAAE;AACF,4EAA4E;AAC5E,gFAAgF;AAChF,6EAA6E;AAC7E,0BAA0B;AAI1B,0EAA0E;AAC1E,SAAS,UAAU,CAAC,KAAgB;IAClC,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAClE,CAAC;AAaD,sEAAsE;AACtE,SAAS,iBAAiB,CAAC,IAA0B;IACnD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAC5B,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU;YAAE,OAAO,CAAC,CAAC,YAAY,CAAC;IACnD,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED;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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO,SAAS,GAAG,SAAS,CAAC;QAC1D,IAAI,SAAS,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC3D,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;IACzB,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC"}
package/dist/client.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { type FartherShoreConfig } from "./config.js";
2
+ import { type CoreRequest } from "./http.js";
2
3
  import { type ProductResource } from "./resources/product.js";
3
4
  import { type AuthResource } from "./resources/auth.js";
4
5
  import { type KeysResource } from "./resources/keys.js";
5
6
  import { type UsageResource } from "./resources/usage.js";
6
7
  import { type BillingResource } from "./resources/billing.js";
7
8
  import { type PlansResource } from "./resources/plans.js";
8
- import { type AnalyticsResource } from "./resources/analytics.js";
9
9
  import { type FeatureHandle, type GatewayRequestInit } from "./resources/feature.js";
10
10
  import type { Bootstrap } from "./types.js";
11
11
  export interface FartherShoreClient {
@@ -16,18 +16,78 @@ export interface FartherShoreClient {
16
16
  setApiKey(key: string | null): void;
17
17
  /** Set the Core session bearer directly (e.g. from the Clerk browser SDK). */
18
18
  setSessionToken(token: string | null): void;
19
+ /** The product this frontend runs for (resolved via bootstrap). */
19
20
  readonly product: ProductResource;
21
+ /** Consumer session: persona/Clerk sign-in, the current session, sign-out. */
20
22
  readonly auth: AuthResource;
23
+ /** The consumer's API keys (list / create / revoke / rotate). */
21
24
  readonly keys: KeysResource;
25
+ /** Per-dimension usage totals + recent events for this product. */
22
26
  readonly usage: UsageResource;
27
+ /** The consumer's subscription, the Stripe billing portal, and credit balance. */
23
28
  readonly billing: BillingResource;
24
29
  /** The product's plan catalog + the subscribe/checkout flow. */
25
30
  readonly plans: PlansResource;
26
- readonly analytics: AnalyticsResource;
27
31
  /** A handle to a builder-defined feature, routed through the Gateway. */
28
32
  feature(name: string): FeatureHandle;
29
33
  /** Generic Gateway call (alias for `feature("…").fetch`). */
30
34
  invoke(path: string, init?: GatewayRequestInit): Promise<Response>;
35
+ /**
36
+ * Generic authenticated Core call — the escape hatch for platform endpoints
37
+ * the typed resources don't model yet (e.g. a product's `/me/team`,
38
+ * `/me/audit-logs`, `/me/addons`). The Core counterpart to {@link invoke}:
39
+ * it attaches the session bearer + the host/env/org scoping headers and maps
40
+ * non-2xx to {@link FartherShoreApiError}, exactly like the typed resources —
41
+ * the caller only supplies the path and the response type. Prefer a typed
42
+ * resource (`fs.usage`, `fs.keys`, …) when one exists.
43
+ */
44
+ core<T>(req: CoreRequest): Promise<T>;
31
45
  }
46
+ /**
47
+ * SSR / server-side entry point. A thin, documented alias for
48
+ * {@link createFartherShoreClient} that makes the server contract explicit:
49
+ * there is **no `window`/`location`** to fall back on, so a server caller must
50
+ * supply what the browser would otherwise provide implicitly —
51
+ *
52
+ * - `portalHost` — the product/env host (no `globalThis.location.host` default
53
+ * exists on the server);
54
+ * - `fetch` — an injectable fetch (the platform doesn't assume a global one);
55
+ * - `getToken` — the per-request session bearer (each request authenticates as a
56
+ * different user, so resolve the token per call rather than via the browser's
57
+ * ambient session).
58
+ *
59
+ * Behaviour is identical to {@link createFartherShoreClient} — `buildContext`
60
+ * already guards `globalThis.location` and requires an injectable `fetch` — so
61
+ * this adds no runtime behaviour; it's a discoverable, self-documenting entry
62
+ * point for SSR/server usage.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const fs = createServerClient({
67
+ * coreUrl: process.env.FS_CORE_URL!,
68
+ * portalHost: "weather.farthershore.com",
69
+ * getToken: () => sessionTokenForThisRequest,
70
+ * fetch, // Node 18+ global, or an injected impl
71
+ * });
72
+ * const sub = await fs.billing.subscription();
73
+ * ```
74
+ */
75
+ export declare function createServerClient(config: FartherShoreConfig): FartherShoreClient;
76
+ /**
77
+ * Create a {@link FartherShoreClient}. In the browser the minimal config is
78
+ * `{ coreUrl }` — the platform Core base URL; `portalHost` defaults to
79
+ * `window.location.host` and the product is discovered at {@link
80
+ * FartherShoreClient.bootstrap}. The returned client owns all routing (Core vs
81
+ * Gateway), auth, and host/env scoping; app code only expresses intent via its
82
+ * typed resources (`fs.usage`, `fs.keys`, `fs.feature(…)`, …). For SSR/server
83
+ * use, prefer {@link createServerClient}.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * const fs = createFartherShoreClient({ coreUrl: "https://core.farthershore.com" });
88
+ * const { product } = await fs.bootstrap();
89
+ * const keys = await fs.keys.list();
90
+ * ```
91
+ */
32
92
  export declare function createFartherShoreClient(config: FartherShoreConfig): FartherShoreClient;
33
93
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,kBAAkB,EAGxB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,kBAAkB;IACjC;yCACqC;IACrC,SAAS,IAAI,OAAO,CAAC,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;;;;;;;;;;;GAeG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,kBAAkB,GACzB,kBAAkB,CAwCpB"}
package/dist/client.js CHANGED
@@ -4,15 +4,62 @@
4
4
  // vs Gateway, auth, host/env scoping.
5
5
  import { buildContext, } from "./config.js";
6
6
  import { resolveBootstrap } from "./bootstrap.js";
7
- import { gatewayFetch } from "./http.js";
7
+ import { coreFetch, gatewayFetch } from "./http.js";
8
8
  import { createProductResource, } from "./resources/product.js";
9
9
  import { createAuthResource } from "./resources/auth.js";
10
10
  import { createKeysResource } from "./resources/keys.js";
11
11
  import { createUsageResource } from "./resources/usage.js";
12
12
  import { createBillingResource, } from "./resources/billing.js";
13
13
  import { createPlansResource } from "./resources/plans.js";
14
- import { createAnalyticsResource, } from "./resources/analytics.js";
15
14
  import { createFeature, } from "./resources/feature.js";
15
+ /**
16
+ * SSR / server-side entry point. A thin, documented alias for
17
+ * {@link createFartherShoreClient} that makes the server contract explicit:
18
+ * there is **no `window`/`location`** to fall back on, so a server caller must
19
+ * supply what the browser would otherwise provide implicitly —
20
+ *
21
+ * - `portalHost` — the product/env host (no `globalThis.location.host` default
22
+ * exists on the server);
23
+ * - `fetch` — an injectable fetch (the platform doesn't assume a global one);
24
+ * - `getToken` — the per-request session bearer (each request authenticates as a
25
+ * different user, so resolve the token per call rather than via the browser's
26
+ * ambient session).
27
+ *
28
+ * Behaviour is identical to {@link createFartherShoreClient} — `buildContext`
29
+ * already guards `globalThis.location` and requires an injectable `fetch` — so
30
+ * this adds no runtime behaviour; it's a discoverable, self-documenting entry
31
+ * point for SSR/server usage.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const fs = createServerClient({
36
+ * coreUrl: process.env.FS_CORE_URL!,
37
+ * portalHost: "weather.farthershore.com",
38
+ * getToken: () => sessionTokenForThisRequest,
39
+ * fetch, // Node 18+ global, or an injected impl
40
+ * });
41
+ * const sub = await fs.billing.subscription();
42
+ * ```
43
+ */
44
+ export function createServerClient(config) {
45
+ return createFartherShoreClient(config);
46
+ }
47
+ /**
48
+ * Create a {@link FartherShoreClient}. In the browser the minimal config is
49
+ * `{ coreUrl }` — the platform Core base URL; `portalHost` defaults to
50
+ * `window.location.host` and the product is discovered at {@link
51
+ * FartherShoreClient.bootstrap}. The returned client owns all routing (Core vs
52
+ * Gateway), auth, and host/env scoping; app code only expresses intent via its
53
+ * typed resources (`fs.usage`, `fs.keys`, `fs.feature(…)`, …). For SSR/server
54
+ * use, prefer {@link createServerClient}.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const fs = createFartherShoreClient({ coreUrl: "https://core.farthershore.com" });
59
+ * const { product } = await fs.bootstrap();
60
+ * const keys = await fs.keys.list();
61
+ * ```
62
+ */
16
63
  export function createFartherShoreClient(config) {
17
64
  const ctx = buildContext(config);
18
65
  let cached = null;
@@ -48,9 +95,9 @@ export function createFartherShoreClient(config) {
48
95
  usage: createUsageResource(ctx),
49
96
  billing: createBillingResource(ctx),
50
97
  plans: createPlansResource(ctx, ensureBootstrap),
51
- analytics: createAnalyticsResource(),
52
98
  feature: (name) => createFeature(ctx, name),
53
99
  invoke: (path, init) => gatewayFetch(ctx, path, init),
100
+ core: (req) => coreFetch(ctx, req),
54
101
  };
55
102
  }
56
103
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,sCAAsC;AAEtC,OAAO,EAGL,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACL,qBAAqB,GAEtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAqB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAqB,MAAM,qB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B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;0CACsC;IACtC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,KAAK,EAAE,SAAS,CAAC;CAClB;AAMD,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,aAAa,CAkCtE;AAED;4DAC4D;AAC5D,wBAAsB,YAAY,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAO7E"}
package/dist/config.js CHANGED
@@ -4,12 +4,13 @@
4
4
  // endpoints, or routing rules. It configures the client ONCE (usually just a
5
5
  // coreUrl) and expresses intent (`fs.usage.summary()`); the SDK owns where the
6
6
  // request goes and how it's authenticated.
7
+ import { FartherShoreConfigError } from "./errors.js";
7
8
  function trimTrailingSlash(u) {
8
9
  return u.replace(/\/+$/, "");
9
10
  }
10
11
  export function buildContext(config) {
11
12
  if (!config.coreUrl) {
12
- throw new Error("createFartherShoreClient: `coreUrl` is required");
13
+ throw new FartherShoreConfigError("createFartherShoreClient: `coreUrl` is required");
13
14
  }
14
15
  const portalHost = config.portalHost ??
15
16
  (typeof globalThis !== "undefined" &&
@@ -19,7 +20,7 @@ export function buildContext(config) {
19
20
  const fetchImpl = config.fetch ??
20
21
  (typeof fetch !== "undefined" ? fetch.bind(globalThis) : undefined);
21
22
  if (!fetchImpl) {
22
- throw new Error("createFartherShoreClient: no global fetch; pass `fetch` in the config");
23
+ throw new FartherShoreConfigError("createFartherShoreClient: no global fetch; pass `fetch` in the config");
23
24
  }
24
25
  return {
25
26
  coreUrl: trimTrailingSlash(config.coreUrl),
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,2CAA2C;AA0D3C,SAAS,iBAAiB,CAAC,CAAS;IAClC,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,UAAU,GACd,MAAM,CAAC,UAAU;QACjB,CAAC,OAAO,UAAU,KAAK,WAAW;YACjC,UAA+C,CAAC,QAAQ,EAAE,IAAI;YAC7D,CAAC,CAAE,UAA6C,CAAC,QAAQ,CAAC,IAAI;YAC9D,CAAC,CAAC,IAAI,CAAC,CAAC;IAEZ,MAAM,SAAS,GACb,MAAM,CAAC,KAAK;QACZ,CAAC,OAAO,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACtE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC;QAC1C,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI;QACxD,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;QACnC,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,IAAI;QAC3C,cAAc,EAAE,MAAM,CAAC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ist/errors.d.ts CHANGED
@@ -1,8 +1,27 @@
1
1
  export declare class FartherShoreError extends Error {
2
2
  constructor(message: string);
3
3
  }
4
- /** A non-2xx response from Core or the Gateway. Carries the platform error
5
- * envelope `{ error: { code, message } }` when present. */
4
+ /**
5
+ * A non-2xx response from Core or the Gateway. Exposes:
6
+ * - `.status` — the HTTP status code;
7
+ * - `.code` — the platform error code from the `{ error: { code, message } }`
8
+ * envelope (or a fallback when the envelope is absent);
9
+ * - `.body` — the parsed response body, for richer error detail.
10
+ *
11
+ * Callers commonly branch on `.status` — e.g. `401`/`403` (re-auth), `404`
12
+ * (treat as absent), `409` (conflict/retry) — rather than parsing the message.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * try {
17
+ * await fs.keys.list();
18
+ * } catch (err) {
19
+ * if (err instanceof FartherShoreApiError && err.status === 401) {
20
+ * // session expired — prompt re-auth
21
+ * } else throw err;
22
+ * }
23
+ * ```
24
+ */
6
25
  export declare class FartherShoreApiError extends FartherShoreError {
7
26
  readonly status: number;
8
27
  readonly code: string;
@@ -14,14 +33,19 @@ export declare class FartherShoreNetworkError extends FartherShoreError {
14
33
  readonly cause?: unknown;
15
34
  constructor(message: string, cause?: unknown);
16
35
  }
17
- /** Thrown when calling a surface that has no platform endpoint yet (an honest
18
- * stub the SDK never silently no-ops a missing capability). */
19
- export declare class FartherShoreNotImplementedError extends FartherShoreError {
20
- constructor(message: string);
36
+ /** Thrown when a request was aborted (e.g. a React hook unmounted or its deps
37
+ * changed before the request resolved). Callers/hooks should ignore it. */
38
+ export declare class FartherShoreAbortError extends FartherShoreError {
39
+ constructor(message?: string);
21
40
  }
22
41
  /** Thrown when the client is used before `bootstrap()` has resolved the product
23
42
  * it needs (e.g. a per-product call with no configured productId). */
24
43
  export declare class FartherShoreNotReadyError extends FartherShoreError {
25
44
  constructor(message: string);
26
45
  }
46
+ /** Thrown at client construction for invalid/missing config (e.g. no `coreUrl`,
47
+ * no global `fetch`). */
48
+ export declare class FartherShoreConfigError extends FartherShoreError {
49
+ constructor(message: string);
50
+ }
27
51
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM;CAI5B;AAED;4DAC4D;AAC5D,qBAAa,oBAAqB,SAAQ,iBAAiB;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBACX,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAOzE;AAED,8DAA8D;AAC9D,qBAAa,wBAAyB,SAAQ,iBAAiB;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;gBACb,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAK7C;AAED;kEACkE;AAClE,qBAAa,+BAAgC,SAAQ,iBAAiB;gBACxD,OAAO,EAAE,MAAM;CAI5B;AAED;uEACuE;AACvE,qBAAa,yBAA0B,SAAQ,iBAAiB;gBAClD,OAAO,EAAE,MAAM;CAI5B"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBACX,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EA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