@mymehq/sdk 5.2.0 → 5.4.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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { MergeStrategy, ConflictSnapshot, MergePolicy, ItemState, Tier, CreateItemInput, Item, PaginatedResult, ItemWithMetadata, Version, Edge, Metadata, SearchResult, CreateEdgeInput, EdgeTypeSchema, TypeSchema, CreateKeyInput, ApiKey, UpdateKeyInput, CreateWebhookInput, Webhook, UpdateWebhookInput, WebhookDelivery, ConnectionInstallResult, ConnectionUninstallResult, PreviewEventRequest, PreviewEventResult, TenantConfig, TenantQuota, Profile, UpdateProfileInput } from '@mymehq/shared';
2
- export { ApiKey, ConflictSnapshot, CreateItemInput, CreateKeyInput, Item, ItemState, MergePolicy, MergeStrategy, Metadata, PaginatedResult, Profile, SearchResult, TypeSchema, UpdateKeyInput, UpdateProfileInput, Version } from '@mymehq/shared';
1
+ import { MergeStrategy, ConflictSnapshot, MergePolicy, ItemState, Tier, CreateItemInput, Item, PaginatedResult, ItemWithMetadata, Version, Edge, Metadata, SearchResult, CreateEdgeInput, EdgeTypeSchema, TypeSchema, CreateKeyInput, ApiKey, UpdateKeyInput, CreateWebhookInput, Webhook, UpdateWebhookInput, WebhookDelivery, ConnectionInstallResult, ConnectionUninstallResult, PreviewEventRequest, PreviewEventResult, TenantConfig, TenantQuota, Tenant, TenantActivityEntry, TenantMetrics, Profile, UpdateProfileInput } from '@mymehq/shared';
2
+ export { ApiKey, ConflictSnapshot, CreateItemInput, CreateKeyInput, Item, ItemState, MergePolicy, MergeStrategy, Metadata, PaginatedResult, Profile, SearchResult, Tenant, TenantActivityEntry, TenantMetrics, TenantQuota, TenantStatus, TypeSchema, UpdateKeyInput, UpdateProfileInput, Version } from '@mymehq/shared';
3
3
 
4
4
  /**
5
5
  * Conflict resolution strategy for item updates.
@@ -178,6 +178,21 @@ interface SearchFilters {
178
178
  interface MetadataInput {
179
179
  tags?: string[];
180
180
  }
181
+ /**
182
+ * Compact API-key summary returned by the admin keys-list route
183
+ * (T-117). The full `ApiKey` shape carries permission maps; the
184
+ * operator surface deliberately surfaces only the identifying fields +
185
+ * timestamps needed for emergency revocation.
186
+ */
187
+ interface TenantApiKeySummary {
188
+ id: string;
189
+ label: string;
190
+ source: string;
191
+ role: string;
192
+ is_platform: boolean;
193
+ created_at: string;
194
+ last_used_at: string | null;
195
+ }
181
196
  /** One item to create or upsert in a `POST /items/bulk` call. Shape is
182
197
  * `CreateItemInput` plus compact outbound-only inline `edges`. */
183
198
  interface BulkItemInput {
@@ -727,6 +742,81 @@ declare class MymeClient {
727
742
  }) => Promise<TenantQuota>;
728
743
  };
729
744
  };
745
+ /**
746
+ * Operator-level admin surface — the `my admin` CLI command tree's
747
+ * backing endpoints. Every method requires a platform-admin key
748
+ * (`is_platform: true`). Non-platform credentials get a `403
749
+ * forbidden`; render `"this command requires a platform-admin key"`
750
+ * in CLI / UI layers.
751
+ *
752
+ * Quota read/write is intentionally NOT duplicated here — it lives on
753
+ * `client.tenants.quotas.{getById, set}` and is already platform-
754
+ * admin-gated. The admin namespace mirrors what the CLI's `my admin`
755
+ * tree exposes; quotas are reached via the existing tenants surface.
756
+ */
757
+ readonly admin: {
758
+ tenants: {
759
+ /** List every tenant in the instance with current status. */
760
+ list: () => Promise<Tenant[]>;
761
+ /**
762
+ * Single tenant + per-tenant quota overrides + the most-recent
763
+ * `system.activity` items for the tenant (`null` quotas when no
764
+ * override is configured; quota fields then resolve to instance
765
+ * defaults).
766
+ */
767
+ show: (tenantId: string) => Promise<{
768
+ tenant: Tenant;
769
+ quotas: TenantQuota | null;
770
+ recent_activity: TenantActivityEntry[];
771
+ }>;
772
+ /**
773
+ * Flip the tenant's status to `'suspended'`. Future non-GET
774
+ * requests from credentials in the tenant return HTTP 403
775
+ * `tenant_suspended`. Reads pass through; platform-admin keys
776
+ * bypass. Idempotent.
777
+ */
778
+ suspend: (tenantId: string) => Promise<Tenant>;
779
+ /** Reverse of `suspend`. Idempotent. */
780
+ unsuspend: (tenantId: string) => Promise<Tenant>;
781
+ /**
782
+ * Per-tenant usage snapshot — item count by state, blob count
783
+ * and total bytes, custom-type count, plus recent activity.
784
+ */
785
+ metrics: (tenantId: string) => Promise<TenantMetrics>;
786
+ };
787
+ keys: {
788
+ /** Active (non-revoked) keys for the named tenant. Operator
789
+ * surface for emergency revocation — pair with `client.keys.revoke`. */
790
+ list: (tenantId: string) => Promise<TenantApiKeySummary[]>;
791
+ };
792
+ };
793
+ /**
794
+ * Account-lifecycle surface (T-116).
795
+ *
796
+ * The data plane (every other namespace on the client) authenticates
797
+ * with a bearer token; these account-management endpoints accept
798
+ * EITHER a bearer (workspace_admin / admin in the user's tenant)
799
+ * OR a better-auth session cookie. The CLI flow uses a bearer (the
800
+ * user's own key); web flows use the cookie. The transport sends
801
+ * the bearer header by default, so SDK callers operating with a
802
+ * bearer just work.
803
+ */
804
+ readonly auth: {
805
+ account: {
806
+ /** Initiate deletion. Mints a confirm token and dispatches the
807
+ * confirmation email. Returns when the request is accepted
808
+ * (HTTP 202). Idempotent within the token TTL. */
809
+ requestDelete: () => Promise<void>;
810
+ /** Consume a confirmation token. The server's GET response is an
811
+ * HTML page intended for the email recipient's browser; this
812
+ * helper exposes the same effect to programmatic callers (CLI
813
+ * / integration tests). Throws on bad / expired tokens. */
814
+ confirmDelete: (token: string) => Promise<void>;
815
+ /** Cancel an in-flight deletion (session-cookie or bearer path).
816
+ * Throws if the account is not in pending-deletion. */
817
+ cancel: () => Promise<void>;
818
+ };
819
+ };
730
820
  /**
731
821
  * The calling user's profile. `system.profile` is a virtual type —
732
822
  * served by a dedicated endpoint over the `users` table joined to
@@ -894,4 +984,4 @@ interface VerifyWebhookSignatureInput {
894
984
  */
895
985
  declare function verifyWebhookSignature(input: VerifyWebhookSignatureInput): WebhookVerifyResult;
896
986
 
897
- export { type BulkActionErrorEntry, type BulkActionFilter, type BulkActionInput, type BulkActionResult, type BulkEdgeInput, type BulkEdgeInputItem, type BulkEdgeResult, type BulkEdgeResultEntry, type BulkInput, type BulkItemInput, type BulkMode, type BulkOutcome, type BulkResult, type BulkResultEntry, type ClientConfig, type ConflictAutoMergeListener, type ConflictAutoMergedEvent, type ConflictData, ConflictError, type ConflictResolver, type ConflictStrategy, type CreateWithAttachmentsAttachment, type CreateWithAttachmentsInput, type CreateWithAttachmentsResult, ForbiddenError, type ItemWithExtensions, type ListFilters, type MetadataInput, MymeClient, MymeError, NotFoundError, type SearchFilters, UnauthorizedError, type UpdateOptions, ValidationError, type VerifyWebhookSignatureInput, type WebhookVerifyReason, type WebhookVerifyResult, defineType, verifyWebhookSignature };
987
+ export { type BulkActionErrorEntry, type BulkActionFilter, type BulkActionInput, type BulkActionResult, type BulkEdgeInput, type BulkEdgeInputItem, type BulkEdgeResult, type BulkEdgeResultEntry, type BulkInput, type BulkItemInput, type BulkMode, type BulkOutcome, type BulkResult, type BulkResultEntry, type ClientConfig, type ConflictAutoMergeListener, type ConflictAutoMergedEvent, type ConflictData, ConflictError, type ConflictResolver, type ConflictStrategy, type CreateWithAttachmentsAttachment, type CreateWithAttachmentsInput, type CreateWithAttachmentsResult, ForbiddenError, type ItemWithExtensions, type ListFilters, type MetadataInput, MymeClient, MymeError, NotFoundError, type SearchFilters, type TenantApiKeySummary, UnauthorizedError, type UpdateOptions, ValidationError, type VerifyWebhookSignatureInput, type WebhookVerifyReason, type WebhookVerifyResult, defineType, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -1129,6 +1129,125 @@ var MymeClient = class {
1129
1129
  }
1130
1130
  }
1131
1131
  };
1132
+ // ---- Admin (T-117) ----
1133
+ /**
1134
+ * Operator-level admin surface — the `my admin` CLI command tree's
1135
+ * backing endpoints. Every method requires a platform-admin key
1136
+ * (`is_platform: true`). Non-platform credentials get a `403
1137
+ * forbidden`; render `"this command requires a platform-admin key"`
1138
+ * in CLI / UI layers.
1139
+ *
1140
+ * Quota read/write is intentionally NOT duplicated here — it lives on
1141
+ * `client.tenants.quotas.{getById, set}` and is already platform-
1142
+ * admin-gated. The admin namespace mirrors what the CLI's `my admin`
1143
+ * tree exposes; quotas are reached via the existing tenants surface.
1144
+ */
1145
+ admin = {
1146
+ tenants: {
1147
+ /** List every tenant in the instance with current status. */
1148
+ list: async () => {
1149
+ const res = await this.transport.request(
1150
+ "GET",
1151
+ "/admin/tenants"
1152
+ );
1153
+ return res.data;
1154
+ },
1155
+ /**
1156
+ * Single tenant + per-tenant quota overrides + the most-recent
1157
+ * `system.activity` items for the tenant (`null` quotas when no
1158
+ * override is configured; quota fields then resolve to instance
1159
+ * defaults).
1160
+ */
1161
+ show: async (tenantId) => {
1162
+ return this.transport.request("GET", `/admin/tenants/${encodeURIComponent(tenantId)}`);
1163
+ },
1164
+ /**
1165
+ * Flip the tenant's status to `'suspended'`. Future non-GET
1166
+ * requests from credentials in the tenant return HTTP 403
1167
+ * `tenant_suspended`. Reads pass through; platform-admin keys
1168
+ * bypass. Idempotent.
1169
+ */
1170
+ suspend: async (tenantId) => {
1171
+ return this.transport.request(
1172
+ "POST",
1173
+ `/admin/tenants/${encodeURIComponent(tenantId)}/suspend`
1174
+ );
1175
+ },
1176
+ /** Reverse of `suspend`. Idempotent. */
1177
+ unsuspend: async (tenantId) => {
1178
+ return this.transport.request(
1179
+ "POST",
1180
+ `/admin/tenants/${encodeURIComponent(tenantId)}/unsuspend`
1181
+ );
1182
+ },
1183
+ /**
1184
+ * Per-tenant usage snapshot — item count by state, blob count
1185
+ * and total bytes, custom-type count, plus recent activity.
1186
+ */
1187
+ metrics: async (tenantId) => {
1188
+ return this.transport.request(
1189
+ "GET",
1190
+ `/admin/tenants/${encodeURIComponent(tenantId)}/metrics`
1191
+ );
1192
+ }
1193
+ },
1194
+ keys: {
1195
+ /** Active (non-revoked) keys for the named tenant. Operator
1196
+ * surface for emergency revocation — pair with `client.keys.revoke`. */
1197
+ list: async (tenantId) => {
1198
+ const res = await this.transport.request("GET", `/admin/tenants/${encodeURIComponent(tenantId)}/keys`);
1199
+ return res.data;
1200
+ }
1201
+ }
1202
+ };
1203
+ // ---- Auth (T-116) ----
1204
+ /**
1205
+ * Account-lifecycle surface (T-116).
1206
+ *
1207
+ * The data plane (every other namespace on the client) authenticates
1208
+ * with a bearer token; these account-management endpoints accept
1209
+ * EITHER a bearer (workspace_admin / admin in the user's tenant)
1210
+ * OR a better-auth session cookie. The CLI flow uses a bearer (the
1211
+ * user's own key); web flows use the cookie. The transport sends
1212
+ * the bearer header by default, so SDK callers operating with a
1213
+ * bearer just work.
1214
+ */
1215
+ auth = {
1216
+ account: {
1217
+ /** Initiate deletion. Mints a confirm token and dispatches the
1218
+ * confirmation email. Returns when the request is accepted
1219
+ * (HTTP 202). Idempotent within the token TTL. */
1220
+ requestDelete: async () => {
1221
+ await this.transport.request(
1222
+ "POST",
1223
+ "/auth/account/delete"
1224
+ );
1225
+ },
1226
+ /** Consume a confirmation token. The server's GET response is an
1227
+ * HTML page intended for the email recipient's browser; this
1228
+ * helper exposes the same effect to programmatic callers (CLI
1229
+ * / integration tests). Throws on bad / expired tokens. */
1230
+ confirmDelete: async (token) => {
1231
+ const res = await this.transport.rawRequest(
1232
+ "GET",
1233
+ `/auth/account/delete/confirm?token=${encodeURIComponent(token)}`
1234
+ );
1235
+ if (!res.ok) {
1236
+ throw new Error(
1237
+ `Account-delete confirm failed (${String(res.status)})`
1238
+ );
1239
+ }
1240
+ },
1241
+ /** Cancel an in-flight deletion (session-cookie or bearer path).
1242
+ * Throws if the account is not in pending-deletion. */
1243
+ cancel: async () => {
1244
+ await this.transport.request(
1245
+ "POST",
1246
+ "/auth/account/delete/cancel"
1247
+ );
1248
+ }
1249
+ }
1250
+ };
1132
1251
  // ---- Profile (T-074) ----
1133
1252
  /**
1134
1253
  * The calling user's profile. `system.profile` is a virtual type —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mymehq/sdk",
3
- "version": "5.2.0",
3
+ "version": "5.4.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.1.0"
23
+ "@mymehq/shared": "5.4.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^22.0.0",