@mymehq/sdk 5.5.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.
- package/README.md +98 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.js +17 -0
- 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/dist/index.d.ts
CHANGED
|
@@ -118,7 +118,7 @@ interface UpdateOptions {
|
|
|
118
118
|
* stamped `source`. The server enforces `(source, source_id)` uniqueness
|
|
119
119
|
* per tenant — a collision returns HTTP 409 `source_id_conflict`. PATCHing
|
|
120
120
|
* the value the item already carries is a no-op success. Used by the
|
|
121
|
-
* sync
|
|
121
|
+
* sync agent (T-118) to preserve item identity through file renames.
|
|
122
122
|
*/
|
|
123
123
|
source_id?: string;
|
|
124
124
|
/**
|
|
@@ -797,6 +797,24 @@ declare class MymeClient {
|
|
|
797
797
|
* surface for emergency revocation — pair with `client.keys.revoke`. */
|
|
798
798
|
list: (tenantId: string) => Promise<TenantApiKeySummary[]>;
|
|
799
799
|
};
|
|
800
|
+
accountDeletion: {
|
|
801
|
+
/**
|
|
802
|
+
* Force a one-shot run of the pending-delete purger (T-124).
|
|
803
|
+
* Returns the number of accounts purged this tick. Useful when
|
|
804
|
+
* an account has just passed its grace window and the operator
|
|
805
|
+
* doesn't want to wait for the next scheduled sweep (default
|
|
806
|
+
* cadence: 1 hour).
|
|
807
|
+
*
|
|
808
|
+
* Idempotent: re-running with no eligible rows returns 0. Only
|
|
809
|
+
* sweeps accounts already past `pending_deletion_at + grace_days`
|
|
810
|
+
* — does not bypass the grace window. The `run_at` timestamp is
|
|
811
|
+
* server-stamped at the moment `runOnce()` begins.
|
|
812
|
+
*/
|
|
813
|
+
purgeNow: () => Promise<{
|
|
814
|
+
purged_count: number;
|
|
815
|
+
run_at: string;
|
|
816
|
+
}>;
|
|
817
|
+
};
|
|
800
818
|
};
|
|
801
819
|
/**
|
|
802
820
|
* Account-lifecycle surface (T-116).
|
package/dist/index.js
CHANGED
|
@@ -1200,6 +1200,23 @@ var MymeClient = class {
|
|
|
1200
1200
|
const res = await this.transport.request("GET", `/admin/tenants/${encodeURIComponent(tenantId)}/keys`);
|
|
1201
1201
|
return res.data;
|
|
1202
1202
|
}
|
|
1203
|
+
},
|
|
1204
|
+
accountDeletion: {
|
|
1205
|
+
/**
|
|
1206
|
+
* Force a one-shot run of the pending-delete purger (T-124).
|
|
1207
|
+
* Returns the number of accounts purged this tick. Useful when
|
|
1208
|
+
* an account has just passed its grace window and the operator
|
|
1209
|
+
* doesn't want to wait for the next scheduled sweep (default
|
|
1210
|
+
* cadence: 1 hour).
|
|
1211
|
+
*
|
|
1212
|
+
* Idempotent: re-running with no eligible rows returns 0. Only
|
|
1213
|
+
* sweeps accounts already past `pending_deletion_at + grace_days`
|
|
1214
|
+
* — does not bypass the grace window. The `run_at` timestamp is
|
|
1215
|
+
* server-stamped at the moment `runOnce()` begins.
|
|
1216
|
+
*/
|
|
1217
|
+
purgeNow: async () => {
|
|
1218
|
+
return this.transport.request("POST", "/admin/account-deletion/purge-now");
|
|
1219
|
+
}
|
|
1203
1220
|
}
|
|
1204
1221
|
};
|
|
1205
1222
|
// ---- Auth (T-116) ----
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mymehq/sdk",
|
|
3
|
-
"version": "5.
|
|
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.
|
|
23
|
+
"@mymehq/shared": "5.7.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^22.0.0",
|