@fytkit/sdk 0.1.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/CHANGELOG.md +38 -0
- package/README.md +70 -0
- package/dist/index.d.ts +1554 -0
- package/dist/index.js +412 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@fytkit/sdk` are documented in this file.
|
|
4
|
+
Format: [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
+
Versioning: [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.0] — 2026-05-18
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- First public stable pre-1.0 release. No public-surface changes since `0.1.0-pre.0`; the `pre` suffix is dropped now that the sample app at `examples/sdk-react/`, the Playwright e2e (`tests/e2e/sdk-react-sample-app.spec.ts`), and the developer docs are landed.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- Verified against a runnable sample app at `examples/sdk-react/` exercising every documented surface end-to-end.
|
|
18
|
+
- CORS support on `/rpc` so cross-origin browser apps can call the SDK without proxying.
|
|
19
|
+
|
|
20
|
+
## [0.1.0-pre.0] — 2026-05-18
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- Initial pre-release of the vanilla TypeScript SDK.
|
|
25
|
+
- `createFytkitClient({ clientId, baseUrl?, storage?, fetch? })` factory.
|
|
26
|
+
- `auth` namespace: `signUp`, `signIn`, `signOut`, `getSession`, `onAuthStateChange`, `requestPasswordReset`, `confirmPasswordReset`, `confirmEmail`.
|
|
27
|
+
- Data namespaces: `workouts`, `programs`, `recipes`, `nutrition`, `articles`, `enrollments`, `sessionLogs`, `progression`, `media`, `appConfig`, `subscription`.
|
|
28
|
+
- `FytkitError` discriminated union with normalised error kinds.
|
|
29
|
+
- Pluggable `TokenStorage` (default: `localStorage`; bundled in-memory adapter for SSR/tests).
|
|
30
|
+
- Proactive refresh ~60 s before token expiry + reactive 401 retry-with-refresh.
|
|
31
|
+
|
|
32
|
+
### Known issues
|
|
33
|
+
|
|
34
|
+
- `signed_out_due_to_token_reuse` is reserved in the `AuthState` union but is never emitted by the current backend (no refresh-token rotation yet).
|
|
35
|
+
|
|
36
|
+
[Unreleased]: https://github.com/cbarlow1993/fytkit-web/compare/@fytkit/sdk@0.1.0...HEAD
|
|
37
|
+
[0.1.0]: https://github.com/cbarlow1993/fytkit-web/releases/tag/@fytkit/sdk@0.1.0
|
|
38
|
+
[0.1.0-pre.0]: https://github.com/cbarlow1993/fytkit-web/releases/tag/@fytkit/sdk@0.1.0-pre.0
|
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# @fytkit/sdk
|
|
2
|
+
|
|
3
|
+
Vanilla TypeScript SDK for the fytkit public API. Build a custom trainee-facing app on top of your fytkit programs, workouts, recipes, and Mux-protected video.
|
|
4
|
+
|
|
5
|
+
> v0.1.x is a pre-1.0 release line. The shape of every exported type is documented in [`etc/sdk.api.md`](./etc/sdk.api.md); breaking changes are recorded in [`CHANGELOG.md`](./CHANGELOG.md).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @fytkit/sdk @orpc/client
|
|
11
|
+
# or
|
|
12
|
+
npm install @fytkit/sdk @orpc/client
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Pin to an exact version while the SDK is pre-1.0:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @fytkit/sdk@0.1.0 @orpc/client
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Full install + version-pinning guidance: [`docs/developer/installation.md`](../../docs/developer/installation.md). Semver policy: [`docs/developer/concepts/versioning.md`](../../docs/developer/concepts/versioning.md).
|
|
22
|
+
|
|
23
|
+
## 30-second quickstart
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { createFytkitClient } from "@fytkit/sdk";
|
|
27
|
+
|
|
28
|
+
const fytkit = createFytkitClient({
|
|
29
|
+
clientId: "fk_app_xxxxxxxxxxxxxxxxx", // from /dashboard/developer
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Sign a trainee in (your own auth UI calls this)
|
|
33
|
+
const session = await fytkit.auth.signIn({
|
|
34
|
+
email: "trainee@example.com",
|
|
35
|
+
password: "their-password",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Fetch their workouts
|
|
39
|
+
const { items } = await fytkit.workouts.list({ limit: 20 });
|
|
40
|
+
|
|
41
|
+
// Subscribe to auth state (e.g. to redirect on sign-out)
|
|
42
|
+
const off = fytkit.auth.onAuthStateChange((state) => {
|
|
43
|
+
if (state.type === "signed_out") window.location.assign("/sign-in");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Sign out — revokes the server-side session and clears local storage
|
|
47
|
+
await fytkit.auth.signOut();
|
|
48
|
+
off();
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## What's included in this preview
|
|
52
|
+
|
|
53
|
+
- `auth.signUp` / `signIn` / `signOut` / `getSession` / `onAuthStateChange`
|
|
54
|
+
- `auth.requestPasswordReset` / `confirmPasswordReset` / `confirmEmail`
|
|
55
|
+
- Data namespaces: `workouts`, `programs`, `recipes`, `nutrition`, `articles`, `enrollments`, `sessionLogs`, `progression`, `media`, `appConfig`, `subscription`
|
|
56
|
+
- Automatic header injection (`X-Fytkit-Client-Id`, `Authorization: Bearer …`)
|
|
57
|
+
- Proactive refresh ~60 s before token expiry + reactive 401 retry
|
|
58
|
+
- Pluggable token storage (`localStorage` default, in-memory + cookie for SSR)
|
|
59
|
+
|
|
60
|
+
## Storage trade-off
|
|
61
|
+
|
|
62
|
+
Access tokens land in `localStorage` by default, namespaced by `clientId`. Any script running on your origin can read them — ship a strict CSP and treat the SDK like any other auth-bearing dependency. Token TTL is ~15 minutes and refresh requires the server, so a leaked token has a short blast radius.
|
|
63
|
+
|
|
64
|
+
Use `createMemoryStorageAdapter()` for SSR + tests.
|
|
65
|
+
|
|
66
|
+
## Coming next
|
|
67
|
+
|
|
68
|
+
- `@fytkit/react` — hooks + `<FytkitVideo>`
|
|
69
|
+
- `examples/sdk-react` — runnable sample app
|
|
70
|
+
- `docs/sdk/quickstart.md` — full guide
|