@mymehq/sdk 5.6.0 → 5.7.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.
Files changed (2) hide show
  1. package/README.md +98 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # @mymehq/sdk
2
+
3
+ TypeScript HTTP client for the [Myme](https://myme.so) API.
4
+
5
+ ```bash
6
+ pnpm add @mymehq/sdk
7
+ ```
8
+
9
+ ```ts
10
+ import { MymeClient } from "@mymehq/sdk";
11
+
12
+ const client = new MymeClient({
13
+ url: "https://staging.myme.so",
14
+ apiKey: process.env.MYME_API_KEY,
15
+ });
16
+
17
+ const note = await client.items.create({
18
+ type: "core.note",
19
+ properties: { title: "Hello", body: "World" },
20
+ });
21
+ ```
22
+
23
+ ## Surface
24
+
25
+ `client.{items,types,keys,edges,search,metadata,tenants,webhooks,connections,auth}` — one nested namespace per API surface. Methods return the unwrapped resource (e.g. `client.items.get` returns `Item`, not `{ item }`); errors throw typed `MymeError` subclasses (`NotFoundError`, `ValidationError`, `UnauthorizedError`, `ForbiddenError`, `ConflictError`).
26
+
27
+ The OAuth helpers (PKCE, device flow, token storages, `MymeAuth`) ship under the `@mymehq/sdk/auth` subpath.
28
+
29
+ ## Testing
30
+
31
+ The SDK ships two in-process test fixtures so consumers can exercise the client against a real Hono server without a network. Both are in `packages/sdk/src/test-harness.ts`.
32
+
33
+ ### Keys-mode fixture (`createKeysModeFixture`)
34
+
35
+ For SDK surfaces that don't depend on `auth_user` resolution. Bootstraps a platform-admin API key over `POST /keys` and returns a client wired to it.
36
+
37
+ ```ts
38
+ import { createKeysModeFixture } from "./test-harness.js";
39
+
40
+ const { client, adminKey, cleanup } = await createKeysModeFixture();
41
+ try {
42
+ const note = await client.items.create({
43
+ type: "core.note",
44
+ properties: { body: "Hello" },
45
+ });
46
+ expect(note.id).toBeTruthy();
47
+ } finally {
48
+ cleanup();
49
+ }
50
+ ```
51
+
52
+ ### Hosted-mode fixture (`createHostedModeFixture`)
53
+
54
+ For SDK surfaces that resolve an `auth_user` from the bearer (account lifecycle, future passkey shims, anything that needs `client.auth.account.*`). Boots the server in `authMode: 'hosted'`, signs up a fresh user via the wrapped form endpoint (which provisions `tenants` + `users` bridge atomically), marks email-verified directly, and mints a `workspace_admin` API key bound to the new user's tenant. The returned client uses that key as bearer; account-lifecycle routes resolve through the bridge.
55
+
56
+ ```ts
57
+ import {
58
+ createHostedModeFixture,
59
+ readLatestAccountVerification,
60
+ } from "./test-harness.js";
61
+
62
+ const fixture = await createHostedModeFixture();
63
+ try {
64
+ await fixture.client.auth.account.requestDelete();
65
+
66
+ // The harness leaves emailTransport undefined; routes silently skip
67
+ // send. The confirm token still lands in auth_verification.
68
+ const token = await readLatestAccountVerification(
69
+ fixture.storage,
70
+ "account-delete:",
71
+ );
72
+ await fixture.client.auth.account.confirmDelete(token ?? "");
73
+
74
+ await fixture.client.auth.account.cancel();
75
+ } finally {
76
+ fixture.cleanup();
77
+ }
78
+ ```
79
+
80
+ The fixture exposes `email`, `authUserId`, `tenantId`, and `bearerKey` for tests that need to assert on or interact with the underlying user — e.g. minting additional clients against the same tenant, or correlating audit rows.
81
+
82
+ ### When to use which
83
+
84
+ | Surface under test | Fixture |
85
+ | ------------------------------------------------------------------------------------- | ------------------------- |
86
+ | `items` / `edges` / `search` / `types` / `metadata` / `tenants` / `webhooks` / `keys` | `createKeysModeFixture` |
87
+ | `auth.account.{requestDelete,confirmDelete,cancel}` | `createHostedModeFixture` |
88
+ | Any future SDK surface that resolves `auth_user.id` from the bearer | `createHostedModeFixture` |
89
+
90
+ Both fixtures share the same SQLite-backed in-process server. PG matrix coverage of the SDK lives off this scope — it runs through the server's `test:pg` matrix on every PR, not the SDK's `pnpm test`.
91
+
92
+ ## Build
93
+
94
+ `tsup` produces `dist/index.js` (ESM) and `dist/index.d.ts`. `@mymehq/types` declarations are inlined into the shared `.d.ts` so consumers only need `@mymehq/sdk` and `@mymehq/shared`.
95
+
96
+ ## Versioning
97
+
98
+ Major bumps when `@mymehq/shared` major-bumps (every wire-shape change cascades). Minor bumps for additive SDK features. Patch for bug fixes. Tag pushes (`v*`) trigger the OIDC-published release workflow; the workflow skips packages whose version is already on npm so unbumped packages are no-ops.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mymehq/sdk",
3
- "version": "5.6.0",
3
+ "version": "5.7.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",
@@ -20,7 +20,7 @@
20
20
  "dist"
21
21
  ],
22
22
  "dependencies": {
23
- "@mymehq/shared": "5.6.0"
23
+ "@mymehq/shared": "5.7.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^22.0.0",