@capybara-hq/kernel 0.1.0-rc.143 → 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/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/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/cli.js +2 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/plugin-package.js +2 -1
- package/dist/client/client-access.service.js +29 -1
- package/dist/config/schema.d.ts +9 -0
- package/dist/config/schema.js +26 -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/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.js +4 -3
- package/dist/extensions/blobs.d.ts +2 -0
- package/dist/extensions/blobs.js +11 -0
- package/dist/extensions/enabled.d.ts +5 -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/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/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/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/orgs.controller.d.ts +11 -4
- package/dist/orgs/orgs.controller.js +25 -5
- package/dist/orgs/orgs.schemas.d.ts +14 -0
- package/dist/orgs/orgs.schemas.js +19 -2
- package/dist/orgs/orgs.service.d.ts +21 -1
- package/dist/orgs/orgs.service.js +40 -1
- 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/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/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/tools/admin-connectors.d.ts +10 -8
- package/dist/tools/admin-connectors.js +12 -10
- package/dist/tools/builtins/automations.d.ts +1 -1
- package/dist/tools/builtins/automations.js +1 -1
- 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
|
@@ -36,6 +36,13 @@ export async function handoffKeysInUse(db, keyIds, identity) {
|
|
|
36
36
|
where pg_catalog.left(n.nspname, ${prefix.length}) = ${prefix}
|
|
37
37
|
and c.relname = ${EXTENSION_EFFECT_HANDOFF}
|
|
38
38
|
`.execute(db);
|
|
39
|
+
const { rows: expected } = await sql `
|
|
40
|
+
select schema_name from capybara.extension_handoff_tables
|
|
41
|
+
`.execute(db);
|
|
42
|
+
const present = new Set(tables.map(({ schema }) => schema));
|
|
43
|
+
// A temporarily missing table may still hold envelopes when it is restored.
|
|
44
|
+
if (expected.some(({ schema_name }) => !present.has(schema_name)))
|
|
45
|
+
return new Set(keyIds);
|
|
39
46
|
const used = new Set();
|
|
40
47
|
for (const { schema, oid, ordinary, owner, login } of tables) {
|
|
41
48
|
const plugin = schema.slice(prefix.length).replaceAll("_", "-");
|
|
@@ -5,7 +5,8 @@ import type { KernelSchemaDb } from "../../db/kernel-schema.js";
|
|
|
5
5
|
* Page-number reads on a snapshot (table pagination spec §2.3): a paged route takes `page`,
|
|
6
6
|
* `size`, its filters and an optional `asOf`, and answers {@link Paged}. Shared by every route a
|
|
7
7
|
* DataTable pages on the server; the snapshot key (`asOf`) is the route's own (an append-only
|
|
8
|
-
* table uses its id, a sortable table its `(sort column, id)`).
|
|
8
|
+
* table uses its id, a sortable table its `(sort column, id)`). A table whose rows are edited or
|
|
9
|
+
* deleted in place reads without a snapshot and answers {@link Page} (no `asOf`, no `newer`).
|
|
9
10
|
*/
|
|
10
11
|
/** The page sizes a table offers (the Pagination select). */
|
|
11
12
|
export declare const PAGE_SIZES: readonly [20, 50, 100];
|
|
@@ -13,22 +14,38 @@ export declare const PAGE_SIZES: readonly [20, 50, 100];
|
|
|
13
14
|
export declare const PAGED_TOTAL_CAP = 10000;
|
|
14
15
|
/** `newer` stops counting here. */
|
|
15
16
|
export declare const PAGED_NEWER_CAP = 1000;
|
|
16
|
-
/**
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* One page of a paged route without a snapshot (spec §2.3): a table whose rows are edited or
|
|
19
|
+
* deleted in place (accounts, agents, connectors, an eval run's results) reads by offset alone,
|
|
20
|
+
* and a removed row shifts later pages by one. Such a route has no `asOf` query field and its
|
|
21
|
+
* answer no `asOf` / `newer`: a client reads them as optional.
|
|
22
|
+
*/
|
|
23
|
+
export interface Page<T> {
|
|
18
24
|
items: T[];
|
|
19
25
|
/** The page read, 1-based. */
|
|
20
26
|
page: number;
|
|
21
27
|
/** Rows per page: 20, 50 or 100. */
|
|
22
28
|
size: number;
|
|
23
|
-
/** The matching rows under the snapshot, at most {@link PAGED_TOTAL_CAP}. */
|
|
29
|
+
/** The matching rows (under the snapshot, when there is one), at most {@link PAGED_TOTAL_CAP}. */
|
|
24
30
|
total: number;
|
|
25
31
|
/** More rows match than `total` says. */
|
|
26
32
|
totalCapped: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** One page of a paged route on a snapshot (spec §2.3). */
|
|
35
|
+
export interface Paged<T> extends Page<T> {
|
|
27
36
|
/** The snapshot key: pass it back to read the other pages of the same snapshot. */
|
|
28
37
|
asOf: string;
|
|
29
38
|
/** Rows above `asOf` matching the filters, at most {@link PAGED_NEWER_CAP}; 0 without `asOf`. */
|
|
30
39
|
newer: number;
|
|
31
40
|
}
|
|
41
|
+
/** A {@link Page} from its rows, the query's `page` / `size` and a {@link cappedCount}. */
|
|
42
|
+
export declare function pageOf<T>(items: T[], q: {
|
|
43
|
+
page: number;
|
|
44
|
+
size: number;
|
|
45
|
+
}, counted: {
|
|
46
|
+
count: number;
|
|
47
|
+
capped: boolean;
|
|
48
|
+
}): Page<T>;
|
|
32
49
|
/**
|
|
33
50
|
* The query fields every paged route takes (spec §2.3), to `extend` a route's filters with. `asOf`
|
|
34
51
|
* is the route's own (its snapshot key format), e.g. {@link bigserialAsOf}.
|
|
@@ -39,6 +56,19 @@ export declare const PageQueryFields: {
|
|
|
39
56
|
};
|
|
40
57
|
/** An `asOf` that is a bigserial id (a decimal string), for append-only tables keyed by id. */
|
|
41
58
|
export declare function bigserialAsOf(what: string): z.ZodOptional<z.ZodString>;
|
|
59
|
+
/**
|
|
60
|
+
* An `asOf` that is a point in time (ISO 8601), for tables whose snapshot is not a row: rows that
|
|
61
|
+
* move up when used (conversations by last activity), or rows keyed by a time and a random id
|
|
62
|
+
* (eval runs). The first read takes it from {@link snapshotNow}; a page then lists the rows whose
|
|
63
|
+
* sort time is at or before it.
|
|
64
|
+
*/
|
|
65
|
+
export declare function timeAsOf(): z.ZodOptional<z.ZodISODateTime>;
|
|
66
|
+
/**
|
|
67
|
+
* The database's time now as a {@link timeAsOf} snapshot key: ISO 8601 in UTC with microseconds,
|
|
68
|
+
* as precise as a `timestamptz`, so a key compared back in SQL (`<= $1::timestamptz`) loses
|
|
69
|
+
* nothing. The database's clock, as the `now()` the rows were written with.
|
|
70
|
+
*/
|
|
71
|
+
export declare function snapshotNow(db: KernelSchemaDb): Promise<string>;
|
|
42
72
|
/** The last page a size may read: pages past the counting cap are refused. */
|
|
43
73
|
export declare const lastReadablePage: (size: number) => number;
|
|
44
74
|
/** Refuses a page past {@link lastReadablePage} (400 `validation_failed`, spec §2.3). */
|
|
@@ -5,7 +5,8 @@ import { ApiError } from "../../errors.js";
|
|
|
5
5
|
* Page-number reads on a snapshot (table pagination spec §2.3): a paged route takes `page`,
|
|
6
6
|
* `size`, its filters and an optional `asOf`, and answers {@link Paged}. Shared by every route a
|
|
7
7
|
* DataTable pages on the server; the snapshot key (`asOf`) is the route's own (an append-only
|
|
8
|
-
* table uses its id, a sortable table its `(sort column, id)`).
|
|
8
|
+
* table uses its id, a sortable table its `(sort column, id)`). A table whose rows are edited or
|
|
9
|
+
* deleted in place reads without a snapshot and answers {@link Page} (no `asOf`, no `newer`).
|
|
9
10
|
*/
|
|
10
11
|
/** The page sizes a table offers (the Pagination select). */
|
|
11
12
|
export const PAGE_SIZES = [20, 50, 100];
|
|
@@ -13,6 +14,16 @@ export const PAGE_SIZES = [20, 50, 100];
|
|
|
13
14
|
export const PAGED_TOTAL_CAP = 10_000;
|
|
14
15
|
/** `newer` stops counting here. */
|
|
15
16
|
export const PAGED_NEWER_CAP = 1_000;
|
|
17
|
+
/** A {@link Page} from its rows, the query's `page` / `size` and a {@link cappedCount}. */
|
|
18
|
+
export function pageOf(items, q, counted) {
|
|
19
|
+
return {
|
|
20
|
+
items,
|
|
21
|
+
page: q.page,
|
|
22
|
+
size: q.size,
|
|
23
|
+
total: counted.count,
|
|
24
|
+
totalCapped: counted.capped,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
16
27
|
/**
|
|
17
28
|
* The query fields every paged route takes (spec §2.3), to `extend` a route's filters with. `asOf`
|
|
18
29
|
* is the route's own (its snapshot key format), e.g. {@link bigserialAsOf}.
|
|
@@ -44,6 +55,32 @@ export function bigserialAsOf(what) {
|
|
|
44
55
|
.optional()
|
|
45
56
|
.describe(`The snapshot: the asOf an earlier page returned (${what}); absent: a new snapshot of the newest rows.`));
|
|
46
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* An `asOf` that is a point in time (ISO 8601), for tables whose snapshot is not a row: rows that
|
|
60
|
+
* move up when used (conversations by last activity), or rows keyed by a time and a random id
|
|
61
|
+
* (eval runs). The first read takes it from {@link snapshotNow}; a page then lists the rows whose
|
|
62
|
+
* sort time is at or before it.
|
|
63
|
+
*/
|
|
64
|
+
export function timeAsOf() {
|
|
65
|
+
return z.iso
|
|
66
|
+
.datetime({ offset: true })
|
|
67
|
+
.optional()
|
|
68
|
+
.describe("The snapshot: the asOf an earlier page returned (an ISO 8601 time); absent: a new snapshot.");
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The database's time now as a {@link timeAsOf} snapshot key: ISO 8601 in UTC with microseconds,
|
|
72
|
+
* as precise as a `timestamptz`, so a key compared back in SQL (`<= $1::timestamptz`) loses
|
|
73
|
+
* nothing. The database's clock, as the `now()` the rows were written with.
|
|
74
|
+
*/
|
|
75
|
+
export async function snapshotNow(db) {
|
|
76
|
+
const r = await sql `
|
|
77
|
+
SELECT to_char(now() AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.US"Z"') AS now
|
|
78
|
+
`.execute(db);
|
|
79
|
+
const now = r.rows[0]?.now;
|
|
80
|
+
if (now === undefined)
|
|
81
|
+
throw new Error("SELECT now() returned no row");
|
|
82
|
+
return now;
|
|
83
|
+
}
|
|
47
84
|
/** The last page a size may read: pages past the counting cap are refused. */
|
|
48
85
|
export const lastReadablePage = (size) => Math.ceil(PAGED_TOTAL_CAP / size);
|
|
49
86
|
/** Refuses a page past {@link lastReadablePage} (400 `validation_failed`, spec §2.3). */
|
|
@@ -4,10 +4,11 @@ import type { Account } from "../identity/accounts.js";
|
|
|
4
4
|
import { type Principal } from "../identity/principal.js";
|
|
5
5
|
import { SessionService } from "../identity/sessions.js";
|
|
6
6
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
7
|
+
import type { Page } from "../infra/paging/paged-read.js";
|
|
7
8
|
import { CredentialThrottler } from "../infra/throttler/credential-throttler.js";
|
|
8
|
-
import { type InvitableRole, type Invitation, type
|
|
9
|
+
import { type InvitableRole, type Invitation, InvitationsService, type InvitationView } from "./invitations.service.js";
|
|
9
10
|
import { type OrgContext } from "./org.guard.js";
|
|
10
|
-
import { InvitationCreateBody, InvitationIdParams } from "./orgs.schemas.js";
|
|
11
|
+
import { InvitationCreateBody, InvitationIdParams, InvitationListQuery } from "./orgs.schemas.js";
|
|
11
12
|
import type { OrgRole } from "./roles.js";
|
|
12
13
|
/** 组织邀请:组织内管理(`/api/v1/orgs/:orgId/invitations`)与凭令牌预览 / 接受(`/api/v1/invitations/:token`,公开)。 */
|
|
13
14
|
export declare class InvitationsController {
|
|
@@ -21,11 +22,7 @@ export declare class InvitationsController {
|
|
|
21
22
|
invitation: Invitation;
|
|
22
23
|
token: string;
|
|
23
24
|
}>;
|
|
24
|
-
list(org: OrgContext): Promise<
|
|
25
|
-
invitations: (Invitation & {
|
|
26
|
-
status: InvitationStatus;
|
|
27
|
-
})[];
|
|
28
|
-
}>;
|
|
25
|
+
list(org: OrgContext, q: z.infer<typeof InvitationListQuery>): Promise<Page<InvitationView>>;
|
|
29
26
|
revoke(principal: Principal, org: OrgContext, { id }: z.infer<typeof InvitationIdParams>): Promise<void>;
|
|
30
27
|
/** 公开预览:只给组织 id / 名称、角色与过期时间。 */
|
|
31
28
|
preview(token: string): Promise<{
|
|
@@ -18,14 +18,16 @@ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
|
18
18
|
import { CredentialThrottler } from "../infra/throttler/credential-throttler.js";
|
|
19
19
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
20
20
|
import { parseWithZod } from "../infra/validation/parse-with-zod.js";
|
|
21
|
-
import { ZBody, ZParam } from "../infra/validation/zod-params.js";
|
|
21
|
+
import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
|
|
22
22
|
import { InvitationsService, } from "./invitations.service.js";
|
|
23
23
|
import { CurrentOrg, OrgAction } from "./org.guard.js";
|
|
24
|
-
import { InvitationCreateBody, InvitationIdParams } from "./orgs.schemas.js";
|
|
24
|
+
import { InvitationCreateBody, InvitationIdParams, InvitationListQuery } from "./orgs.schemas.js";
|
|
25
25
|
class InvitationCreateBodyDto extends createZodDto(InvitationCreateBody, "InvitationCreateBody") {
|
|
26
26
|
}
|
|
27
27
|
class InvitationIdParamsDto extends createZodDto(InvitationIdParams, "InvitationIdParams") {
|
|
28
28
|
}
|
|
29
|
+
class InvitationListQueryDto extends createZodDto(InvitationListQuery, "InvitationListQuery") {
|
|
30
|
+
}
|
|
29
31
|
/** Validated inside the handler, after the attempt is reserved (a signed-in principal sends none). */
|
|
30
32
|
const SignupBody = z.object({
|
|
31
33
|
login: z.string(),
|
|
@@ -51,8 +53,8 @@ let InvitationsController = class InvitationsController {
|
|
|
51
53
|
const p = requireUser(principal);
|
|
52
54
|
return this.invitations.create(org.orgId, body, p.account.id, patTokenId(p));
|
|
53
55
|
}
|
|
54
|
-
async list(org) {
|
|
55
|
-
return
|
|
56
|
+
async list(org, q) {
|
|
57
|
+
return this.invitations.page(org.orgId, q);
|
|
56
58
|
}
|
|
57
59
|
async revoke(principal, org, { id }) {
|
|
58
60
|
const p = requireUser(principal);
|
|
@@ -102,7 +104,8 @@ __decorate([
|
|
|
102
104
|
__decorate([
|
|
103
105
|
Get("orgs/:orgId/invitations"),
|
|
104
106
|
OrgAction("org.invitations.manage"),
|
|
105
|
-
__param(0, CurrentOrg())
|
|
107
|
+
__param(0, CurrentOrg()),
|
|
108
|
+
__param(1, ZQuery(InvitationListQueryDto))
|
|
106
109
|
], InvitationsController.prototype, "list", null);
|
|
107
110
|
__decorate([
|
|
108
111
|
Delete("orgs/:orgId/invitations/:id"),
|
|
@@ -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: {
|
|
@@ -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"),
|
|
@@ -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
|
];
|