@capybara-hq/kernel 0.1.0-rc.130 → 0.1.0-rc.132
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/admin/account-erasures.d.ts +37 -0
- package/dist/admin/account-erasures.js +119 -0
- package/dist/admin/admin.controller.d.ts +35 -2
- package/dist/admin/admin.controller.js +75 -18
- package/dist/admin/admin.module.js +10 -0
- package/dist/admin/admin.schemas.d.ts +51 -0
- package/dist/admin/admin.schemas.js +20 -0
- package/dist/admin/erasure-dispositions.d.ts +23 -0
- package/dist/admin/erasure-dispositions.js +76 -0
- package/dist/admin/health.service.d.ts +6 -0
- package/dist/admin/health.service.js +27 -1
- package/dist/admin/usage.service.d.ts +5 -0
- package/dist/admin/usage.service.js +21 -2
- package/dist/agents/agents.service.d.ts +1 -1
- package/dist/catalog/plugin-import.d.ts +3 -1
- package/dist/catalog/plugin-import.js +19 -15
- package/dist/channels/connections.service.d.ts +1 -1
- package/dist/client/client-reports.service.js +12 -0
- package/dist/config/schema.d.ts +9 -1
- package/dist/config/schema.js +51 -1
- package/dist/conversations/conversations.service.d.ts +9 -1
- package/dist/conversations/conversations.service.js +112 -15
- package/dist/conversations/event-log.d.ts +2 -0
- package/dist/conversations/event-log.js +77 -0
- package/dist/conversations/events.d.ts +11 -0
- package/dist/conversations/events.js +13 -1
- package/dist/conversations/prompt-suggestions.js +4 -0
- package/dist/conversations/titles.js +3 -2
- package/dist/ctx/create-ctx.d.ts +3 -2
- package/dist/ctx/create-ctx.js +10 -7
- package/dist/db/extension-db.d.ts +30 -0
- package/dist/db/extension-db.js +91 -0
- package/dist/db/extension-schema-transfer.d.ts +6 -0
- package/dist/db/extension-schema-transfer.js +141 -0
- package/dist/db/kernel-schema.d.ts +73 -12
- package/dist/db/migrator.d.ts +6 -0
- package/dist/db/migrator.js +39 -4
- package/dist/db/pool.d.ts +4 -0
- package/dist/db/pool.js +36 -1
- package/dist/devices/devices.service.d.ts +13 -1
- package/dist/devices/devices.service.js +122 -9
- package/dist/erasure/account-batches.d.ts +9 -0
- package/dist/erasure/account-batches.js +567 -0
- package/dist/erasure/account-files.d.ts +34 -0
- package/dist/erasure/account-files.js +217 -0
- package/dist/erasure/account-residual.d.ts +15 -0
- package/dist/erasure/account-residual.js +149 -0
- package/dist/erasure/account-worker.d.ts +32 -0
- package/dist/erasure/account-worker.js +392 -0
- package/dist/erasure/device-cleanup.d.ts +23 -0
- package/dist/erasure/device-cleanup.js +221 -0
- package/dist/erasure/erasure.module.d.ts +2 -0
- package/dist/{conversations/event-org-backfill.module.js → erasure/erasure.module.js} +6 -10
- package/dist/erasure/external-evidence.d.ts +4 -0
- package/dist/erasure/external-evidence.js +28 -0
- package/dist/erasure/jobs.d.ts +5 -0
- package/dist/erasure/jobs.js +20 -0
- package/dist/erasure/org-batches.d.ts +11 -0
- package/dist/erasure/org-batches.js +159 -0
- package/dist/erasure/org-catalog.d.ts +2 -0
- package/dist/erasure/org-catalog.js +34 -0
- package/dist/erasure/org-rules.d.ts +14 -0
- package/dist/erasure/org-rules.js +227 -0
- package/dist/erasure/org-worker.d.ts +38 -0
- package/dist/erasure/org-worker.js +501 -0
- package/dist/erasure/requests.d.ts +61 -0
- package/dist/erasure/requests.js +180 -0
- package/dist/erasure/sweep.job.d.ts +19 -0
- package/dist/erasure/sweep.job.js +130 -0
- package/dist/erasure/worker.d.ts +17 -0
- package/dist/erasure/worker.js +110 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +4 -0
- package/dist/evals/judge.d.ts +5 -0
- package/dist/evals/judge.js +16 -1
- package/dist/evals/run-replay.js +12 -1
- package/dist/evals/step-replay.d.ts +5 -3
- package/dist/evals/step-replay.js +9 -5
- package/dist/evals/worker.d.ts +2 -0
- package/dist/evals/worker.js +60 -16
- package/dist/extensions/admin-ops.d.ts +3 -1
- package/dist/extensions/admin-ops.js +11 -7
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/host.d.ts +4 -1
- package/dist/extensions/host.js +29 -6
- package/dist/extensions/instance.d.ts +3 -0
- package/dist/extensions/instance.js +3 -1
- package/dist/extensions/migrate-lock.d.ts +4 -1
- package/dist/extensions/migrate-lock.js +19 -2
- package/dist/files/blob-objects.d.ts +7 -3
- package/dist/files/blob-objects.js +39 -22
- package/dist/files/blob-sweep.job.d.ts +11 -0
- package/dist/files/blob-sweep.job.js +67 -6
- package/dist/http/api.module.js +5 -1
- package/dist/identity/accounts.js +3 -0
- package/dist/identity/api-tokens.js +5 -0
- package/dist/identity/auth.guard.d.ts +1 -0
- package/dist/identity/auth.guard.js +1 -0
- package/dist/identity/erasure-admission.d.ts +3 -0
- package/dist/identity/erasure-admission.js +14 -0
- package/dist/identity/external.js +5 -0
- package/dist/identity/sessions.js +5 -0
- package/dist/identity/settings.d.ts +86 -1
- package/dist/identity/settings.js +38 -4
- package/dist/infra/config/kernel-config.service.js +1 -0
- package/dist/infra/metrics/kernel-metrics.d.ts +18 -0
- package/dist/infra/metrics/kernel-metrics.js +54 -0
- package/dist/infra/metrics/operational-metrics.d.ts +31 -0
- package/dist/infra/metrics/operational-metrics.js +188 -0
- package/dist/infra/outbox/registry.d.ts +23 -14
- package/dist/infra/outbox/registry.js +12 -15
- package/dist/infra/throttler/credential-throttler.js +8 -1
- package/dist/infra/throttler/named-throttlers.d.ts +6 -0
- package/dist/infra/throttler/named-throttlers.js +6 -0
- package/dist/infra/throttler/principal-throttler.guard.d.ts +10 -0
- package/dist/infra/throttler/principal-throttler.guard.js +50 -0
- package/dist/infra/throttler/redis-throttler-storage.d.ts +1 -0
- package/dist/infra/throttler/redis-throttler-storage.js +27 -5
- package/dist/infra/throttler/throttler.guard.d.ts +2 -3
- package/dist/infra/throttler/throttler.guard.js +2 -3
- package/dist/infra/throttler/throttler.module.js +3 -2
- package/dist/kernel.js +4 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +26 -21
- package/dist/models/budget-admission.d.ts +31 -0
- package/dist/models/budget-admission.js +149 -0
- package/dist/models/budget-counters.d.ts +28 -0
- package/dist/models/budget-counters.js +117 -0
- package/dist/models/budget-policy.d.ts +88 -0
- package/dist/models/budget-policy.js +78 -0
- package/dist/models/embeddings.js +13 -2
- package/dist/models/images.js +12 -2
- package/dist/models/purposes.d.ts +5 -2
- package/dist/models/purposes.js +9 -5
- package/dist/orgs/invitations.service.d.ts +1 -1
- package/dist/orgs/members.service.d.ts +28 -1
- package/dist/orgs/members.service.js +74 -11
- package/dist/orgs/offboarding.js +4 -6
- package/dist/orgs/org-owner.d.ts +2 -0
- package/dist/orgs/org-owner.js +21 -6
- package/dist/orgs/orgs.controller.d.ts +22 -0
- package/dist/orgs/orgs.controller.js +24 -0
- package/dist/orgs/orgs.module.js +4 -0
- package/dist/orgs/orgs.schemas.js +7 -0
- package/dist/orgs/orgs.service.d.ts +5 -1
- package/dist/orgs/orgs.service.js +28 -3
- package/dist/orgs/settings.controller.js +6 -1
- package/dist/orgs/settings.service.d.ts +58 -1
- package/dist/orgs/settings.service.js +74 -9
- package/dist/platform/exclusions.js +20 -1
- package/dist/platform/ops/accounts.ops.js +58 -1
- package/dist/platform/ops/admin.ops.js +13 -5
- package/dist/platform/ops/org-settings.ops.js +11 -4
- package/dist/platform/ops/orgs.ops.js +28 -0
- package/dist/platform/ops/retention.d.ts +16 -0
- package/dist/platform/ops/retention.js +21 -0
- package/dist/retention/jobs.d.ts +21 -0
- package/dist/retention/jobs.js +48 -0
- package/dist/retention/policy.d.ts +70 -0
- package/dist/retention/policy.js +103 -0
- package/dist/retention/purge-batch.d.ts +17 -0
- package/dist/retention/purge-batch.js +355 -0
- package/dist/retention/report-obligations.d.ts +12 -0
- package/dist/retention/report-obligations.js +71 -0
- package/dist/retention/sweep.job.d.ts +17 -0
- package/dist/retention/sweep.job.js +95 -0
- package/dist/retention/worker.d.ts +29 -0
- package/dist/retention/worker.js +306 -0
- package/dist/roles/worker.module.js +12 -8
- package/dist/runtime/maintenance.d.ts +5 -3
- package/dist/runtime/maintenance.js +19 -12
- package/dist/runtime/model-call.d.ts +3 -1
- package/dist/runtime/model-call.js +25 -3
- package/dist/runtime/providers.d.ts +7 -2
- package/dist/runtime/providers.js +76 -10
- package/dist/runtime/quota.d.ts +12 -12
- package/dist/runtime/quota.js +42 -37
- package/dist/runtime/run-finish.js +2 -0
- package/dist/runtime/run-principal.d.ts +9 -0
- package/dist/runtime/run-principal.js +18 -0
- package/dist/runtime/run-worker.js +48 -10
- package/dist/runtime/usage-report-jobs.d.ts +4 -1
- package/dist/runtime/usage-report-jobs.js +36 -13
- package/dist/runtime/usage-report.d.ts +5 -3
- package/dist/runtime/usage-report.js +37 -19
- package/dist/sandbox/review/classifier.d.ts +2 -2
- package/dist/sandbox/review/classifier.js +6 -2
- package/dist/sandbox/sandbox.service.js +18 -7
- package/dist/storage/purge.js +5 -1
- package/dist/storage/storage.service.d.ts +17 -1
- package/dist/storage/storage.service.js +75 -4
- package/dist/tools/builtins/vision/read-image.js +3 -0
- package/dist/tools/builtins/web/extract.js +3 -0
- package/dist/tools/pipeline.js +5 -1
- package/package.json +3 -1
- package/src/migrations/0216_model_budget_counters.sql +24 -0
- package/src/migrations/0217_retention.sql +44 -0
- package/src/migrations/0218_data_erasure.sql +41 -0
- package/src/migrations/0219_event_org_constraint_check.sql +29 -0
- package/src/migrations/0220_require_event_org.sql +18 -0
- package/src/migrations/0221_drop_connector_declaration_policy.sql +2 -0
- package/dist/conversations/event-org-backfill.d.ts +0 -111
- package/dist/conversations/event-org-backfill.js +0 -264
- package/dist/conversations/event-org-backfill.module.d.ts +0 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ErasureRequests } from "../erasure/requests.js";
|
|
2
|
+
import { AccountsService } from "../identity/accounts.js";
|
|
3
|
+
import { SessionService } from "../identity/sessions.js";
|
|
4
|
+
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
5
|
+
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
6
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
7
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
8
|
+
import { StorageService } from "../storage/storage.service.js";
|
|
9
|
+
export declare class AccountErasures {
|
|
10
|
+
private readonly db;
|
|
11
|
+
readonly txHost: TransactionHost;
|
|
12
|
+
private readonly accounts;
|
|
13
|
+
private readonly sessions;
|
|
14
|
+
private readonly requests;
|
|
15
|
+
private readonly admins;
|
|
16
|
+
private readonly config;
|
|
17
|
+
private readonly storage;
|
|
18
|
+
constructor(db: KernelDb, txHost: TransactionHost, accounts: AccountsService, sessions: SessionService, requests: ErasureRequests, admins: SuperAdminLock, config: KernelConfigService, storage: StorageService);
|
|
19
|
+
status(workId: string): Promise<{
|
|
20
|
+
blockedReason: string | null;
|
|
21
|
+
completedAt: Date | null;
|
|
22
|
+
dueAt: Date;
|
|
23
|
+
id: string;
|
|
24
|
+
kind: "account" | "org";
|
|
25
|
+
scopeBoundaries: "third-party-conversation-content"[];
|
|
26
|
+
stage: "account-external" | "account-final" | "account-orgs" | "blocked" | "done" | "late" | "objects" | "pending" | "prefix" | "roots" | "rows";
|
|
27
|
+
}>;
|
|
28
|
+
accept(accountId: string, actor: string): Promise<{
|
|
29
|
+
blockedReason: string | null;
|
|
30
|
+
completedAt: Date | null;
|
|
31
|
+
dueAt: Date;
|
|
32
|
+
id: string;
|
|
33
|
+
kind: "account" | "org";
|
|
34
|
+
scopeBoundaries: "third-party-conversation-content"[];
|
|
35
|
+
stage: "account-external" | "account-final" | "account-orgs" | "blocked" | "done" | "late" | "objects" | "pending" | "prefix" | "roots" | "rows";
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
11
|
+
import { ErasureRequests } from "../erasure/requests.js";
|
|
12
|
+
import { ApiError } from "../errors.js";
|
|
13
|
+
import { AccountsService } from "../identity/accounts.js";
|
|
14
|
+
import { SessionService } from "../identity/sessions.js";
|
|
15
|
+
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
16
|
+
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
17
|
+
import { afterCommit } from "../infra/database/after-commit.js";
|
|
18
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
19
|
+
import { asPlatform } from "../infra/database/org-scope.js";
|
|
20
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
21
|
+
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
22
|
+
import { StorageService } from "../storage/storage.service.js";
|
|
23
|
+
let AccountErasures = class AccountErasures {
|
|
24
|
+
db;
|
|
25
|
+
txHost;
|
|
26
|
+
accounts;
|
|
27
|
+
sessions;
|
|
28
|
+
requests;
|
|
29
|
+
admins;
|
|
30
|
+
config;
|
|
31
|
+
storage;
|
|
32
|
+
constructor(db, txHost, accounts, sessions, requests, admins, config, storage) {
|
|
33
|
+
this.db = db;
|
|
34
|
+
this.txHost = txHost;
|
|
35
|
+
this.accounts = accounts;
|
|
36
|
+
this.sessions = sessions;
|
|
37
|
+
this.requests = requests;
|
|
38
|
+
this.admins = admins;
|
|
39
|
+
this.config = config;
|
|
40
|
+
this.storage = storage;
|
|
41
|
+
}
|
|
42
|
+
async status(workId) {
|
|
43
|
+
const row = await this.requests.status(workId);
|
|
44
|
+
if (row?.kind !== "account")
|
|
45
|
+
throw new ApiError("not_found", "Erasure request not found");
|
|
46
|
+
return row;
|
|
47
|
+
}
|
|
48
|
+
async accept(accountId, actor) {
|
|
49
|
+
const retention = this.config.get().retention;
|
|
50
|
+
if (!retention.erasureEnabled || !retention.destructiveEnabled) {
|
|
51
|
+
throw new ApiError("conflict", "Account erasure is not enabled on this deployment");
|
|
52
|
+
}
|
|
53
|
+
// org-filter: deployment-wide a super admin checks ownership in every surviving org.
|
|
54
|
+
return asPlatform("Accept an account erasure and protect its surviving organizations", async () => {
|
|
55
|
+
// Owner changes lock the org row. Acquire every known one before the super-admin lock.
|
|
56
|
+
const owned = () => this.db
|
|
57
|
+
.selectFrom("orgs")
|
|
58
|
+
.innerJoin("memberships as m", "m.org_id", "orgs.id")
|
|
59
|
+
.where("m.account_id", "=", accountId)
|
|
60
|
+
.where("m.role", "=", "owner")
|
|
61
|
+
.where("orgs.deleted_at", "is", null);
|
|
62
|
+
const locked = await owned()
|
|
63
|
+
.select("orgs.id")
|
|
64
|
+
.orderBy("orgs.id")
|
|
65
|
+
.forNoKeyUpdate("orgs")
|
|
66
|
+
.execute();
|
|
67
|
+
await this.admins.lockAndAuthorize(actor);
|
|
68
|
+
const existing = await this.requests.active("account", accountId);
|
|
69
|
+
if (existing)
|
|
70
|
+
return existing;
|
|
71
|
+
// Disabling takes the permission authority lock, revokes credentials, and holds the target
|
|
72
|
+
// account row. A concurrent grant to the account must finish before this write or wait for it.
|
|
73
|
+
const { revokedSessionIds } = await this.accounts.updateAccount(accountId, { status: "disabled" }, actor, undefined, {
|
|
74
|
+
auditDetail: { erasureRequested: true },
|
|
75
|
+
});
|
|
76
|
+
afterCommit(() => this.sessions.markRevoked(revokedSessionIds));
|
|
77
|
+
const current = await owned().select("orgs.id").execute();
|
|
78
|
+
const known = new Set(locked.map((row) => row.id));
|
|
79
|
+
if (current.some((row) => !known.has(row.id))) {
|
|
80
|
+
throw new ApiError("conflict", "Organization ownership changed; retry the erasure request");
|
|
81
|
+
}
|
|
82
|
+
const lastOwner = await owned()
|
|
83
|
+
.where(({ not, exists, selectFrom }) => not(exists(selectFrom("memberships as other")
|
|
84
|
+
.innerJoin("accounts as a", "a.id", "other.account_id")
|
|
85
|
+
.select("a.id")
|
|
86
|
+
.whereRef("other.org_id", "=", "orgs.id")
|
|
87
|
+
.where("other.role", "=", "owner")
|
|
88
|
+
.where("a.status", "=", "active")
|
|
89
|
+
.where("a.id", "!=", accountId))))
|
|
90
|
+
.select("orgs.id")
|
|
91
|
+
.executeTakeFirst();
|
|
92
|
+
if (lastOwner)
|
|
93
|
+
throw new ApiError("org.last_owner", "Transfer ownership to another active owner before erasing this account");
|
|
94
|
+
await this.db
|
|
95
|
+
.updateTable("accounts")
|
|
96
|
+
.set({ erasure_requested: true })
|
|
97
|
+
.where("id", "=", accountId)
|
|
98
|
+
.execute();
|
|
99
|
+
return this.requests.enqueue("account", accountId, {
|
|
100
|
+
storageIdentity: this.storage.erasureIdentity(),
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
__decorate([
|
|
106
|
+
Transactional()
|
|
107
|
+
], AccountErasures.prototype, "accept", null);
|
|
108
|
+
AccountErasures = __decorate([
|
|
109
|
+
Injectable(),
|
|
110
|
+
__param(0, Inject(KernelDb)),
|
|
111
|
+
__param(1, Inject(TransactionHost)),
|
|
112
|
+
__param(2, Inject(AccountsService)),
|
|
113
|
+
__param(3, Inject(SessionService)),
|
|
114
|
+
__param(4, Inject(ErasureRequests)),
|
|
115
|
+
__param(5, Inject(SuperAdminLock)),
|
|
116
|
+
__param(6, Inject(KernelConfigService)),
|
|
117
|
+
__param(7, Inject(StorageService))
|
|
118
|
+
], AccountErasures);
|
|
119
|
+
export { AccountErasures };
|
|
@@ -16,13 +16,17 @@ import { ModelPurposesService, type PurposeListing, type PurposePut } from "../m
|
|
|
16
16
|
import { type Member, MembersService } from "../orgs/members.service.js";
|
|
17
17
|
import { type Org, OrgsService } from "../orgs/orgs.service.js";
|
|
18
18
|
import { type PlatformProviderState, ProviderRegistry, type ProviderStatus } from "../runtime/providers.js";
|
|
19
|
-
import {
|
|
19
|
+
import { AccountErasures } from "./account-erasures.js";
|
|
20
|
+
import { AccountErasureBody, AccountListQuery, AccountParams, AdminOrgParams, CreateAccountBody, DeploymentSettingsBody, ErasureDispositionBody, ErasureWorkParams, PurposeParams, UpdateAccountBody } from "./admin.schemas.js";
|
|
21
|
+
import { ErasureDispositions } from "./erasure-dispositions.js";
|
|
20
22
|
import { type LimitDefaults } from "./limit-defaults.js";
|
|
21
23
|
/**
|
|
22
24
|
* 超级管理员端点(`/api/v1/admin/*`):只接受超级管理员的 Web 会话或个人令牌;
|
|
23
25
|
* 服务令牌一律 `forbidden`(未标 `@AllowService`)。
|
|
24
26
|
*/
|
|
25
27
|
export declare class AdminController {
|
|
28
|
+
private readonly erasures;
|
|
29
|
+
private readonly erasureDispositions;
|
|
26
30
|
private readonly accounts;
|
|
27
31
|
private readonly sessions;
|
|
28
32
|
private readonly log;
|
|
@@ -37,7 +41,7 @@ export declare class AdminController {
|
|
|
37
41
|
private readonly icons;
|
|
38
42
|
private readonly members;
|
|
39
43
|
private readonly db;
|
|
40
|
-
constructor(accounts: AccountsService, sessions: SessionService, log: Logger, orgs: OrgsService, settings: SettingsService, prices: PricesService, purposes: ModelPurposesService, registry: ProviderRegistry, displayNames: ExtensionDisplayNames, enablement: ModelEnablement, config: KernelConfigService, icons: PluginIcons, members: MembersService, db: KernelDb);
|
|
44
|
+
constructor(erasures: AccountErasures, erasureDispositions: ErasureDispositions, accounts: AccountsService, sessions: SessionService, log: Logger, orgs: OrgsService, settings: SettingsService, prices: PricesService, purposes: ModelPurposesService, registry: ProviderRegistry, displayNames: ExtensionDisplayNames, enablement: ModelEnablement, config: KernelConfigService, icons: PluginIcons, members: MembersService, db: KernelDb);
|
|
41
45
|
/** One account with its avatar URL and source. */
|
|
42
46
|
private view;
|
|
43
47
|
/**
|
|
@@ -47,7 +51,36 @@ export declare class AdminController {
|
|
|
47
51
|
listAccounts(q: z.infer<typeof AccountListQuery>): Promise<{
|
|
48
52
|
accounts: AccountView[];
|
|
49
53
|
next: string | null;
|
|
54
|
+
erasureEnabled: boolean;
|
|
50
55
|
}>;
|
|
56
|
+
requestAccountErasure(principal: Principal, { accountId }: z.infer<typeof AccountParams>, _body: z.infer<typeof AccountErasureBody>): Promise<{
|
|
57
|
+
blockedReason: string | null;
|
|
58
|
+
completedAt: Date | null;
|
|
59
|
+
dueAt: Date;
|
|
60
|
+
id: string;
|
|
61
|
+
kind: "account" | "org";
|
|
62
|
+
scopeBoundaries: "third-party-conversation-content"[];
|
|
63
|
+
stage: "account-external" | "account-final" | "account-orgs" | "blocked" | "done" | "late" | "objects" | "pending" | "prefix" | "roots" | "rows";
|
|
64
|
+
}>;
|
|
65
|
+
accountErasureStatus({ workId }: z.infer<typeof ErasureWorkParams>): Promise<{
|
|
66
|
+
blockedReason: string | null;
|
|
67
|
+
completedAt: Date | null;
|
|
68
|
+
dueAt: Date;
|
|
69
|
+
id: string;
|
|
70
|
+
kind: "account" | "org";
|
|
71
|
+
scopeBoundaries: "third-party-conversation-content"[];
|
|
72
|
+
stage: "account-external" | "account-final" | "account-orgs" | "blocked" | "done" | "late" | "objects" | "pending" | "prefix" | "roots" | "rows";
|
|
73
|
+
}>;
|
|
74
|
+
erasureStatus({ workId }: z.infer<typeof ErasureWorkParams>): Promise<{
|
|
75
|
+
blockedReason: string | null;
|
|
76
|
+
completedAt: Date | null;
|
|
77
|
+
dueAt: Date;
|
|
78
|
+
id: string;
|
|
79
|
+
kind: "account" | "org";
|
|
80
|
+
scopeBoundaries: "third-party-conversation-content"[];
|
|
81
|
+
stage: "account-external" | "account-final" | "account-orgs" | "blocked" | "done" | "late" | "objects" | "pending" | "prefix" | "roots" | "rows";
|
|
82
|
+
}>;
|
|
83
|
+
recordErasureDisposition(principal: Principal, { workId }: z.infer<typeof ErasureWorkParams>, body: z.infer<typeof ErasureDispositionBody>): Promise<void>;
|
|
51
84
|
createAccount(principal: Principal, body: z.infer<typeof CreateAccountBody>): Promise<{
|
|
52
85
|
account: AccountView;
|
|
53
86
|
}>;
|
|
@@ -13,7 +13,7 @@ import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
|
13
13
|
import { PluginIcons } from "../extensions/plugin-icons.js";
|
|
14
14
|
import { withAvatarUrl, withAvatarUrls } from "../identity/account-avatar.js";
|
|
15
15
|
import { AccountsService } from "../identity/accounts.js";
|
|
16
|
-
import { CurrentPrincipal, patTokenId, requireUser, SuperAdmin, } from "../identity/principal.js";
|
|
16
|
+
import { CurrentPrincipal, patTokenId, requireUser, SessionOnly, SuperAdmin, } from "../identity/principal.js";
|
|
17
17
|
import { SessionService } from "../identity/sessions.js";
|
|
18
18
|
import { SettingsService } from "../identity/settings.js";
|
|
19
19
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
@@ -29,8 +29,16 @@ import { ModelPurposesService, PurposePutDto, withDeclaredByNames, } from "../mo
|
|
|
29
29
|
import { MembersService } from "../orgs/members.service.js";
|
|
30
30
|
import { OrgsService } from "../orgs/orgs.service.js";
|
|
31
31
|
import { ProviderRegistry, } from "../runtime/providers.js";
|
|
32
|
-
import {
|
|
32
|
+
import { AccountErasures } from "./account-erasures.js";
|
|
33
|
+
import { AccountErasureBody, AccountListQuery, AccountParams, AdminOrgParams, CreateAccountBody, DeploymentSettingsBody, ErasureDispositionBody, ErasureWorkParams, PurposeParams, UpdateAccountBody, } from "./admin.schemas.js";
|
|
34
|
+
import { ErasureDispositions } from "./erasure-dispositions.js";
|
|
33
35
|
import { limitDefaults } from "./limit-defaults.js";
|
|
36
|
+
class AccountErasureBodyDto extends createZodDto(AccountErasureBody, "AccountErasureBody") {
|
|
37
|
+
}
|
|
38
|
+
class ErasureDispositionBodyDto extends createZodDto(ErasureDispositionBody, "ErasureDispositionBody") {
|
|
39
|
+
}
|
|
40
|
+
class ErasureWorkParamsDto extends createZodDto(ErasureWorkParams, "ErasureWorkParams") {
|
|
41
|
+
}
|
|
34
42
|
class AccountListQueryDto extends createZodDto(AccountListQuery, "AccountListQuery") {
|
|
35
43
|
}
|
|
36
44
|
class CreateAccountBodyDto extends createZodDto(CreateAccountBody, "CreateAccountBody") {
|
|
@@ -52,6 +60,8 @@ const ModelPriceBody = createZodDto(MODEL_PRICE_PUT, "ModelPricePut");
|
|
|
52
60
|
* 服务令牌一律 `forbidden`(未标 `@AllowService`)。
|
|
53
61
|
*/
|
|
54
62
|
let AdminController = class AdminController {
|
|
63
|
+
erasures;
|
|
64
|
+
erasureDispositions;
|
|
55
65
|
accounts;
|
|
56
66
|
sessions;
|
|
57
67
|
log;
|
|
@@ -66,7 +76,9 @@ let AdminController = class AdminController {
|
|
|
66
76
|
icons;
|
|
67
77
|
members;
|
|
68
78
|
db;
|
|
69
|
-
constructor(accounts, sessions, log, orgs, settings, prices, purposes, registry, displayNames, enablement, config, icons, members, db) {
|
|
79
|
+
constructor(erasures, erasureDispositions, accounts, sessions, log, orgs, settings, prices, purposes, registry, displayNames, enablement, config, icons, members, db) {
|
|
80
|
+
this.erasures = erasures;
|
|
81
|
+
this.erasureDispositions = erasureDispositions;
|
|
70
82
|
this.accounts = accounts;
|
|
71
83
|
this.sessions = sessions;
|
|
72
84
|
this.log = log;
|
|
@@ -97,7 +109,24 @@ let AdminController = class AdminController {
|
|
|
97
109
|
});
|
|
98
110
|
const page = rows.slice(0, q.limit);
|
|
99
111
|
const next = rows.length > q.limit ? (page.at(-1)?.id ?? null) : null;
|
|
100
|
-
|
|
112
|
+
const retention = this.config.get().retention;
|
|
113
|
+
return {
|
|
114
|
+
accounts: await withAvatarUrls(this.db.db, page),
|
|
115
|
+
next,
|
|
116
|
+
erasureEnabled: retention.erasureEnabled && retention.destructiveEnabled,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
async requestAccountErasure(principal, { accountId }, _body) {
|
|
120
|
+
return this.erasures.accept(accountId, requireUser(principal).account.id);
|
|
121
|
+
}
|
|
122
|
+
async accountErasureStatus({ workId }) {
|
|
123
|
+
return this.erasures.status(workId);
|
|
124
|
+
}
|
|
125
|
+
async erasureStatus({ workId }) {
|
|
126
|
+
return this.erasureDispositions.status(workId);
|
|
127
|
+
}
|
|
128
|
+
async recordErasureDisposition(principal, { workId }, body) {
|
|
129
|
+
await this.erasureDispositions.record(workId, requireUser(principal).account.id, body);
|
|
101
130
|
}
|
|
102
131
|
async createAccount(principal, body) {
|
|
103
132
|
const actor = requireUser(principal);
|
|
@@ -225,6 +254,32 @@ __decorate([
|
|
|
225
254
|
Get("accounts"),
|
|
226
255
|
__param(0, ZQuery(AccountListQueryDto))
|
|
227
256
|
], AdminController.prototype, "listAccounts", null);
|
|
257
|
+
__decorate([
|
|
258
|
+
Post("accounts/:accountId/erasure"),
|
|
259
|
+
SessionOnly(),
|
|
260
|
+
HttpCode(202),
|
|
261
|
+
__param(0, CurrentPrincipal()),
|
|
262
|
+
__param(1, ZParam(AccountParamsDto)),
|
|
263
|
+
__param(2, ZBody(AccountErasureBodyDto))
|
|
264
|
+
], AdminController.prototype, "requestAccountErasure", null);
|
|
265
|
+
__decorate([
|
|
266
|
+
Get("account-erasures/:workId"),
|
|
267
|
+
SessionOnly(),
|
|
268
|
+
__param(0, ZParam(ErasureWorkParamsDto))
|
|
269
|
+
], AdminController.prototype, "accountErasureStatus", null);
|
|
270
|
+
__decorate([
|
|
271
|
+
Get("erasure-requests/:workId"),
|
|
272
|
+
SessionOnly(),
|
|
273
|
+
__param(0, ZParam(ErasureWorkParamsDto))
|
|
274
|
+
], AdminController.prototype, "erasureStatus", null);
|
|
275
|
+
__decorate([
|
|
276
|
+
Post("erasure-requests/:workId/external-disposition"),
|
|
277
|
+
SessionOnly(),
|
|
278
|
+
HttpCode(204),
|
|
279
|
+
__param(0, CurrentPrincipal()),
|
|
280
|
+
__param(1, ZParam(ErasureWorkParamsDto)),
|
|
281
|
+
__param(2, ZBody(ErasureDispositionBodyDto))
|
|
282
|
+
], AdminController.prototype, "recordErasureDisposition", null);
|
|
228
283
|
__decorate([
|
|
229
284
|
Post("accounts"),
|
|
230
285
|
HttpCode(201),
|
|
@@ -281,19 +336,21 @@ __decorate([
|
|
|
281
336
|
AdminController = __decorate([
|
|
282
337
|
Controller("api/v1/admin"),
|
|
283
338
|
SuperAdmin(),
|
|
284
|
-
__param(0, Inject(
|
|
285
|
-
__param(1, Inject(
|
|
286
|
-
__param(2, Inject(
|
|
287
|
-
__param(3, Inject(
|
|
288
|
-
__param(4, Inject(
|
|
289
|
-
__param(5, Inject(
|
|
290
|
-
__param(6, Inject(
|
|
291
|
-
__param(7, Inject(
|
|
292
|
-
__param(8, Inject(
|
|
293
|
-
__param(9, Inject(
|
|
294
|
-
__param(10, Inject(
|
|
295
|
-
__param(11, Inject(
|
|
296
|
-
__param(12, Inject(
|
|
297
|
-
__param(13, Inject(
|
|
339
|
+
__param(0, Inject(AccountErasures)),
|
|
340
|
+
__param(1, Inject(ErasureDispositions)),
|
|
341
|
+
__param(2, Inject(AccountsService)),
|
|
342
|
+
__param(3, Inject(SessionService)),
|
|
343
|
+
__param(4, Inject(KERNEL_LOGGER)),
|
|
344
|
+
__param(5, Inject(OrgsService)),
|
|
345
|
+
__param(6, Inject(SettingsService)),
|
|
346
|
+
__param(7, Inject(PricesService)),
|
|
347
|
+
__param(8, Inject(ModelPurposesService)),
|
|
348
|
+
__param(9, Inject(ProviderRegistry)),
|
|
349
|
+
__param(10, Inject(ExtensionDisplayNames)),
|
|
350
|
+
__param(11, Inject(ModelEnablement)),
|
|
351
|
+
__param(12, Inject(KernelConfigService)),
|
|
352
|
+
__param(13, Inject(PluginIcons)),
|
|
353
|
+
__param(14, Inject(MembersService)),
|
|
354
|
+
__param(15, Inject(KernelDb))
|
|
298
355
|
], AdminController);
|
|
299
356
|
export { AdminController };
|
|
@@ -10,6 +10,7 @@ import { TemplateConnectorsQueueModule } from "../catalog/template-connector-job
|
|
|
10
10
|
import { ChannelsModule } from "../channels/channels.module.js";
|
|
11
11
|
import { PromptSuggestionsModule } from "../conversations/prompt-suggestions.js";
|
|
12
12
|
import { TitlesModule } from "../conversations/titles.js";
|
|
13
|
+
import { ErasureModule } from "../erasure/erasure.module.js";
|
|
13
14
|
import { EvalsModule } from "../evals/evals.module.js";
|
|
14
15
|
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
15
16
|
import { LifecycleHooksModule } from "../extensions/lifecycle-hooks.js";
|
|
@@ -22,9 +23,12 @@ import { ProvidersModule } from "../runtime/providers.js";
|
|
|
22
23
|
import { RunJobsModule } from "../runtime/run-jobs.js";
|
|
23
24
|
import { UsageReportModule } from "../runtime/usage-report.js";
|
|
24
25
|
import { SandboxProviderRegistryModule } from "../sandbox/providers.module.js";
|
|
26
|
+
import { StorageModule } from "../storage/storage.module.js";
|
|
25
27
|
import { ConnectorToolsQueueModule } from "../tools/connector-tools-jobs.js";
|
|
26
28
|
import { ToolWatchQueueModule } from "../tools/tool-watch-queue.module.js";
|
|
29
|
+
import { AccountErasures } from "./account-erasures.js";
|
|
27
30
|
import { AuditLogService } from "./audit-log.service.js";
|
|
31
|
+
import { ErasureDispositions } from "./erasure-dispositions.js";
|
|
28
32
|
import { AdminHealthService } from "./health.service.js";
|
|
29
33
|
import { OrgNetworkAdmin } from "./org-network.service.js";
|
|
30
34
|
import { OutboxDeadService } from "./outbox-dead.service.js";
|
|
@@ -43,6 +47,8 @@ let AdminModule = class AdminModule {
|
|
|
43
47
|
AdminModule = __decorate([
|
|
44
48
|
Module({
|
|
45
49
|
imports: [
|
|
50
|
+
ErasureModule,
|
|
51
|
+
StorageModule,
|
|
46
52
|
SandboxProviderRegistryModule,
|
|
47
53
|
IdentityModule,
|
|
48
54
|
OrgsModule,
|
|
@@ -70,6 +76,8 @@ AdminModule = __decorate([
|
|
|
70
76
|
ModelsModule,
|
|
71
77
|
],
|
|
72
78
|
providers: [
|
|
79
|
+
AccountErasures,
|
|
80
|
+
ErasureDispositions,
|
|
73
81
|
SetupService,
|
|
74
82
|
AuditLogService,
|
|
75
83
|
AdminOverviewService,
|
|
@@ -79,6 +87,8 @@ AdminModule = __decorate([
|
|
|
79
87
|
OrgNetworkAdmin,
|
|
80
88
|
],
|
|
81
89
|
exports: [
|
|
90
|
+
AccountErasures,
|
|
91
|
+
ErasureDispositions,
|
|
82
92
|
SetupService,
|
|
83
93
|
AuditLogService,
|
|
84
94
|
AdminOverviewService,
|
|
@@ -15,6 +15,20 @@ export declare const CreateAccountBody: z.ZodObject<{
|
|
|
15
15
|
export declare const AccountParams: z.ZodObject<{
|
|
16
16
|
accountId: z.ZodString;
|
|
17
17
|
}, z.core.$strip>;
|
|
18
|
+
export declare const AccountErasureBody: z.ZodObject<{
|
|
19
|
+
confirm: z.ZodLiteral<true>;
|
|
20
|
+
}, z.core.$strict>;
|
|
21
|
+
export declare const ErasureWorkParams: z.ZodObject<{
|
|
22
|
+
workId: z.ZodUUID;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare const ErasureDispositionBody: z.ZodObject<{
|
|
25
|
+
blocker: z.ZodEnum<{
|
|
26
|
+
"catalog-or-tool-ownership-unverified": "catalog-or-tool-ownership-unverified";
|
|
27
|
+
"external-cleanup-unverified": "external-cleanup-unverified";
|
|
28
|
+
}>;
|
|
29
|
+
reason: z.ZodString;
|
|
30
|
+
evidence: z.ZodString;
|
|
31
|
+
}, z.core.$strict>;
|
|
18
32
|
export declare const UpdateAccountBody: z.ZodObject<{
|
|
19
33
|
displayName: z.ZodOptional<z.ZodString>;
|
|
20
34
|
status: z.ZodOptional<z.ZodEnum<{
|
|
@@ -30,6 +44,43 @@ export declare const DeploymentSettingsBody: z.ZodObject<{
|
|
|
30
44
|
super_admin: "super_admin";
|
|
31
45
|
}>>;
|
|
32
46
|
runConcurrencyOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodNumber>>>;
|
|
47
|
+
retention: z.ZodOptional<z.ZodObject<{
|
|
48
|
+
conversationDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
49
|
+
auditDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
50
|
+
usageDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
51
|
+
platformAuditDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
52
|
+
}, z.core.$strict>>;
|
|
53
|
+
confirmRetentionShortening: z.ZodOptional<z.ZodLiteral<true>>;
|
|
54
|
+
modelBudgets: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
55
|
+
orgDefault: z.ZodOptional<z.ZodObject<{
|
|
56
|
+
tokens: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
spend: z.ZodOptional<z.ZodObject<{
|
|
58
|
+
amount: z.ZodString;
|
|
59
|
+
currency: z.ZodString;
|
|
60
|
+
}, z.core.$strict>>;
|
|
61
|
+
}, z.core.$strict>>;
|
|
62
|
+
orgCeiling: z.ZodOptional<z.ZodObject<{
|
|
63
|
+
tokens: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
spend: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
amount: z.ZodString;
|
|
66
|
+
currency: z.ZodString;
|
|
67
|
+
}, z.core.$strict>>;
|
|
68
|
+
}, z.core.$strict>>;
|
|
69
|
+
memberDefault: z.ZodOptional<z.ZodObject<{
|
|
70
|
+
tokens: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
spend: z.ZodOptional<z.ZodObject<{
|
|
72
|
+
amount: z.ZodString;
|
|
73
|
+
currency: z.ZodString;
|
|
74
|
+
}, z.core.$strict>>;
|
|
75
|
+
}, z.core.$strict>>;
|
|
76
|
+
memberCeiling: z.ZodOptional<z.ZodObject<{
|
|
77
|
+
tokens: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
spend: z.ZodOptional<z.ZodObject<{
|
|
79
|
+
amount: z.ZodString;
|
|
80
|
+
currency: z.ZodString;
|
|
81
|
+
}, z.core.$strict>>;
|
|
82
|
+
}, z.core.$strict>>;
|
|
83
|
+
}, z.core.$strict>>>;
|
|
33
84
|
priceCurrency: z.ZodOptional<z.ZodString>;
|
|
34
85
|
sandboxLimitOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodObject<{
|
|
35
86
|
cpu: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { externalDispositionBlockers } from "../erasure/external-evidence.js";
|
|
2
3
|
import { MAX_PASSWORD_LENGTH } from "../identity/login.js";
|
|
3
4
|
import { DEPLOYMENT_SETTINGS_PATCH } from "../identity/settings.js";
|
|
4
5
|
import { ModelDisabledPatch, ModelProviderParams } from "../models/enablement.controller.js";
|
|
@@ -17,6 +18,13 @@ export const CreateAccountBody = z.object({
|
|
|
17
18
|
superAdmin: z.boolean().optional(),
|
|
18
19
|
});
|
|
19
20
|
export const AccountParams = z.object({ accountId: z.string().min(1).max(100) });
|
|
21
|
+
export const AccountErasureBody = z.strictObject({ confirm: z.literal(true) });
|
|
22
|
+
export const ErasureWorkParams = z.object({ workId: z.uuid() });
|
|
23
|
+
export const ErasureDispositionBody = z.strictObject({
|
|
24
|
+
blocker: z.enum(externalDispositionBlockers),
|
|
25
|
+
reason: z.string().trim().min(1).max(500),
|
|
26
|
+
evidence: z.string().trim().min(1).max(255),
|
|
27
|
+
});
|
|
20
28
|
export const UpdateAccountBody = z.object({
|
|
21
29
|
/** A body sanity bound; a changed name must have at most 64 code points (the service checks). */
|
|
22
30
|
displayName: z.string().trim().min(1).max(1000).optional(),
|
|
@@ -36,6 +44,18 @@ export const ADMIN_ROUTES = [
|
|
|
36
44
|
params: AccountParams,
|
|
37
45
|
body: UpdateAccountBody,
|
|
38
46
|
},
|
|
47
|
+
{
|
|
48
|
+
route: "POST /api/v1/admin/accounts/:accountId/erasure",
|
|
49
|
+
params: AccountParams,
|
|
50
|
+
body: AccountErasureBody,
|
|
51
|
+
},
|
|
52
|
+
{ route: "GET /api/v1/admin/account-erasures/:workId", params: ErasureWorkParams },
|
|
53
|
+
{ route: "GET /api/v1/admin/erasure-requests/:workId", params: ErasureWorkParams },
|
|
54
|
+
{
|
|
55
|
+
route: "POST /api/v1/admin/erasure-requests/:workId/external-disposition",
|
|
56
|
+
params: ErasureWorkParams,
|
|
57
|
+
body: ErasureDispositionBody,
|
|
58
|
+
},
|
|
39
59
|
{ route: "GET /api/v1/admin/orgs" },
|
|
40
60
|
// `:orgId` is the conversation's org for the operation, so never an operation field
|
|
41
61
|
{ route: "GET /api/v1/admin/orgs/:orgId/members" },
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import { ErasureRequests } from "../erasure/requests.js";
|
|
3
|
+
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
4
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
|
+
import type { ErasureDispositionBody } from "./admin.schemas.js";
|
|
7
|
+
export declare class ErasureDispositions {
|
|
8
|
+
private readonly db;
|
|
9
|
+
readonly txHost: TransactionHost;
|
|
10
|
+
private readonly requests;
|
|
11
|
+
private readonly admins;
|
|
12
|
+
constructor(db: KernelDb, txHost: TransactionHost, requests: ErasureRequests, admins: SuperAdminLock);
|
|
13
|
+
status(id: string): Promise<{
|
|
14
|
+
blockedReason: string | null;
|
|
15
|
+
completedAt: Date | null;
|
|
16
|
+
dueAt: Date;
|
|
17
|
+
id: string;
|
|
18
|
+
kind: "account" | "org";
|
|
19
|
+
scopeBoundaries: "third-party-conversation-content"[];
|
|
20
|
+
stage: "account-external" | "account-final" | "account-orgs" | "blocked" | "done" | "late" | "objects" | "pending" | "prefix" | "roots" | "rows";
|
|
21
|
+
}>;
|
|
22
|
+
record(id: string, actor: string, input: z.infer<typeof ErasureDispositionBody>): Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
11
|
+
import { ErasureRequests } from "../erasure/requests.js";
|
|
12
|
+
import { ApiError } from "../errors.js";
|
|
13
|
+
import { audit } from "../identity/audit.js";
|
|
14
|
+
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
15
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
16
|
+
import { asPlatform } from "../infra/database/org-scope.js";
|
|
17
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
18
|
+
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
19
|
+
let ErasureDispositions = class ErasureDispositions {
|
|
20
|
+
db;
|
|
21
|
+
txHost;
|
|
22
|
+
requests;
|
|
23
|
+
admins;
|
|
24
|
+
constructor(db, txHost, requests, admins) {
|
|
25
|
+
this.db = db;
|
|
26
|
+
this.txHost = txHost;
|
|
27
|
+
this.requests = requests;
|
|
28
|
+
this.admins = admins;
|
|
29
|
+
}
|
|
30
|
+
async status(id) {
|
|
31
|
+
const request = await this.requests.status(id);
|
|
32
|
+
if (!request)
|
|
33
|
+
throw new ApiError("not_found", "Erasure request not found");
|
|
34
|
+
return request;
|
|
35
|
+
}
|
|
36
|
+
async record(id, actor, input) {
|
|
37
|
+
await this.admins.lockAndAuthorize(actor);
|
|
38
|
+
// org-filter: deployment-wide the super admin verifies one request by its opaque receipt ID.
|
|
39
|
+
await asPlatform("record verified erasure evidence", async () => {
|
|
40
|
+
const request = await this.db
|
|
41
|
+
.selectFrom("data_erasure_requests")
|
|
42
|
+
.selectAll()
|
|
43
|
+
.where("id", "=", id)
|
|
44
|
+
.forUpdate()
|
|
45
|
+
.executeTakeFirst();
|
|
46
|
+
if (!request)
|
|
47
|
+
throw new ApiError("not_found", "Erasure request not found");
|
|
48
|
+
if (request.stage !== "pending" ||
|
|
49
|
+
!request.target_id ||
|
|
50
|
+
request.blocked_reason !== input.blocker ||
|
|
51
|
+
(request.kind === "account" && input.blocker === "catalog-or-tool-ownership-unverified")) {
|
|
52
|
+
throw new ApiError("conflict", "The erasure blocker has changed. Refresh the receipt.");
|
|
53
|
+
}
|
|
54
|
+
await audit(this.db.db, {
|
|
55
|
+
actorAccountId: actor,
|
|
56
|
+
action: "data_erasure.external_verified",
|
|
57
|
+
target: request.id,
|
|
58
|
+
detail: input,
|
|
59
|
+
});
|
|
60
|
+
if (!(await this.requests.advance(request, "pending", null, new Date()))) {
|
|
61
|
+
throw new ApiError("conflict", "The erasure blocker has changed. Refresh the receipt.");
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
__decorate([
|
|
67
|
+
Transactional()
|
|
68
|
+
], ErasureDispositions.prototype, "record", null);
|
|
69
|
+
ErasureDispositions = __decorate([
|
|
70
|
+
Injectable(),
|
|
71
|
+
__param(0, Inject(KernelDb)),
|
|
72
|
+
__param(1, Inject(TransactionHost)),
|
|
73
|
+
__param(2, Inject(ErasureRequests)),
|
|
74
|
+
__param(3, Inject(SuperAdminLock))
|
|
75
|
+
], ErasureDispositions);
|
|
76
|
+
export { ErasureDispositions };
|
|
@@ -88,6 +88,12 @@ export interface AdminHealth {
|
|
|
88
88
|
running: number;
|
|
89
89
|
}[];
|
|
90
90
|
} | null;
|
|
91
|
+
/** Up to ten recent retention blockers, oldest due first. Recovery holds are expected. */
|
|
92
|
+
retentionBlockers: {
|
|
93
|
+
workId: string;
|
|
94
|
+
orgId: string | null;
|
|
95
|
+
reason: string;
|
|
96
|
+
}[] | null;
|
|
91
97
|
unavailable: AdminHealthSource[];
|
|
92
98
|
}
|
|
93
99
|
/**
|