@bunbase-ae/js 2.10.1-next.250.3e4ff22 → 2.10.1-next.253.19f24dd
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/package.json +1 -1
- package/src/admin.ts +89 -6
- package/src/index.ts +3 -0
package/package.json
CHANGED
package/src/admin.ts
CHANGED
|
@@ -301,14 +301,25 @@ export interface ServerSettings {
|
|
|
301
301
|
// storage tiers handled out-of-band (e.g. S3 versioning).
|
|
302
302
|
backup_include_storage?: boolean;
|
|
303
303
|
// Phase 2 (#350): when true, every backup also captures an AES-256-GCM
|
|
304
|
-
// encrypted bundle of secret env vars
|
|
305
|
-
//
|
|
306
|
-
//
|
|
304
|
+
// encrypted bundle of secret env vars. The passphrase used to encrypt the
|
|
305
|
+
// bundle is sourced from the `BACKUP_ENV_PASSPHRASE` environment variable
|
|
306
|
+
// on the BunBase host (see `backup_env_passphrase_source` below for the
|
|
307
|
+
// read-only set/unset indicator). Default false — opt-in. Passphrase loss
|
|
308
|
+
// is unrecoverable for the env restore path; DB+storage still restore
|
|
309
|
+
// without it.
|
|
307
310
|
backup_include_env?: boolean;
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
+
/**
|
|
312
|
+
* @deprecated Removed in #402. The env-bundle passphrase is sourced from
|
|
313
|
+
* the `BACKUP_ENV_PASSPHRASE` environment variable only — never from
|
|
314
|
+
* `_settings`, never via this API. Setting this field via the admin API
|
|
315
|
+
* is silently ignored. Use `backup_env_passphrase_source` to read whether
|
|
316
|
+
* the env var is set on the BunBase host.
|
|
317
|
+
*/
|
|
311
318
|
backup_env_passphrase?: string;
|
|
319
|
+
// Read-only indicator (#402). `"env_set"` means BACKUP_ENV_PASSPHRASE is
|
|
320
|
+
// present in the BunBase host's process environment; `"env_unset"` means
|
|
321
|
+
// it is missing — encrypted env-bundle capture will skip with a warn log.
|
|
322
|
+
backup_env_passphrase_source?: "env_set" | "env_unset";
|
|
312
323
|
server_timezone?: string;
|
|
313
324
|
server_locale?: string;
|
|
314
325
|
access_log_level?: "info" | "warn" | "error";
|
|
@@ -400,6 +411,24 @@ export interface StatsResponse {
|
|
|
400
411
|
time_series: MinuteBucket[];
|
|
401
412
|
}
|
|
402
413
|
|
|
414
|
+
export interface TenantSummary {
|
|
415
|
+
tenant_id: string;
|
|
416
|
+
member_count: number;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export interface TenantMember {
|
|
420
|
+
user_id: string;
|
|
421
|
+
role: string;
|
|
422
|
+
created_at: number;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export interface AdminTenantMembership {
|
|
426
|
+
tenant_id: string;
|
|
427
|
+
user_id: string;
|
|
428
|
+
role: string;
|
|
429
|
+
created_at: number;
|
|
430
|
+
}
|
|
431
|
+
|
|
403
432
|
// ─── Sub-clients ──────────────────────────────────────────────────────────────
|
|
404
433
|
|
|
405
434
|
class AdminUsersClient {
|
|
@@ -1129,6 +1158,58 @@ class AdminNamedQueriesClient {
|
|
|
1129
1158
|
}
|
|
1130
1159
|
}
|
|
1131
1160
|
|
|
1161
|
+
// Tenant membership management — surfaces the /api/v1/admin/tenants/* endpoints
|
|
1162
|
+
// added in v2.5.2 (#277/#323) so operators don't need to hand-roll fetch calls
|
|
1163
|
+
// to onboard a tenant member.
|
|
1164
|
+
class AdminTenantsClient {
|
|
1165
|
+
constructor(private readonly http: HttpClient) {}
|
|
1166
|
+
|
|
1167
|
+
async list(): Promise<TenantSummary[]> {
|
|
1168
|
+
const res = await this.http.request<{ items: TenantSummary[] }>("GET", "/api/v1/admin/tenants");
|
|
1169
|
+
return res.items;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
async listMembers(tenantId: string): Promise<TenantMember[]> {
|
|
1173
|
+
const res = await this.http.request<{ items: TenantMember[] }>(
|
|
1174
|
+
"GET",
|
|
1175
|
+
`/api/v1/admin/tenants/${encodeURIComponent(tenantId)}/members`,
|
|
1176
|
+
);
|
|
1177
|
+
return res.items;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
async addMember(
|
|
1181
|
+
tenantId: string,
|
|
1182
|
+
params: { userId: string; role?: string },
|
|
1183
|
+
): Promise<AdminTenantMembership> {
|
|
1184
|
+
const body: Record<string, unknown> = { user_id: params.userId };
|
|
1185
|
+
if (params.role !== undefined) body.role = params.role;
|
|
1186
|
+
return this.http.request<AdminTenantMembership>(
|
|
1187
|
+
"POST",
|
|
1188
|
+
`/api/v1/admin/tenants/${encodeURIComponent(tenantId)}/members`,
|
|
1189
|
+
{ body },
|
|
1190
|
+
);
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
async setMemberRole(
|
|
1194
|
+
tenantId: string,
|
|
1195
|
+
userId: string,
|
|
1196
|
+
role: string,
|
|
1197
|
+
): Promise<AdminTenantMembership> {
|
|
1198
|
+
return this.http.request<AdminTenantMembership>(
|
|
1199
|
+
"PATCH",
|
|
1200
|
+
`/api/v1/admin/tenants/${encodeURIComponent(tenantId)}/members/${encodeURIComponent(userId)}`,
|
|
1201
|
+
{ body: { role } },
|
|
1202
|
+
);
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
async removeMember(tenantId: string, userId: string): Promise<void> {
|
|
1206
|
+
await this.http.request<{ ok: boolean }>(
|
|
1207
|
+
"DELETE",
|
|
1208
|
+
`/api/v1/admin/tenants/${encodeURIComponent(tenantId)}/members/${encodeURIComponent(userId)}`,
|
|
1209
|
+
);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1132
1213
|
// ─── Main AdminClient ─────────────────────────────────────────────────────────
|
|
1133
1214
|
|
|
1134
1215
|
export class AdminClient {
|
|
@@ -1143,6 +1224,7 @@ export class AdminClient {
|
|
|
1143
1224
|
readonly queries: AdminNamedQueriesClient;
|
|
1144
1225
|
readonly logs: AdminLogsClient;
|
|
1145
1226
|
readonly system: AdminSystemClient;
|
|
1227
|
+
readonly tenants: AdminTenantsClient;
|
|
1146
1228
|
|
|
1147
1229
|
constructor(http: HttpClient) {
|
|
1148
1230
|
this.users = new AdminUsersClient(http);
|
|
@@ -1156,5 +1238,6 @@ export class AdminClient {
|
|
|
1156
1238
|
this.queries = new AdminNamedQueriesClient(http);
|
|
1157
1239
|
this.logs = new AdminLogsClient(http);
|
|
1158
1240
|
this.system = new AdminSystemClient(http);
|
|
1241
|
+
this.tenants = new AdminTenantsClient(http);
|
|
1159
1242
|
}
|
|
1160
1243
|
}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export {
|
|
|
7
7
|
type AdminRecord,
|
|
8
8
|
type AdminSession,
|
|
9
9
|
type AdminStoredFile,
|
|
10
|
+
type AdminTenantMembership,
|
|
10
11
|
type AdminUser,
|
|
11
12
|
type BackupDestinationConfig,
|
|
12
13
|
type BackupFile,
|
|
@@ -38,6 +39,8 @@ export {
|
|
|
38
39
|
type StatsResponse,
|
|
39
40
|
type StorageBucket,
|
|
40
41
|
type TemplateName,
|
|
42
|
+
type TenantMember,
|
|
43
|
+
type TenantSummary,
|
|
41
44
|
type UpdateNamedQueryInput,
|
|
42
45
|
type UpdateUserParams,
|
|
43
46
|
type WebhookLogRow,
|