@capybara-hq/kernel 0.1.0-rc.142 → 0.1.0-rc.144
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/admin-agents.controller.d.ts +3 -5
- package/dist/admin/admin-agents.controller.js +1 -1
- package/dist/admin/admin-connectors.controller.d.ts +3 -5
- package/dist/admin/admin-connectors.controller.js +1 -1
- package/dist/admin/admin-items.schemas.d.ts +6 -6
- package/dist/admin/admin-items.schemas.js +5 -9
- package/dist/admin/admin.controller.d.ts +18 -12
- package/dist/admin/admin.controller.js +29 -15
- package/dist/admin/admin.schemas.d.ts +12 -3
- package/dist/admin/admin.schemas.js +17 -6
- package/dist/agents/admin-agents.d.ts +10 -8
- package/dist/agents/admin-agents.js +13 -9
- package/dist/agents/agents.module.js +3 -0
- package/dist/agents/agents.service.js +1 -1
- package/dist/agents/org-templates.d.ts +3 -1
- package/dist/agents/org-templates.js +7 -3
- package/dist/agents/pending-connector-requests.d.ts +10 -4
- package/dist/agents/pending-connector-requests.js +29 -7
- package/dist/automations/automations.controller.d.ts +9 -5
- package/dist/automations/automations.controller.js +21 -4
- package/dist/automations/automations.schemas.d.ts +19 -0
- package/dist/automations/automations.schemas.js +9 -0
- package/dist/automations/automations.service.d.ts +25 -8
- package/dist/automations/automations.service.js +40 -34
- package/dist/automations/events/acceptance.d.ts +6 -1
- package/dist/automations/events/acceptance.js +30 -11
- package/dist/automations/store.d.ts +17 -0
- package/dist/automations/store.js +35 -0
- package/dist/catalog/admin-catalog.controller.d.ts +64 -2
- package/dist/catalog/admin-catalog.controller.js +17 -0
- package/dist/catalog/catalog-import.module.js +3 -0
- package/dist/catalog/catalog-scope.service.d.ts +3 -1
- package/dist/catalog/catalog-scope.service.js +11 -7
- package/dist/catalog/catalog.module.js +3 -0
- package/dist/catalog/catalog.service.d.ts +3 -1
- package/dist/catalog/catalog.service.js +8 -4
- package/dist/catalog/cli.js +2 -2
- package/dist/catalog/component-promotion.d.ts +3 -1
- package/dist/catalog/component-promotion.js +7 -3
- package/dist/catalog/component-scope.service.d.ts +3 -1
- package/dist/catalog/component-scope.service.js +7 -3
- package/dist/catalog/enable-requests.d.ts +10 -8
- package/dist/catalog/enable-requests.js +40 -21
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/owned-items.d.ts +3 -1
- package/dist/catalog/owned-items.js +13 -9
- package/dist/catalog/platform-components.d.ts +6 -1
- package/dist/catalog/platform-components.js +9 -3
- package/dist/catalog/plugin-connectors.d.ts +8 -4
- package/dist/catalog/plugin-connectors.js +12 -6
- package/dist/catalog/plugin-import.d.ts +3 -1
- package/dist/catalog/plugin-import.js +14 -5
- package/dist/catalog/plugin-install.d.ts +3 -1
- package/dist/catalog/plugin-install.js +8 -4
- package/dist/catalog/plugin-package.js +2 -1
- package/dist/catalog/plugin-upgrade.d.ts +3 -1
- package/dist/catalog/plugin-upgrade.js +8 -4
- package/dist/catalog/request-hints.d.ts +19 -0
- package/dist/catalog/request-hints.js +34 -0
- package/dist/catalog/request-rules.d.ts +9 -5
- package/dist/catalog/request-rules.js +16 -9
- package/dist/catalog/requests.service.d.ts +3 -1
- package/dist/catalog/requests.service.js +28 -9
- package/dist/catalog/scope-orgs.d.ts +2 -1
- package/dist/catalog/scope-orgs.js +2 -2
- package/dist/catalog/scope-sync.d.ts +3 -1
- package/dist/catalog/scope-sync.js +12 -2
- package/dist/catalog/scope-writer.d.ts +6 -3
- package/dist/catalog/scope-writer.js +28 -10
- package/dist/catalog/unshare.d.ts +3 -2
- package/dist/catalog/unshare.js +4 -4
- package/dist/client/client-access.service.js +29 -1
- package/dist/config/schema.d.ts +12 -0
- package/dist/config/schema.js +56 -0
- package/dist/ctx/create-ctx.d.ts +2 -19
- package/dist/ctx/create-ctx.js +3 -93
- package/dist/ctx/durable-relay.d.ts +2 -5
- package/dist/ctx/durable-relay.js +56 -29
- package/dist/db/extension-handoff-schema.js +5 -0
- package/dist/db/kernel-schema.d.ts +74 -0
- package/dist/db/migrator.js +36 -0
- package/dist/erasure/account-batches.js +2 -0
- package/dist/erasure/account-residual.js +1 -0
- package/dist/erasure/org-catalog.js +8 -3
- package/dist/erasure/org-rules.js +1 -0
- package/dist/evals/evals.schemas.d.ts +15 -5
- package/dist/evals/evals.schemas.js +17 -10
- package/dist/evals/runs.controller.d.ts +4 -12
- package/dist/evals/runs.controller.js +14 -11
- package/dist/evals/runs.service.d.ts +29 -25
- package/dist/evals/runs.service.js +73 -61
- package/dist/evals/trajectory.controller.d.ts +10 -6
- package/dist/evals/trajectory.controller.js +11 -4
- package/dist/evals/trajectory.service.d.ts +17 -9
- package/dist/evals/trajectory.service.js +52 -35
- package/dist/extensions/admin-ops.d.ts +6 -1
- package/dist/extensions/admin-ops.js +21 -7
- package/dist/extensions/blobs.d.ts +2 -0
- package/dist/extensions/blobs.js +11 -0
- package/dist/extensions/deployment-config.d.ts +6 -1
- package/dist/extensions/deployment-config.js +13 -2
- package/dist/extensions/enabled.d.ts +5 -0
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/grant-epoch.d.ts +108 -0
- package/dist/extensions/grant-epoch.js +214 -0
- package/dist/extensions/host.d.ts +29 -9
- package/dist/extensions/host.js +148 -42
- package/dist/extensions/instance.d.ts +3 -3
- package/dist/extensions/instance.js +1 -1
- package/dist/extensions/isolated/authorization.d.ts +54 -2
- package/dist/extensions/isolated/authorization.js +148 -35
- package/dist/extensions/isolated/child-session.js +0 -1
- package/dist/extensions/isolated/revision.js +1 -1
- package/dist/extensions/org-config.d.ts +3 -1
- package/dist/extensions/org-config.js +13 -4
- package/dist/extensions/org-overrides.d.ts +6 -1
- package/dist/extensions/org-overrides.js +13 -2
- package/dist/extensions/package-digest.job.d.ts +34 -0
- package/dist/extensions/package-digest.job.js +121 -0
- package/dist/extensions/package.js +10 -6
- package/dist/extensions/permission-set.d.ts +14 -78
- package/dist/extensions/permission-set.js +17 -143
- package/dist/extensions/permission-view.d.ts +13 -1
- package/dist/extensions/permission-view.js +20 -0
- package/dist/extensions/registry.js +4 -1
- package/dist/extensions/resolve.d.ts +7 -8
- package/dist/extensions/resolve.js +7 -8
- package/dist/extensions/revision-approvals.d.ts +167 -0
- package/dist/extensions/revision-approvals.js +353 -0
- package/dist/extensions/revision-grants.d.ts +197 -0
- package/dist/extensions/revision-grants.js +584 -0
- package/dist/extensions/state.module.js +12 -1
- package/dist/identity/accounts.d.ts +10 -4
- package/dist/identity/accounts.js +18 -5
- package/dist/inbox/inbox-items.service.d.ts +6 -1
- package/dist/inbox/inbox-items.service.js +29 -10
- package/dist/inbox/inbox.module.js +3 -0
- package/dist/inbox/inbox.service.d.ts +3 -1
- package/dist/inbox/inbox.service.js +9 -2
- package/dist/inbox/org-notices.d.ts +4 -3
- package/dist/inbox/org-notices.js +9 -6
- package/dist/inbox/platform-inbox.service.d.ts +3 -1
- package/dist/inbox/platform-inbox.service.js +11 -3
- package/dist/inbox/platform-notices.d.ts +3 -2
- package/dist/inbox/platform-notices.js +10 -4
- package/dist/infra/config/kernel-config.service.js +4 -1
- package/dist/infra/database/extension-effect-key-lock.js +7 -0
- package/dist/infra/paging/paged-read.d.ts +34 -4
- package/dist/infra/paging/paged-read.js +38 -1
- package/dist/invalidation/audiences.d.ts +32 -0
- package/dist/invalidation/audiences.js +43 -0
- package/dist/invalidation/hints.d.ts +6 -0
- package/dist/invalidation/hints.js +7 -1
- package/dist/invalidation/invalidation-hints.d.ts +12 -1
- package/dist/invalidation/invalidation-hints.js +46 -5
- package/dist/invalidation/invalidation-hints.module.d.ts +2 -0
- package/dist/invalidation/invalidation-hints.module.js +4 -1
- package/dist/invalidation/me-stream.d.ts +1 -11
- package/dist/invalidation/me-stream.js +12 -41
- package/dist/invalidation/org-intent-bridge.d.ts +18 -0
- package/dist/invalidation/org-intent-bridge.js +46 -0
- package/dist/models/enablement.d.ts +3 -1
- package/dist/models/enablement.js +25 -5
- package/dist/orgs/invitations.controller.d.ts +4 -7
- package/dist/orgs/invitations.controller.js +8 -5
- package/dist/orgs/invitations.service.d.ts +17 -3
- package/dist/orgs/invitations.service.js +35 -13
- package/dist/orgs/members.service.d.ts +35 -0
- package/dist/orgs/members.service.js +52 -3
- package/dist/orgs/offboarding.d.ts +3 -1
- package/dist/orgs/offboarding.js +7 -3
- package/dist/orgs/orgs.controller.d.ts +11 -4
- package/dist/orgs/orgs.controller.js +25 -5
- package/dist/orgs/orgs.module.js +3 -0
- package/dist/orgs/orgs.schemas.d.ts +14 -0
- package/dist/orgs/orgs.schemas.js +19 -2
- package/dist/orgs/orgs.service.d.ts +24 -2
- package/dist/orgs/orgs.service.js +47 -4
- package/dist/orgs/security-settings.service.d.ts +14 -6
- package/dist/orgs/security-settings.service.js +18 -13
- package/dist/orgs/settings.controller.d.ts +7 -4
- package/dist/platform/exclusions.js +15 -0
- package/dist/platform/ops/accounts.ops.js +7 -16
- package/dist/platform/ops/admin-items.ops.js +7 -7
- package/dist/platform/ops/automations.ops.js +6 -4
- package/dist/platform/ops/evals.ops.js +30 -15
- package/dist/platform/ops/org-settings.ops.js +2 -2
- package/dist/platform/ops/orgs.ops.js +44 -27
- package/dist/push/delivery.d.ts +3 -1
- package/dist/push/delivery.js +7 -3
- package/dist/push/push-processor.js +8 -1
- package/dist/roles/worker.module.js +3 -0
- package/dist/runtime/step-log.d.ts +1 -1
- package/dist/runtime/step-log.js +5 -4
- package/dist/runtime/stream-limit.d.ts +13 -0
- package/dist/runtime/stream-limit.js +40 -0
- package/dist/runtime/stream.controller.d.ts +2 -0
- package/dist/runtime/stream.controller.js +2 -0
- package/dist/runtime/stream.d.ts +1 -0
- package/dist/runtime/stream.js +15 -6
- package/dist/sandbox/permission-authority.module.js +6 -1
- package/dist/sandbox/permission-transitions.d.ts +3 -1
- package/dist/sandbox/permission-transitions.js +17 -2
- package/dist/setup/kernel-checks.d.ts +3 -3
- package/dist/setup/kernel-checks.js +4 -4
- package/dist/setup/setup-check-registry.d.ts +16 -5
- package/dist/setup/setup-check-registry.js +11 -3
- package/dist/setup/setup-checks.service.d.ts +1 -2
- package/dist/setup/setup-checks.service.js +7 -6
- package/dist/skills/agent-skills.service.d.ts +6 -1
- package/dist/skills/agent-skills.service.js +12 -3
- package/dist/skills/changes.service.d.ts +6 -1
- package/dist/skills/changes.service.js +11 -3
- package/dist/skills/conversation-catalog.d.ts +3 -0
- package/dist/skills/conversation-catalog.js +2 -0
- package/dist/skills/skills.module.js +3 -0
- package/dist/skills/skills.service.d.ts +3 -1
- package/dist/skills/skills.service.js +8 -4
- package/dist/tools/admin-connectors.d.ts +10 -8
- package/dist/tools/admin-connectors.js +12 -10
- package/dist/tools/approvals.service.d.ts +12 -1
- package/dist/tools/approvals.service.js +36 -9
- package/dist/tools/builtins/automations.d.ts +1 -1
- package/dist/tools/builtins/automations.js +1 -1
- package/dist/tools/connectors.service.d.ts +3 -1
- package/dist/tools/connectors.service.js +29 -7
- package/dist/tools/tools.module.js +3 -0
- package/dist/ui/admin-ui.controller.d.ts +3 -1
- package/dist/ui/admin-ui.controller.js +3 -1
- package/dist/ui/ui-stream.d.ts +2 -0
- package/dist/ui/ui-stream.js +20 -6
- package/dist/ui/views.controller.d.ts +4 -2
- package/dist/ui/views.controller.js +4 -2
- package/package.json +3 -3
- package/src/migrations/0234_extension_grant_epoch.sql +141 -0
- package/src/migrations/0235_extension_revision_grants.sql +166 -0
- package/src/migrations/0236_paged_table_idx.sql +33 -0
- package/src/migrations/0237_extension_handoff_health.sql +18 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Account, AccountsService } from "../identity/accounts.js";
|
|
2
2
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
3
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
4
|
+
import { type Page } from "../infra/paging/paged-read.js";
|
|
4
5
|
import { MembersService } from "./members.service.js";
|
|
5
6
|
import { OrgLock } from "./org-lock.js";
|
|
6
7
|
import { type OrgRole } from "./roles.js";
|
|
@@ -59,9 +60,18 @@ export declare class InvitationsService {
|
|
|
59
60
|
token: string;
|
|
60
61
|
}>;
|
|
61
62
|
private createIn;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
/** Every invitation of the org with its status, oldest first (internal callers). */
|
|
64
|
+
list(orgId: string): Promise<InvitationView[]>;
|
|
65
|
+
/**
|
|
66
|
+
* One page of every invitation ever made in the org, newest first (`created_at`, then id), by
|
|
67
|
+
* page number without a snapshot (table pagination spec §2.3: an invitation's status changes
|
|
68
|
+
* in place).
|
|
69
|
+
*/
|
|
70
|
+
page(orgId: string, q: {
|
|
71
|
+
page: number;
|
|
72
|
+
size: number;
|
|
73
|
+
}): Promise<Page<InvitationView>>;
|
|
74
|
+
private invitationsOf;
|
|
65
75
|
/** 撤销;不属于该组织 → `invitation.invalid`;已接受 → `invitation.used`;已撤销则无操作。 */
|
|
66
76
|
revoke(orgId: string, id: string, actorAccountId: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<void>;
|
|
67
77
|
preview(token: string): Promise<{
|
|
@@ -91,3 +101,7 @@ export declare class InvitationsService {
|
|
|
91
101
|
*/
|
|
92
102
|
private classify;
|
|
93
103
|
}
|
|
104
|
+
/** An invitation as the list shows it: with its status. */
|
|
105
|
+
export type InvitationView = Invitation & {
|
|
106
|
+
status: InvitationStatus;
|
|
107
|
+
};
|
|
@@ -18,6 +18,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
18
18
|
import { asPlatform, withOrgScope } from "../infra/database/org-scope.js";
|
|
19
19
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
20
20
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
21
|
+
import { assertReadablePage, cappedCount, PAGED_TOTAL_CAP, pageOf, pageOffset, } from "../infra/paging/paged-read.js";
|
|
21
22
|
import { MembersService } from "./members.service.js";
|
|
22
23
|
import { OrgLock } from "./org-lock.js";
|
|
23
24
|
import { roleAtLeast } from "./roles.js";
|
|
@@ -103,25 +104,36 @@ let InvitationsService = class InvitationsService {
|
|
|
103
104
|
await opts.inTransaction?.(invitation, token);
|
|
104
105
|
return { invitation, token };
|
|
105
106
|
}
|
|
107
|
+
/** Every invitation of the org with its status, oldest first (internal callers). */
|
|
106
108
|
async list(orgId) {
|
|
107
|
-
const rows = await this.
|
|
108
|
-
.selectFrom("invitations")
|
|
109
|
+
const rows = await this.invitationsOf(orgId)
|
|
109
110
|
.selectAll()
|
|
110
111
|
.select(sql `expires_at <= now()`.as("expired"))
|
|
111
|
-
.where("org_id", "=", orgId)
|
|
112
112
|
.orderBy("created_at")
|
|
113
113
|
.orderBy("id")
|
|
114
114
|
.execute();
|
|
115
|
-
return rows.map(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
115
|
+
return rows.map(invitationViewOf);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* One page of every invitation ever made in the org, newest first (`created_at`, then id), by
|
|
119
|
+
* page number without a snapshot (table pagination spec §2.3: an invitation's status changes
|
|
120
|
+
* in place).
|
|
121
|
+
*/
|
|
122
|
+
async page(orgId, q) {
|
|
123
|
+
assertReadablePage(q.page, q.size);
|
|
124
|
+
const counted = await cappedCount(this.db.db, this.invitationsOf(orgId), PAGED_TOTAL_CAP);
|
|
125
|
+
const rows = await this.invitationsOf(orgId)
|
|
126
|
+
.selectAll()
|
|
127
|
+
.select(sql `expires_at <= now()`.as("expired"))
|
|
128
|
+
.orderBy("created_at", "desc")
|
|
129
|
+
.orderBy("id", "desc")
|
|
130
|
+
.offset(pageOffset(q.page, q.size))
|
|
131
|
+
.limit(q.size)
|
|
132
|
+
.execute();
|
|
133
|
+
return pageOf(rows.map(invitationViewOf), q, counted);
|
|
134
|
+
}
|
|
135
|
+
invitationsOf(orgId) {
|
|
136
|
+
return this.db.selectFrom("invitations").where("org_id", "=", orgId);
|
|
125
137
|
}
|
|
126
138
|
/** 撤销;不属于该组织 → `invitation.invalid`;已接受 → `invitation.used`;已撤销则无操作。 */
|
|
127
139
|
async revoke(orgId, id, actorAccountId, actorTokenId, auditDetail) {
|
|
@@ -266,3 +278,13 @@ function signupOf(who) {
|
|
|
266
278
|
throw new Error("unreachable");
|
|
267
279
|
return who.signup;
|
|
268
280
|
}
|
|
281
|
+
function invitationViewOf({ expired, ...r }) {
|
|
282
|
+
const status = r.revoked_at
|
|
283
|
+
? "revoked"
|
|
284
|
+
: r.accepted_at
|
|
285
|
+
? "accepted"
|
|
286
|
+
: expired
|
|
287
|
+
? "expired"
|
|
288
|
+
: "pending";
|
|
289
|
+
return { ...toInvitation(r), status };
|
|
290
|
+
}
|
|
@@ -3,6 +3,7 @@ import type { Account } from "../identity/accounts.js";
|
|
|
3
3
|
import { CacheService } from "../infra/cache/cache.service.js";
|
|
4
4
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
5
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
|
+
import { type Page } from "../infra/paging/paged-read.js";
|
|
6
7
|
import { type ModelBudget } from "../models/budget-policy.js";
|
|
7
8
|
import { Offboarding } from "./offboarding.js";
|
|
8
9
|
import { OrgLock } from "./org-lock.js";
|
|
@@ -16,6 +17,20 @@ export interface Member {
|
|
|
16
17
|
/** 该组织的匿名访客(渠道连接的匿名策略用):不能改角色、移出、转让所有权或指派为 agent 负责人。 */
|
|
17
18
|
anonymous: boolean;
|
|
18
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* One member as the web's pickers and name maps need them (`GET …/members/directory`): who they
|
|
22
|
+
* are, how they show, their role (the owner count) and whether they are the org's anonymous guest
|
|
23
|
+
* (never picked as an owner or a member of an agent).
|
|
24
|
+
*/
|
|
25
|
+
export interface MemberDirectoryEntry {
|
|
26
|
+
accountId: string;
|
|
27
|
+
displayName: string;
|
|
28
|
+
/** Tells apart members of the same name in an owner picker. */
|
|
29
|
+
email: string | null;
|
|
30
|
+
avatarUrl: string | null;
|
|
31
|
+
role: OrgRole;
|
|
32
|
+
anonymous: boolean;
|
|
33
|
+
}
|
|
19
34
|
/**
|
|
20
35
|
* 账号是不是某个组织的匿名访客(`org_anonymous_accounts`)。匿名访客没有登录方式,只能以 guest 身份
|
|
21
36
|
* 代表 IM 里未绑定的人:不能被授予别的角色、成为 owner、指派为 agent 负责人、加入别的组织或被移出。
|
|
@@ -71,7 +86,27 @@ export declare class MembersService {
|
|
|
71
86
|
effective: ModelBudget;
|
|
72
87
|
}>;
|
|
73
88
|
private setModelBudgetIn;
|
|
89
|
+
/** Every member of the org, by join time (the internal callers and the admin console's org page). */
|
|
74
90
|
list(orgId: string): Promise<Member[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Every member of the org in the compact directory shape, by join time (the web's owner pickers
|
|
93
|
+
* and member names; the members table reads {@link page}).
|
|
94
|
+
*/
|
|
95
|
+
directory(orgId: string): Promise<MemberDirectoryEntry[]>;
|
|
96
|
+
/**
|
|
97
|
+
* One page of the org's members by join time (then account id), by page number without a
|
|
98
|
+
* snapshot (table pagination spec §2.3: memberships are edited in place); `q` keeps those whose
|
|
99
|
+
* display name or email contains it.
|
|
100
|
+
*/
|
|
101
|
+
page(orgId: string, q: {
|
|
102
|
+
page: number;
|
|
103
|
+
size: number;
|
|
104
|
+
q?: string;
|
|
105
|
+
}): Promise<Page<Member>>;
|
|
106
|
+
/** The org's memberships with their accounts, those matching `q` when given (not empty). */
|
|
107
|
+
private matching;
|
|
108
|
+
/** The matching members by join time, then account id; one window of them when given. */
|
|
109
|
+
private read;
|
|
75
110
|
/**
|
|
76
111
|
* 加入成员(邀请接受等,手动加入的唯一入口);已是成员 → `member.already_exists`;匿名访客 → `member.anonymous_guest`。
|
|
77
112
|
* 同一事务删除此人在该组织的通讯录排除(Ruling A20:手动重新加入后,通讯录同步恢复照常管理此人)。
|
|
@@ -8,6 +8,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
11
|
+
import { sql } from "kysely";
|
|
11
12
|
import { ApiError } from "../errors.js";
|
|
12
13
|
import { avatarColumns, personAvatarUrl } from "../identity/account-avatar.js";
|
|
13
14
|
import { audit } from "../identity/audit.js";
|
|
@@ -17,6 +18,7 @@ import { afterCommit } from "../infra/database/after-commit.js";
|
|
|
17
18
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
18
19
|
import { TransactionHost, withOrderedLocks } from "../infra/database/transaction-host.js";
|
|
19
20
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
21
|
+
import { assertReadablePage, cappedCount, PAGED_TOTAL_CAP, pageOf, pageOffset, } from "../infra/paging/paged-read.js";
|
|
20
22
|
import { readSettledModelUsage } from "../models/budget-counters.js";
|
|
21
23
|
import { orgModelBudgetCacheKey, readMemberBudget, readPlatformModelBudgets, resolveModelBudgets, StoredMemberBudgetsSchema, } from "../models/budget-policy.js";
|
|
22
24
|
import { Offboarding } from "./offboarding.js";
|
|
@@ -113,13 +115,58 @@ let MembersService = class MembersService {
|
|
|
113
115
|
});
|
|
114
116
|
return this.budgetView(updated, targetId);
|
|
115
117
|
}
|
|
118
|
+
/** Every member of the org, by join time (the internal callers and the admin console's org page). */
|
|
116
119
|
async list(orgId) {
|
|
117
|
-
|
|
120
|
+
return this.read(orgId);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Every member of the org in the compact directory shape, by join time (the web's owner pickers
|
|
124
|
+
* and member names; the members table reads {@link page}).
|
|
125
|
+
*/
|
|
126
|
+
async directory(orgId) {
|
|
127
|
+
return (await this.list(orgId)).map((m) => ({
|
|
128
|
+
accountId: m.account.id,
|
|
129
|
+
displayName: m.account.displayName,
|
|
130
|
+
email: m.account.email,
|
|
131
|
+
avatarUrl: m.account.avatarUrl,
|
|
132
|
+
role: m.role,
|
|
133
|
+
anonymous: m.anonymous,
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* One page of the org's members by join time (then account id), by page number without a
|
|
138
|
+
* snapshot (table pagination spec §2.3: memberships are edited in place); `q` keeps those whose
|
|
139
|
+
* display name or email contains it.
|
|
140
|
+
*/
|
|
141
|
+
async page(orgId, q) {
|
|
142
|
+
assertReadablePage(q.page, q.size);
|
|
143
|
+
const counted = await cappedCount(this.db.db, this.matching(orgId, q.q), PAGED_TOTAL_CAP);
|
|
144
|
+
const items = await this.read(orgId, q.q, {
|
|
145
|
+
offset: pageOffset(q.page, q.size),
|
|
146
|
+
limit: q.size,
|
|
147
|
+
});
|
|
148
|
+
return pageOf(items, q, counted);
|
|
149
|
+
}
|
|
150
|
+
/** The org's memberships with their accounts, those matching `q` when given (not empty). */
|
|
151
|
+
matching(orgId, q) {
|
|
152
|
+
let query = this.db
|
|
118
153
|
.selectFrom("memberships")
|
|
119
154
|
.innerJoin("accounts", "accounts.id", "memberships.account_id")
|
|
120
155
|
.leftJoin("org_anonymous_accounts", (j) => j
|
|
121
156
|
.onRef("org_anonymous_accounts.org_id", "=", "memberships.org_id")
|
|
122
157
|
.onRef("org_anonymous_accounts.account_id", "=", "memberships.account_id"))
|
|
158
|
+
.where("memberships.org_id", "=", orgId);
|
|
159
|
+
// an empty search (the route trims it) is no search
|
|
160
|
+
if (q !== undefined && q !== "") {
|
|
161
|
+
const like = `%${q.replace(/[\\%_]/g, (ch) => `\\${ch}`)}%`;
|
|
162
|
+
query = query.where(sql `(accounts.display_name ILIKE ${like} ESCAPE '\\'
|
|
163
|
+
OR accounts.email ILIKE ${like} ESCAPE '\\')`);
|
|
164
|
+
}
|
|
165
|
+
return query;
|
|
166
|
+
}
|
|
167
|
+
/** The matching members by join time, then account id; one window of them when given. */
|
|
168
|
+
async read(orgId, q, window) {
|
|
169
|
+
const rows = await this.matching(orgId, q)
|
|
123
170
|
.select((eb) => [
|
|
124
171
|
"accounts.id",
|
|
125
172
|
"accounts.display_name",
|
|
@@ -129,9 +176,11 @@ let MembersService = class MembersService {
|
|
|
129
176
|
"org_anonymous_accounts.account_id as anonymous_id",
|
|
130
177
|
...avatarColumns(eb, "accounts", "account"),
|
|
131
178
|
])
|
|
132
|
-
.where("memberships.org_id", "=", orgId)
|
|
133
179
|
.orderBy("memberships.created_at")
|
|
134
|
-
|
|
180
|
+
// the membership's column (the same value as accounts.id), so the index
|
|
181
|
+
// (org_id, created_at, account_id) serves the tie-break
|
|
182
|
+
.orderBy("memberships.account_id")
|
|
183
|
+
.$if(window !== undefined, (x) => x.offset(window?.offset ?? 0).limit(window?.limit ?? PAGED_TOTAL_CAP))
|
|
135
184
|
.execute();
|
|
136
185
|
return rows.map((r) => ({
|
|
137
186
|
account: {
|
|
@@ -5,6 +5,7 @@ import { SessionService } from "../identity/sessions.js";
|
|
|
5
5
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
6
6
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
7
7
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
8
|
+
import type { HintPublisher } from "../invalidation/audiences.js";
|
|
8
9
|
import type { KernelLogger } from "../log.js";
|
|
9
10
|
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
10
11
|
import { ApprovalsService } from "../tools/approvals.service.js";
|
|
@@ -87,13 +88,14 @@ export declare class Offboarding {
|
|
|
87
88
|
readonly log: KernelLogger;
|
|
88
89
|
private readonly ceilings;
|
|
89
90
|
private readonly orgLock;
|
|
91
|
+
private readonly hints;
|
|
90
92
|
constructor(db: KernelDb, txHost: TransactionHost, sessions: Pick<SessionService, "markRevoked">, registry: Pick<ExtensionRegistry, "list">, eventLog: Pick<EventLog, "notify" | "publishChanged">,
|
|
91
93
|
/** Owes the run stops and device destroys in the offboard transaction. */
|
|
92
94
|
outbox: Pick<OutboxService, "add">,
|
|
93
95
|
/** Stops the departed member's runs (`by: null`, a system action) in the `run-stop` job. */
|
|
94
96
|
runs: OffboardingRunControl, credentials: Pick<Credentials, "clearAccount">, approvals: Pick<ApprovalsService, "pendingConversationsFor" | "cancelPendingFor">, questions: Pick<QuestionsService, "pendingConversationsFor" | "cancelPendingFor">,
|
|
95
97
|
/** Owes `org.member_removed` to the subscribing plugins, in the offboard transaction. */
|
|
96
|
-
lifecycle: Pick<LifecycleHooks, "recordIn">, log: KernelLogger, ceilings: PermissionCeilingWrites, orgLock: Pick<OrgLock, "lockForRemoval"
|
|
98
|
+
lifecycle: Pick<LifecycleHooks, "recordIn">, log: KernelLogger, ceilings: PermissionCeilingWrites, orgLock: Pick<OrgLock, "lockForRemoval">, hints: HintPublisher);
|
|
97
99
|
/**
|
|
98
100
|
* In the caller's transaction (`mandatory`: the caller holds the org row lock, order org row →
|
|
99
101
|
* membership, and did the "last owner" checks):
|
package/dist/orgs/offboarding.js
CHANGED
|
@@ -27,6 +27,7 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
|
27
27
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
28
28
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
29
29
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
30
|
+
import { InvalidationHints } from "../invalidation/invalidation-hints.js";
|
|
30
31
|
import { deletePushRegistrationsForSessions } from "../push/registration-cleanup.js";
|
|
31
32
|
import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
|
|
32
33
|
import { RunControl } from "../runtime/run-control.js";
|
|
@@ -76,13 +77,14 @@ let Offboarding = class Offboarding {
|
|
|
76
77
|
log;
|
|
77
78
|
ceilings;
|
|
78
79
|
orgLock;
|
|
80
|
+
hints;
|
|
79
81
|
constructor(db, txHost, sessions, registry, eventLog,
|
|
80
82
|
/** Owes the run stops and device destroys in the offboard transaction. */
|
|
81
83
|
outbox,
|
|
82
84
|
/** Stops the departed member's runs (`by: null`, a system action) in the `run-stop` job. */
|
|
83
85
|
runs, credentials, approvals, questions,
|
|
84
86
|
/** Owes `org.member_removed` to the subscribing plugins, in the offboard transaction. */
|
|
85
|
-
lifecycle, log, ceilings, orgLock) {
|
|
87
|
+
lifecycle, log, ceilings, orgLock, hints) {
|
|
86
88
|
this.db = db;
|
|
87
89
|
this.txHost = txHost;
|
|
88
90
|
this.sessions = sessions;
|
|
@@ -97,6 +99,7 @@ let Offboarding = class Offboarding {
|
|
|
97
99
|
this.log = log;
|
|
98
100
|
this.ceilings = ceilings;
|
|
99
101
|
this.orgLock = orgLock;
|
|
102
|
+
this.hints = hints;
|
|
100
103
|
}
|
|
101
104
|
/**
|
|
102
105
|
* In the caller's transaction (`mandatory`: the caller holds the org row lock, order org row →
|
|
@@ -263,7 +266,7 @@ let Offboarding = class Offboarding {
|
|
|
263
266
|
.returning("id")
|
|
264
267
|
.execute();
|
|
265
268
|
// their connector setup requests follow them to the org owner (ruling P4-T6-4)
|
|
266
|
-
await retargetSetupRequests(this.db.db, agents.map((a) => a.id), owner.account_id);
|
|
269
|
+
await retargetSetupRequests(this.db.db, this.hints, agents.map((a) => a.id), owner.account_id);
|
|
267
270
|
const threads = await this.db
|
|
268
271
|
.updateTable("channel_threads")
|
|
269
272
|
.set({ archived_at: sql `now()` })
|
|
@@ -509,6 +512,7 @@ Offboarding = __decorate([
|
|
|
509
512
|
__param(10, Inject(LifecycleHooks)),
|
|
510
513
|
__param(11, Inject(KERNEL_LOGGER)),
|
|
511
514
|
__param(12, Inject(PermissionCeilingWrites)),
|
|
512
|
-
__param(13, Inject(OrgLock))
|
|
515
|
+
__param(13, Inject(OrgLock)),
|
|
516
|
+
__param(14, Inject(InvalidationHints))
|
|
513
517
|
], Offboarding);
|
|
514
518
|
export { Offboarding };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { type ApiTokenRecord, ApiTokenService } from "../identity/api-tokens.js";
|
|
3
3
|
import { type Principal } from "../identity/principal.js";
|
|
4
|
+
import type { Page } from "../infra/paging/paged-read.js";
|
|
4
5
|
import { MemberBudgetBody } from "../models/budget-policy.js";
|
|
5
|
-
import { type Member, MembersService } from "./members.service.js";
|
|
6
|
+
import { type Member, type MemberDirectoryEntry, MembersService } from "./members.service.js";
|
|
6
7
|
import { OrgNetworkAllowances } from "./network-allowances.service.js";
|
|
7
8
|
import { type OrgContext } from "./org.guard.js";
|
|
8
|
-
import { MemberParams, MemberRoleBody, type NetworkAllowanceView, OrgUpdateBody } from "./orgs.schemas.js";
|
|
9
|
+
import { MemberListQuery, MemberParams, MemberRoleBody, type NetworkAllowanceView, OrgUpdateBody } from "./orgs.schemas.js";
|
|
9
10
|
import { type Org, OrgsService } from "./orgs.service.js";
|
|
10
11
|
import type { OrgRole } from "./roles.js";
|
|
11
12
|
declare const CreateSchema: z.ZodObject<{
|
|
@@ -50,8 +51,14 @@ export declare class OrgsController {
|
|
|
50
51
|
remove(principal: Principal, org: OrgContext): Promise<void>;
|
|
51
52
|
transfer(principal: Principal, org: OrgContext, body: z.infer<typeof TransferSchema>): Promise<void>;
|
|
52
53
|
leave(principal: Principal, org: OrgContext): Promise<void>;
|
|
53
|
-
listMembers(org: OrgContext): Promise<
|
|
54
|
-
|
|
54
|
+
listMembers(org: OrgContext, q: z.infer<typeof MemberListQuery>): Promise<Page<Member>>;
|
|
55
|
+
/**
|
|
56
|
+
* Every member at once in the compact directory shape (account id, name, email, avatar, role,
|
|
57
|
+
* anonymous), for the web's owner pickers and member names; the members table pages
|
|
58
|
+
* `GET :orgId/members`. Readable by whoever may read that list.
|
|
59
|
+
*/
|
|
60
|
+
memberDirectory(org: OrgContext): Promise<{
|
|
61
|
+
members: MemberDirectoryEntry[];
|
|
55
62
|
}>;
|
|
56
63
|
/**
|
|
57
64
|
* The internal endpoints a super admin lets this org's extension requests reach (plugin safe
|
|
@@ -13,12 +13,12 @@ import { ApiError } from "../errors.js";
|
|
|
13
13
|
import { ApiTokenService, FutureIsoDate } from "../identity/api-tokens.js";
|
|
14
14
|
import { CurrentPrincipal, patTokenId, requireUser, SessionOnly, } from "../identity/principal.js";
|
|
15
15
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
16
|
-
import { ZBody, ZParam } from "../infra/validation/zod-params.js";
|
|
16
|
+
import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
|
|
17
17
|
import { MemberBudgetBody } from "../models/budget-policy.js";
|
|
18
18
|
import { MembersService } from "./members.service.js";
|
|
19
19
|
import { OrgNetworkAllowances } from "./network-allowances.service.js";
|
|
20
20
|
import { CurrentOrg, OrgAction } from "./org.guard.js";
|
|
21
|
-
import { MemberParams, MemberRoleBody, networkAllowanceView, OrgUpdateBody, } from "./orgs.schemas.js";
|
|
21
|
+
import { MemberListQuery, MemberParams, MemberRoleBody, networkAllowanceView, OrgUpdateBody, } from "./orgs.schemas.js";
|
|
22
22
|
import { OrgsService } from "./orgs.service.js";
|
|
23
23
|
const CreateSchema = z.object({
|
|
24
24
|
name: z.string().min(1).max(100),
|
|
@@ -44,6 +44,8 @@ class MemberRoleBodyDto extends createZodDto(MemberRoleBody, "MemberRoleBody") {
|
|
|
44
44
|
}
|
|
45
45
|
class MemberParamsDto extends createZodDto(MemberParams, "MemberParams") {
|
|
46
46
|
}
|
|
47
|
+
class MemberListQueryDto extends createZodDto(MemberListQuery, "MemberListQuery") {
|
|
48
|
+
}
|
|
47
49
|
/** 组织与成员(`/api/v1/orgs`)。组织级路由由 `@OrgAction` + OrgGuard 每请求实时鉴权。 */
|
|
48
50
|
let OrgsController = class OrgsController {
|
|
49
51
|
orgs;
|
|
@@ -87,8 +89,20 @@ let OrgsController = class OrgsController {
|
|
|
87
89
|
const p = requireUser(principal);
|
|
88
90
|
await this.members.leave(org.orgId, p.account.id, patTokenId(p));
|
|
89
91
|
}
|
|
90
|
-
async listMembers(org) {
|
|
91
|
-
return
|
|
92
|
+
async listMembers(org, q) {
|
|
93
|
+
return this.members.page(org.orgId, {
|
|
94
|
+
page: q.page,
|
|
95
|
+
size: q.size,
|
|
96
|
+
...(q.q !== undefined && { q: q.q }),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Every member at once in the compact directory shape (account id, name, email, avatar, role,
|
|
101
|
+
* anonymous), for the web's owner pickers and member names; the members table pages
|
|
102
|
+
* `GET :orgId/members`. Readable by whoever may read that list.
|
|
103
|
+
*/
|
|
104
|
+
async memberDirectory(org) {
|
|
105
|
+
return { members: await this.members.directory(org.orgId) };
|
|
92
106
|
}
|
|
93
107
|
/**
|
|
94
108
|
* The internal endpoints a super admin lets this org's extension requests reach (plugin safe
|
|
@@ -171,8 +185,14 @@ __decorate([
|
|
|
171
185
|
__decorate([
|
|
172
186
|
Get(":orgId/members"),
|
|
173
187
|
OrgAction("org.members.read"),
|
|
174
|
-
__param(0, CurrentOrg())
|
|
188
|
+
__param(0, CurrentOrg()),
|
|
189
|
+
__param(1, ZQuery(MemberListQueryDto))
|
|
175
190
|
], OrgsController.prototype, "listMembers", null);
|
|
191
|
+
__decorate([
|
|
192
|
+
Get(":orgId/members/directory"),
|
|
193
|
+
OrgAction("org.members.read"),
|
|
194
|
+
__param(0, CurrentOrg())
|
|
195
|
+
], OrgsController.prototype, "memberDirectory", null);
|
|
176
196
|
__decorate([
|
|
177
197
|
Get(":orgId/network-allowances"),
|
|
178
198
|
OrgAction("org.update"),
|
package/dist/orgs/orgs.module.js
CHANGED
|
@@ -13,6 +13,7 @@ import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
|
13
13
|
import { LifecycleHooksModule } from "../extensions/lifecycle-hooks.js";
|
|
14
14
|
import { IdentityModule } from "../identity/identity.module.js";
|
|
15
15
|
import { QueueModule } from "../infra/queue/queue.module.js";
|
|
16
|
+
import { InvalidationHintsModule } from "../invalidation/invalidation-hints.module.js";
|
|
16
17
|
import { PlatformModule } from "../platform/platform.module.js";
|
|
17
18
|
import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
|
|
18
19
|
import { RuntimeModule } from "../runtime/runtime.module.js";
|
|
@@ -38,6 +39,8 @@ let OrgsModule = class OrgsModule {
|
|
|
38
39
|
OrgsModule = __decorate([
|
|
39
40
|
Module({
|
|
40
41
|
imports: [
|
|
42
|
+
// invalidation hints its writers publish after their commit
|
|
43
|
+
InvalidationHintsModule,
|
|
41
44
|
IdentityModule,
|
|
42
45
|
ErasureModule,
|
|
43
46
|
StorageModule,
|
|
@@ -17,6 +17,20 @@ export declare const InvitationCreateBody: z.ZodObject<{
|
|
|
17
17
|
export declare const InvitationIdParams: z.ZodObject<{
|
|
18
18
|
id: z.ZodString;
|
|
19
19
|
}, z.core.$strip>;
|
|
20
|
+
/**
|
|
21
|
+
* `GET /api/v1/orgs/:orgId/members`: page numbers without a snapshot (table pagination spec §2.3:
|
|
22
|
+
* memberships are edited in place) and a search.
|
|
23
|
+
*/
|
|
24
|
+
export declare const MemberListQuery: z.ZodObject<{
|
|
25
|
+
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
26
|
+
size: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
27
|
+
q: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
/** `GET /api/v1/orgs/:orgId/invitations`: every invitation ever made, newest first, by page number. */
|
|
30
|
+
export declare const InvitationListQuery: z.ZodObject<{
|
|
31
|
+
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
32
|
+
size: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
20
34
|
/** `PATCH` / `DELETE /api/v1/orgs/:orgId/members/:accountId`. */
|
|
21
35
|
export declare const MemberParams: z.ZodObject<{
|
|
22
36
|
accountId: z.ZodString;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { PageQueryFields } from "../infra/paging/paged-read.js";
|
|
2
3
|
import { MemberBudgetBody } from "../models/budget-policy.js";
|
|
3
4
|
import { INVITABLE_ROLES, MAX_INVITATION_HOURS } from "./invitations.service.js";
|
|
4
5
|
import { ORG_ROLES } from "./roles.js";
|
|
@@ -15,6 +16,22 @@ export const InvitationCreateBody = z.object({
|
|
|
15
16
|
});
|
|
16
17
|
/** `DELETE /api/v1/orgs/:orgId/invitations/:id`. */
|
|
17
18
|
export const InvitationIdParams = z.object({ id: z.string().min(1).max(100) });
|
|
19
|
+
/**
|
|
20
|
+
* `GET /api/v1/orgs/:orgId/members`: page numbers without a snapshot (table pagination spec §2.3:
|
|
21
|
+
* memberships are edited in place) and a search.
|
|
22
|
+
*/
|
|
23
|
+
export const MemberListQuery = z.object({
|
|
24
|
+
// empty or blank: no search
|
|
25
|
+
q: z
|
|
26
|
+
.string()
|
|
27
|
+
.trim()
|
|
28
|
+
.max(200)
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Only members whose display name or email contains this (case-insensitive)."),
|
|
31
|
+
...PageQueryFields,
|
|
32
|
+
});
|
|
33
|
+
/** `GET /api/v1/orgs/:orgId/invitations`: every invitation ever made, newest first, by page number. */
|
|
34
|
+
export const InvitationListQuery = z.object({ ...PageQueryFields });
|
|
18
35
|
/** `PATCH` / `DELETE /api/v1/orgs/:orgId/members/:accountId`. */
|
|
19
36
|
export const MemberParams = z.object({ accountId: z.string().min(1).max(100) });
|
|
20
37
|
/** `PATCH /api/v1/orgs/:orgId/members/:accountId`. */
|
|
@@ -27,7 +44,7 @@ export const ORG_ROUTES = [
|
|
|
27
44
|
{ route: "GET /api/v1/orgs" },
|
|
28
45
|
{ route: "GET /api/v1/orgs/:orgId" },
|
|
29
46
|
{ route: "PATCH /api/v1/orgs/:orgId", body: OrgUpdateBody },
|
|
30
|
-
{ route: "GET /api/v1/orgs/:orgId/members" },
|
|
47
|
+
{ route: "GET /api/v1/orgs/:orgId/members", query: MemberListQuery },
|
|
31
48
|
{
|
|
32
49
|
route: "PATCH /api/v1/orgs/:orgId/members/:accountId",
|
|
33
50
|
params: MemberParams,
|
|
@@ -41,7 +58,7 @@ export const ORG_ROUTES = [
|
|
|
41
58
|
},
|
|
42
59
|
{ route: "DELETE /api/v1/orgs/:orgId/members/:accountId", params: MemberParams },
|
|
43
60
|
{ route: "POST /api/v1/orgs/:orgId/invitations", body: InvitationCreateBody },
|
|
44
|
-
{ route: "GET /api/v1/orgs/:orgId/invitations" },
|
|
61
|
+
{ route: "GET /api/v1/orgs/:orgId/invitations", query: InvitationListQuery },
|
|
45
62
|
{ route: "DELETE /api/v1/orgs/:orgId/invitations/:id", params: InvitationIdParams },
|
|
46
63
|
{ route: "GET /api/v1/orgs/:orgId/network-allowances" },
|
|
47
64
|
];
|
|
@@ -11,6 +11,8 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
|
11
11
|
import { XactLock } from "../infra/database/xact-lock.js";
|
|
12
12
|
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
13
13
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
14
|
+
import { type Page } from "../infra/paging/paged-read.js";
|
|
15
|
+
import type { HintPublisher } from "../invalidation/audiences.js";
|
|
14
16
|
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
15
17
|
import { StorageService } from "../storage/storage.service.js";
|
|
16
18
|
import { OrgLock } from "./org-lock.js";
|
|
@@ -21,6 +23,8 @@ export type Org = {
|
|
|
21
23
|
name: string;
|
|
22
24
|
createdAt: Date;
|
|
23
25
|
};
|
|
26
|
+
/** One org as the super admin's org pickers and names need it (`GET /admin/orgs/directory`). */
|
|
27
|
+
export type OrgDirectoryEntry = Pick<Org, "id" | "slug" | "name">;
|
|
24
28
|
/** 组织 slug:小写字母数字与 `-`,首尾不能是 `-`,1–40 个字符。 */
|
|
25
29
|
export declare const SLUG_RE: RegExp;
|
|
26
30
|
/** 由名字生成 slug:转小写、非字母数字换 `-`、去首尾 `-`;为空则 `org-<6 位随机>`。 */
|
|
@@ -49,6 +53,7 @@ export declare class OrgsService {
|
|
|
49
53
|
private readonly ceilings;
|
|
50
54
|
private readonly erasure;
|
|
51
55
|
private readonly storage;
|
|
56
|
+
private readonly hints;
|
|
52
57
|
constructor(db: KernelDb, outbox: Pick<OutboxService, "add">, txHost: TransactionHost, settings: SettingsService, apiTokens: ApiTokenService, orgLock: OrgLock, events: KernelEvents,
|
|
53
58
|
/** Cancels the deleted org's running eval runs (in the delete's transaction). */
|
|
54
59
|
evalBudget: Pick<EvalBudget, "cancelRuns">,
|
|
@@ -57,7 +62,7 @@ export declare class OrgsService {
|
|
|
57
62
|
/** What the deleted org owns is transferred or removed in the delete's transaction (P3-20). */
|
|
58
63
|
ownedItems: Pick<OwnedItems, "onOrgDeleted">,
|
|
59
64
|
/** Records `org.deleted` for the subscribing plugins in the delete's transaction. */
|
|
60
|
-
lifecycle: Pick<LifecycleHooks, "recordIn">, ceilings: PermissionCeilingWrites, erasure: Pick<ErasureRequests, "enqueue">, storage: Pick<StorageService, "erasureIdentity"
|
|
65
|
+
lifecycle: Pick<LifecycleHooks, "recordIn">, ceilings: PermissionCeilingWrites, erasure: Pick<ErasureRequests, "enqueue">, storage: Pick<StorageService, "erasureIdentity">, hints: HintPublisher);
|
|
61
66
|
/**
|
|
62
67
|
* Creates an org with the actor as owner, in the caller's transaction when there is one (the
|
|
63
68
|
* setup wizard creates it with the account); a slug conflict is `org.slug_taken` either way, but
|
|
@@ -74,10 +79,27 @@ export declare class OrgsService {
|
|
|
74
79
|
listForAccount(accountId: string): Promise<(Org & {
|
|
75
80
|
role: OrgRole;
|
|
76
81
|
})[]>;
|
|
77
|
-
/**
|
|
82
|
+
/** Every live org with its member count, oldest first (internal callers that need them all). */
|
|
78
83
|
listAll(): Promise<(Org & {
|
|
79
84
|
memberCount: number;
|
|
80
85
|
})[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Every live org in the compact directory shape, oldest first (the super admin's org filters,
|
|
88
|
+
* pickers and names; the orgs table reads {@link page}).
|
|
89
|
+
*/
|
|
90
|
+
directory(): Promise<OrgDirectoryEntry[]>;
|
|
91
|
+
/**
|
|
92
|
+
* One page of the live orgs with their member counts (the super admin's orgs list), newest first
|
|
93
|
+
* (`created_at`, then id), by page number without a snapshot (table pagination spec §2.3: orgs
|
|
94
|
+
* are edited in place); `q` keeps those whose name or slug contains it (case-insensitive).
|
|
95
|
+
*/
|
|
96
|
+
page(q: {
|
|
97
|
+
page: number;
|
|
98
|
+
size: number;
|
|
99
|
+
q?: string;
|
|
100
|
+
}): Promise<Page<Org & {
|
|
101
|
+
memberCount: number;
|
|
102
|
+
}>>;
|
|
81
103
|
/** 未软删除的组织;不存在或已软删除为 undefined。 */
|
|
82
104
|
get(orgId: string): Promise<Org | undefined>;
|
|
83
105
|
/** Renames / re-slugs (needs admin, decided live under the org lock). */
|