@company-semantics/contracts 9.0.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -3
- package/src/__tests__/resource-keys.test.ts +30 -23
- package/src/admin/authz-simulate.ts +4 -4
- package/src/admin/direct-grants.ts +2 -2
- package/src/api/generated-spec-hash.ts +2 -2
- package/src/api/generated.ts +97 -0
- package/src/api/http/routes/ai-chat.ts +3 -3
- package/src/api/http/utils/resource-response.ts +5 -2
- package/src/api/index.ts +4 -4
- package/src/api/primitives.ts +6 -2
- package/src/auth/README.md +1 -0
- package/src/auth/index.ts +12 -5
- package/src/autotune.ts +5 -1
- package/src/billing/index.ts +1 -1
- package/src/billing/types.ts +1 -1
- package/src/chat/README.md +3 -0
- package/src/chat/__tests__/runtime-profile.test.ts +68 -48
- package/src/chat/index.ts +10 -4
- package/src/chat/runtime-profile.ts +25 -10
- package/src/chat/schemas.ts +49 -41
- package/src/chat/types.ts +48 -42
- package/src/ci-envelope/README.md +2 -0
- package/src/ci-envelope/__tests__/transitions.test.ts +56 -56
- package/src/ci-envelope/index.ts +2 -2
- package/src/ci-envelope/types.ts +20 -20
- package/src/ci-results/index.ts +2 -2
- package/src/ci-results/repo-ci-result.ts +15 -12
- package/src/compatibility.ts +6 -6
- package/src/content/index.ts +10 -4
- package/src/content/schemas.ts +42 -24
- package/src/dispatch/index.ts +18 -15
- package/src/email/__tests__/registry.test.ts +81 -77
- package/src/email/index.ts +3 -3
- package/src/email/registry.ts +25 -25
- package/src/email/types.ts +43 -43
- package/src/errors/index.ts +8 -8
- package/src/execution/__tests__/events.test.ts +42 -42
- package/src/execution/__tests__/lifecycle.test.ts +192 -190
- package/src/execution/__tests__/registry.test.ts +114 -114
- package/src/execution/audit-export.ts +4 -4
- package/src/execution/errors.ts +7 -7
- package/src/execution/event-metadata.ts +4 -4
- package/src/execution/events.ts +23 -21
- package/src/execution/expiry.ts +5 -5
- package/src/execution/hash-chain.ts +2 -2
- package/src/execution/index.ts +19 -28
- package/src/execution/kinds.ts +7 -7
- package/src/execution/lifecycle.ts +33 -33
- package/src/execution/registry.ts +63 -63
- package/src/execution/schemas.ts +31 -23
- package/src/execution/status.ts +45 -26
- package/src/execution/summary.ts +16 -17
- package/src/execution/timeline-ui.ts +9 -9
- package/src/execution/types.ts +31 -25
- package/src/generated/openapi-routes.ts +2 -0
- package/src/guards/config.ts +22 -18
- package/src/guards/index.ts +4 -4
- package/src/guards/types.ts +32 -24
- package/src/identity/__tests__/avatar.test.ts +68 -59
- package/src/identity/avatar.ts +8 -8
- package/src/identity/display-name.ts +3 -3
- package/src/identity/index.ts +8 -8
- package/src/identity/people-org-chart.ts +8 -4
- package/src/identity/schemas.ts +28 -18
- package/src/identity/types.ts +5 -5
- package/src/impersonation/index.ts +5 -5
- package/src/impersonation/schemas.ts +15 -9
- package/src/impersonation-events.ts +21 -21
- package/src/impersonation.ts +25 -24
- package/src/index.ts +118 -90
- package/src/interfaces/mcp/tools/help.ts +19 -19
- package/src/internal-admin.ts +6 -6
- package/src/mcp/README.md +2 -0
- package/src/mcp/__tests__/capability-graph.test.ts +290 -290
- package/src/mcp/capability-graph.ts +42 -40
- package/src/mcp/failure-context.ts +1 -3
- package/src/mcp/index.ts +69 -56
- package/src/mcp/resources.ts +9 -9
- package/src/meetings/index.ts +2 -2
- package/src/meetings/schemas.ts +51 -34
- package/src/message-parts/README.md +2 -0
- package/src/message-parts/__tests__/builder.test.ts +142 -142
- package/src/message-parts/__tests__/confirmation.test.ts +100 -86
- package/src/message-parts/__tests__/preview.test.ts +63 -63
- package/src/message-parts/__tests__/wire.test.ts +130 -124
- package/src/message-parts/builder.ts +23 -23
- package/src/message-parts/confirmation.ts +17 -14
- package/src/message-parts/execution.ts +7 -7
- package/src/message-parts/index.ts +10 -10
- package/src/message-parts/lifecycle.ts +25 -25
- package/src/message-parts/preview.ts +30 -30
- package/src/message-parts/types.ts +27 -27
- package/src/message-parts/wire.ts +24 -24
- package/src/mutations.ts +2 -2
- package/src/observability.ts +23 -11
- package/src/org/__tests__/org-units.test.ts +131 -96
- package/src/org/__tests__/tree-ordering.test.ts +57 -37
- package/src/org/__tests__/view-scopes.test.ts +40 -40
- package/src/org/domain.ts +9 -9
- package/src/org/index.ts +31 -21
- package/src/org/org-units.ts +34 -20
- package/src/org/schemas.ts +261 -124
- package/src/org/sharing.ts +17 -13
- package/src/org/tree-ordering.ts +3 -1
- package/src/org/types.ts +54 -47
- package/src/org/view-scopes.ts +9 -9
- package/src/permissions/access-levels.ts +7 -2
- package/src/permissions/access-source.ts +6 -6
- package/src/permissions/index.ts +5 -5
- package/src/permissions/orgchart-roles.ts +7 -7
- package/src/permissions/permission-introspection.ts +7 -5
- package/src/permissions/share-api.ts +19 -9
- package/src/pressure.ts +4 -4
- package/src/queryIntent.ts +21 -21
- package/src/ralph/__tests__/prd-groups.test.ts +159 -159
- package/src/ralph/__tests__/prd.test.ts +30 -30
- package/src/ralph/index.ts +3 -8
- package/src/ralph/prd.ts +33 -33
- package/src/ralph/progress.ts +1 -1
- package/src/rate-limit/README.md +4 -4
- package/src/rate-limit/index.ts +3 -3
- package/src/requests.ts +36 -8
- package/src/resource-keys.ts +207 -124
- package/src/resource-registry.ts +5 -5
- package/src/route-builder.ts +3 -3
- package/src/safe-mode.ts +2 -2
- package/src/security/index.ts +4 -4
- package/src/security/org-secrets.ts +13 -9
- package/src/security/secret.ts +3 -3
- package/src/sse.ts +3 -1
- package/src/system/README.md +3 -0
- package/src/system/capabilities.ts +22 -23
- package/src/system/diagram.ts +45 -45
- package/src/system/index.ts +14 -14
- package/src/tiers.ts +1 -1
- package/src/timeouts.ts +1 -1
- package/src/tracing.ts +30 -30
- package/src/types/analytics.ts +2 -2
- package/src/usage/README.md +3 -0
- package/src/usage/execution-types.ts +69 -69
- package/src/usage/types.ts +7 -3
package/src/org/sharing.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Document access level.
|
|
3
3
|
* Privilege order: editor > commenter > viewer.
|
|
4
4
|
*/
|
|
5
|
-
export type AccessLevel =
|
|
5
|
+
export type AccessLevel = "viewer" | "commenter" | "editor";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Document sharing policy.
|
|
@@ -11,10 +11,14 @@ export type AccessLevel = 'viewer' | 'commenter' | 'editor';
|
|
|
11
11
|
* - org_comment: All org members can comment
|
|
12
12
|
* - org_edit: All org members can edit (does NOT imply canShare)
|
|
13
13
|
*/
|
|
14
|
-
export type SharePolicy =
|
|
14
|
+
export type SharePolicy =
|
|
15
|
+
| "restricted"
|
|
16
|
+
| "org_read"
|
|
17
|
+
| "org_comment"
|
|
18
|
+
| "org_edit";
|
|
15
19
|
|
|
16
20
|
export interface AclEntry {
|
|
17
|
-
readonly principalType:
|
|
21
|
+
readonly principalType: "user" | "unit";
|
|
18
22
|
readonly principalId: string;
|
|
19
23
|
readonly principalName: string;
|
|
20
24
|
readonly accessLevel: AccessLevel;
|
|
@@ -32,12 +36,12 @@ export interface AclEntry {
|
|
|
32
36
|
* `org_unit_authority_grants` table and carry an explicit scope set.
|
|
33
37
|
*/
|
|
34
38
|
export type AccessSource =
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
39
|
+
| "org_rbac"
|
|
40
|
+
| "sharing_policy"
|
|
41
|
+
| "unit_baseline"
|
|
42
|
+
| "unit_delegation"
|
|
43
|
+
| "acl_grant"
|
|
44
|
+
| "doc_ownership";
|
|
41
45
|
|
|
42
46
|
export interface AccessReason {
|
|
43
47
|
readonly source: AccessSource;
|
|
@@ -55,7 +59,7 @@ export interface AccessReason {
|
|
|
55
59
|
* - Unit membership grants baseline access ONLY to resources owned by that unit.
|
|
56
60
|
*/
|
|
57
61
|
export interface EffectiveAccess {
|
|
58
|
-
readonly level:
|
|
62
|
+
readonly level: "none" | AccessLevel;
|
|
59
63
|
readonly reasons: ReadonlyArray<AccessReason>;
|
|
60
64
|
readonly canShare: boolean;
|
|
61
65
|
}
|
|
@@ -94,11 +98,11 @@ export interface ShareState {
|
|
|
94
98
|
* Used by audit views to display a history of permission changes.
|
|
95
99
|
*/
|
|
96
100
|
export interface PermissionAuditEntry {
|
|
97
|
-
readonly action:
|
|
98
|
-
readonly resourceType:
|
|
101
|
+
readonly action: "granted" | "revoked" | "updated";
|
|
102
|
+
readonly resourceType: "goals_doc" | "unit";
|
|
99
103
|
readonly resourceId: string;
|
|
100
104
|
readonly resourceName: string;
|
|
101
|
-
readonly principalType:
|
|
105
|
+
readonly principalType: "user" | "unit";
|
|
102
106
|
readonly principalId: string;
|
|
103
107
|
readonly principalName: string;
|
|
104
108
|
readonly detail: string;
|
package/src/org/tree-ordering.ts
CHANGED
|
@@ -33,7 +33,9 @@ export interface TreeOrderableNode {
|
|
|
33
33
|
orderKey: string;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export function orderTreeNodes<T extends TreeOrderableNode>(
|
|
36
|
+
export function orderTreeNodes<T extends TreeOrderableNode>(
|
|
37
|
+
nodes: readonly T[],
|
|
38
|
+
): T[] {
|
|
37
39
|
const byParent = new Map<string | null, T[]>();
|
|
38
40
|
for (const node of nodes) {
|
|
39
41
|
const bucket = byParent.get(node.parentId) ?? [];
|
package/src/org/types.ts
CHANGED
|
@@ -5,21 +5,21 @@
|
|
|
5
5
|
* @see ADR-BE-XXX (Personal vs Shared Organization Model)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { OrgChartRole } from
|
|
8
|
+
import type { OrgChartRole } from "../permissions/orgchart-roles";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Organization type distinguishes personal workspaces from shared organizations.
|
|
12
12
|
* - 'personal': Single-user workspace, owned by creator, claimable
|
|
13
13
|
* - 'shared': Multi-user organization, owned by one user, not claimable
|
|
14
14
|
*/
|
|
15
|
-
export type OrgType =
|
|
15
|
+
export type OrgType = "personal" | "shared";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Execution scope determines whose identity is used when executing actions.
|
|
19
19
|
* - 'self': Actions execute under the connecting user's identity only
|
|
20
20
|
* - 'org': Actions execute on behalf of the organization (shared access)
|
|
21
21
|
*/
|
|
22
|
-
export type ExecutionScope =
|
|
22
|
+
export type ExecutionScope = "self" | "org";
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Public organization information suitable for API responses.
|
|
@@ -55,7 +55,6 @@ export interface OwnershipTransferStatus {
|
|
|
55
55
|
// @see ADR-CONT-030 for design rationale
|
|
56
56
|
// =============================================================================
|
|
57
57
|
|
|
58
|
-
|
|
59
58
|
/**
|
|
60
59
|
* Workspace overview for the control plane UI.
|
|
61
60
|
* Read-only projection of organization state.
|
|
@@ -87,14 +86,14 @@ export interface WorkspaceMemberUnitSummary {
|
|
|
87
86
|
unitName: string;
|
|
88
87
|
/** Human-readable path from the OrgUnit tree (e.g. "Sales / Enterprise"). */
|
|
89
88
|
unitPath: string;
|
|
90
|
-
role:
|
|
89
|
+
role: "owner" | "manager" | "member";
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
/**
|
|
94
93
|
* Invite status for a workspace member row. `null` for members that have no
|
|
95
94
|
* associated invite record (joined pre-invite system).
|
|
96
95
|
*/
|
|
97
|
-
export type WorkspaceMemberInviteStatus =
|
|
96
|
+
export type WorkspaceMemberInviteStatus = "active" | "pending" | "expired";
|
|
98
97
|
|
|
99
98
|
/**
|
|
100
99
|
* Workspace member types. Inferred from their Zod schemas in `./schemas`
|
|
@@ -103,7 +102,7 @@ export type WorkspaceMemberInviteStatus = 'active' | 'pending' | 'expired';
|
|
|
103
102
|
* the field-level documentation; do not reintroduce a parallel interface (it
|
|
104
103
|
* was the cause of the `manages`/`avatarUrl` drift — see ADR-CTRL-112).
|
|
105
104
|
*/
|
|
106
|
-
export type { WorkspaceMember, WorkspaceMemberDetail } from
|
|
105
|
+
export type { WorkspaceMember, WorkspaceMemberDetail } from "./schemas";
|
|
107
106
|
|
|
108
107
|
/**
|
|
109
108
|
* Recent audit action attached to a member-detail response.
|
|
@@ -116,14 +115,13 @@ export interface MemberRecentAction {
|
|
|
116
115
|
summary: string;
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
|
|
120
118
|
/**
|
|
121
119
|
* Entry in the RBAC roles catalog (GET /api/rbac/roles).
|
|
122
120
|
*/
|
|
123
121
|
export interface RoleCatalogEntry {
|
|
124
122
|
/** Canonical role name, e.g. 'org_owner'. */
|
|
125
123
|
name: string;
|
|
126
|
-
type:
|
|
124
|
+
type: "system" | "custom";
|
|
127
125
|
/** One-line description sourced from system-roles.ts (or org-provided for custom). */
|
|
128
126
|
description: string;
|
|
129
127
|
/** Scope patterns granted by this role. May contain wildcards (e.g. 'org.view_*'). */
|
|
@@ -194,7 +192,8 @@ export interface SsoOperationalState {
|
|
|
194
192
|
* SECURITY INVARIANT: Never return actual client ID or client secret values.
|
|
195
193
|
* Only boolean indicators (hasClientId, hasClientSecret) are safe to expose.
|
|
196
194
|
*/
|
|
197
|
-
export interface SsoSetupInfo
|
|
195
|
+
export interface SsoSetupInfo
|
|
196
|
+
extends SsoDiscoveryConfig, SsoCredentialStatus, SsoOperationalState {}
|
|
198
197
|
|
|
199
198
|
/**
|
|
200
199
|
* Individual readiness check for SSO activation.
|
|
@@ -244,17 +243,17 @@ export interface SsoEnforcementStatus {
|
|
|
244
243
|
* Any state → NOT_CONFIGURED (on credential removal or provider switch)
|
|
245
244
|
*/
|
|
246
245
|
export type ProviderStatus =
|
|
247
|
-
|
|
|
248
|
-
|
|
|
249
|
-
|
|
|
250
|
-
|
|
|
251
|
-
|
|
|
246
|
+
| "NOT_CONFIGURED"
|
|
247
|
+
| "CONFIG_SAVED"
|
|
248
|
+
| "CONFIG_VALID"
|
|
249
|
+
| "TEST_SUCCESS"
|
|
250
|
+
| "ENABLED";
|
|
252
251
|
|
|
253
252
|
/** Workspace SSO state derived from provider status + policy. */
|
|
254
|
-
export type WorkspaceSsoState =
|
|
253
|
+
export type WorkspaceSsoState = "SSO_DISABLED" | "SSO_ENABLED" | "SSO_ENFORCED";
|
|
255
254
|
|
|
256
255
|
/** Backend-authoritative stepper step. Frontend MUST NOT re-derive. */
|
|
257
|
-
export type SsoStepperStep =
|
|
256
|
+
export type SsoStepperStep = "configure" | "test" | "enable" | "enforce";
|
|
258
257
|
|
|
259
258
|
/** Owner identity information for the SSO readiness surface. */
|
|
260
259
|
export interface OwnerIdentityInfo {
|
|
@@ -272,7 +271,11 @@ export interface OidcValidationResult {
|
|
|
272
271
|
issuer?: string;
|
|
273
272
|
authorizationEndpoint?: string;
|
|
274
273
|
error?: string;
|
|
275
|
-
errorCode?:
|
|
274
|
+
errorCode?:
|
|
275
|
+
| "UNREACHABLE"
|
|
276
|
+
| "INVALID_DOCUMENT"
|
|
277
|
+
| "MISSING_FIELDS"
|
|
278
|
+
| "SSRF_BLOCKED";
|
|
276
279
|
}
|
|
277
280
|
|
|
278
281
|
/** Initiation payload for a test SSO login attempt. */
|
|
@@ -283,17 +286,21 @@ export interface TestSsoInitiation {
|
|
|
283
286
|
|
|
284
287
|
/** Result of a test SSO login attempt. */
|
|
285
288
|
export interface TestSsoResult {
|
|
286
|
-
status:
|
|
289
|
+
status: "pending" | "success" | "failed" | "expired";
|
|
287
290
|
claims?: { sub: string; email?: string; name?: string; issuer: string };
|
|
288
291
|
identityLinked?: boolean;
|
|
289
292
|
error?: string;
|
|
290
|
-
errorCode?:
|
|
293
|
+
errorCode?:
|
|
294
|
+
| "IDENTITY_CONFLICT"
|
|
295
|
+
| "DOMAIN_MISMATCH"
|
|
296
|
+
| "ISSUER_MISMATCH"
|
|
297
|
+
| "CALLBACK_ERROR";
|
|
291
298
|
}
|
|
292
299
|
|
|
293
300
|
/** MX-based provider suggestion for SSO setup. */
|
|
294
301
|
export interface ProviderSuggestion {
|
|
295
|
-
suggestedProvider:
|
|
296
|
-
confidence:
|
|
302
|
+
suggestedProvider: "google" | "microsoft" | null;
|
|
303
|
+
confidence: "high" | "low";
|
|
297
304
|
reason: string;
|
|
298
305
|
/** The verified domain that triggered the suggestion (for pre-filling provider inputs). */
|
|
299
306
|
detectedDomain?: string;
|
|
@@ -354,7 +361,7 @@ export interface WorkspaceAuditEvent {
|
|
|
354
361
|
actor: {
|
|
355
362
|
id: string;
|
|
356
363
|
name: string;
|
|
357
|
-
type:
|
|
364
|
+
type: "user" | "system";
|
|
358
365
|
};
|
|
359
366
|
action: string;
|
|
360
367
|
summary: string;
|
|
@@ -368,7 +375,7 @@ export interface WorkspaceAuditEvent {
|
|
|
368
375
|
/**
|
|
369
376
|
* Status of an organization invite.
|
|
370
377
|
*/
|
|
371
|
-
export type OrgInviteStatus =
|
|
378
|
+
export type OrgInviteStatus = "pending" | "accepted" | "expired" | "revoked";
|
|
372
379
|
|
|
373
380
|
/**
|
|
374
381
|
* Organization invite for the workspace invites list.
|
|
@@ -379,7 +386,7 @@ export interface OrgInvite {
|
|
|
379
386
|
orgId: string;
|
|
380
387
|
email: string;
|
|
381
388
|
/** Invite role — invites only grant the restricted {admin, member} domain. */
|
|
382
|
-
role:
|
|
389
|
+
role: "admin" | "member";
|
|
383
390
|
invitedBy: {
|
|
384
391
|
id: string;
|
|
385
392
|
name: string;
|
|
@@ -395,7 +402,7 @@ export interface OrgInvite {
|
|
|
395
402
|
*/
|
|
396
403
|
export interface CreateInviteRequest {
|
|
397
404
|
email: string;
|
|
398
|
-
role:
|
|
405
|
+
role: "admin" | "member";
|
|
399
406
|
}
|
|
400
407
|
|
|
401
408
|
/**
|
|
@@ -417,7 +424,7 @@ export interface RemoveMemberRequest {
|
|
|
417
424
|
*/
|
|
418
425
|
export interface ChangeMemberRoleRequest {
|
|
419
426
|
memberId: string;
|
|
420
|
-
newRole:
|
|
427
|
+
newRole: "admin" | "member";
|
|
421
428
|
}
|
|
422
429
|
|
|
423
430
|
/**
|
|
@@ -478,20 +485,20 @@ export interface UpdateAuthPolicyRequest {
|
|
|
478
485
|
*/
|
|
479
486
|
export type Phase3AuditAction =
|
|
480
487
|
// Invite lifecycle
|
|
481
|
-
|
|
|
482
|
-
|
|
|
483
|
-
|
|
|
484
|
-
|
|
|
488
|
+
| "org.member.invited"
|
|
489
|
+
| "org.member.joined"
|
|
490
|
+
| "org.invite.revoked"
|
|
491
|
+
| "org.invite.expired"
|
|
485
492
|
// Member mutations
|
|
486
|
-
|
|
|
487
|
-
|
|
|
493
|
+
| "org.member.removed"
|
|
494
|
+
| "org.member.role_changed"
|
|
488
495
|
// Organization transition
|
|
489
|
-
|
|
|
496
|
+
| "org.type_transition"
|
|
490
497
|
// Integration scope changes
|
|
491
|
-
|
|
|
492
|
-
|
|
|
498
|
+
| "integration.scope_promoted"
|
|
499
|
+
| "integration.scope_demoted"
|
|
493
500
|
// Auth policy
|
|
494
|
-
|
|
|
501
|
+
| "org.auth_policy.updated";
|
|
495
502
|
|
|
496
503
|
// =============================================================================
|
|
497
504
|
// Multi-Org Membership Types (Phase 4)
|
|
@@ -583,7 +590,7 @@ export interface OrgScopedContext {
|
|
|
583
590
|
* - 'info': Read-only surface, any member, org.view_* capabilities
|
|
584
591
|
* - 'settings': Admin surface, org.manage_* capabilities
|
|
585
592
|
*/
|
|
586
|
-
export type WorkspaceSurface =
|
|
593
|
+
export type WorkspaceSurface = "info" | "settings";
|
|
587
594
|
|
|
588
595
|
/**
|
|
589
596
|
* Read-only workspace overview for the Info surface.
|
|
@@ -655,10 +662,10 @@ export interface TransferAcceptanceView {
|
|
|
655
662
|
|
|
656
663
|
/** Responsibility checklist items shown on the acceptance page. */
|
|
657
664
|
export const TRANSFER_RESPONSIBILITIES = [
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
665
|
+
"You will become the sole owner of this workspace",
|
|
666
|
+
"You will be responsible for billing and compliance",
|
|
667
|
+
"The current owner will be downgraded to admin",
|
|
668
|
+
"This action cannot be undone without a new transfer",
|
|
662
669
|
] as const;
|
|
663
670
|
|
|
664
671
|
export type TransferResponsibility = (typeof TRANSFER_RESPONSIBILITIES)[number];
|
|
@@ -669,12 +676,12 @@ export type TransferResponsibility = (typeof TRANSFER_RESPONSIBILITIES)[number];
|
|
|
669
676
|
// =============================================================================
|
|
670
677
|
|
|
671
678
|
/** Identity Trust Level — org's identity posture */
|
|
672
|
-
export type IdentityTrustLevel =
|
|
679
|
+
export type IdentityTrustLevel = "ITL_0" | "ITL_1" | "ITL_2";
|
|
673
680
|
|
|
674
681
|
export const IDENTITY_TRUST_LEVEL_LABELS: Record<IdentityTrustLevel, string> = {
|
|
675
|
-
ITL_0:
|
|
676
|
-
ITL_1:
|
|
677
|
-
ITL_2:
|
|
682
|
+
ITL_0: "No verified domains",
|
|
683
|
+
ITL_1: "Domain verified",
|
|
684
|
+
ITL_2: "SSO enforced",
|
|
678
685
|
} as const;
|
|
679
686
|
|
|
680
687
|
/** Transfer eligibility result with ITL context */
|
|
@@ -701,7 +708,7 @@ export interface TransferMemberEligibility {
|
|
|
701
708
|
/**
|
|
702
709
|
* Status of an integration request from a member.
|
|
703
710
|
*/
|
|
704
|
-
export type IntegrationRequestStatus =
|
|
711
|
+
export type IntegrationRequestStatus = "pending" | "approved" | "denied";
|
|
705
712
|
|
|
706
713
|
/**
|
|
707
714
|
* Advisory integration request created by a member.
|
package/src/org/view-scopes.ts
CHANGED
|
@@ -17,19 +17,19 @@
|
|
|
17
17
|
*/
|
|
18
18
|
export const VIEW_SCOPE_MAP = {
|
|
19
19
|
// Protected views (require specific scope)
|
|
20
|
-
workspace:
|
|
21
|
-
timeline:
|
|
22
|
-
teamwork:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
teams:
|
|
26
|
-
|
|
20
|
+
workspace: "org.view_workspace",
|
|
21
|
+
timeline: "org.view_timeline",
|
|
22
|
+
teamwork: "org.view_teamwork",
|
|
23
|
+
"teamwork-member": "org.view_teamwork",
|
|
24
|
+
"company-md": "org.view_company_md",
|
|
25
|
+
teams: "org.view_teams",
|
|
26
|
+
"internal-admin": "internal.view_admin",
|
|
27
27
|
// Public views (require only authentication)
|
|
28
28
|
chat: null,
|
|
29
29
|
settings: null,
|
|
30
30
|
chats: null,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
"my-work": null,
|
|
32
|
+
"user-md": null,
|
|
33
33
|
upgrade: null,
|
|
34
34
|
} as const;
|
|
35
35
|
|
|
@@ -10,9 +10,14 @@
|
|
|
10
10
|
*
|
|
11
11
|
* The commenter level is currently a stub — see ADR-CTRL-087.
|
|
12
12
|
*/
|
|
13
|
-
import { z } from
|
|
13
|
+
import { z } from "zod";
|
|
14
14
|
|
|
15
|
-
export const ACCESS_LEVELS = [
|
|
15
|
+
export const ACCESS_LEVELS = [
|
|
16
|
+
"owner",
|
|
17
|
+
"editor",
|
|
18
|
+
"commenter",
|
|
19
|
+
"viewer",
|
|
20
|
+
] as const;
|
|
16
21
|
export type AccessLevel = (typeof ACCESS_LEVELS)[number];
|
|
17
22
|
|
|
18
23
|
export const AccessLevelSchema = z.enum(ACCESS_LEVELS);
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
* - `inheritance` — org-chart-membership-based unit walk
|
|
15
15
|
* - `migration` — one-shot backfill from legacy systems (AUTH-004)
|
|
16
16
|
*/
|
|
17
|
-
import { z } from
|
|
17
|
+
import { z } from "zod";
|
|
18
18
|
|
|
19
19
|
export const ACCESS_SOURCES = [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
"explicit",
|
|
21
|
+
"ownership",
|
|
22
|
+
"visibility",
|
|
23
|
+
"inheritance",
|
|
24
|
+
"migration",
|
|
25
25
|
] as const;
|
|
26
26
|
export type AccessSource = (typeof ACCESS_SOURCES)[number];
|
|
27
27
|
|
package/src/permissions/index.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Re-exports the three canonical enums introduced in AUTH-001 (PRD-00669).
|
|
5
5
|
* Import from '@company-semantics/contracts' (root).
|
|
6
6
|
*/
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
7
|
+
export * from "./access-levels";
|
|
8
|
+
export * from "./orgchart-roles";
|
|
9
|
+
export * from "./access-source";
|
|
10
|
+
export * from "./share-api";
|
|
11
|
+
export * from "./permission-introspection";
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
* remains a separate, orthogonal axis — it is an INPUT to authority
|
|
21
21
|
* resolution, not the derived policy role.
|
|
22
22
|
*/
|
|
23
|
-
import { z } from
|
|
23
|
+
import { z } from "zod";
|
|
24
24
|
|
|
25
|
-
export const ORG_CHART_ROLES = [
|
|
25
|
+
export const ORG_CHART_ROLES = ["ceo", "leader", "delegate", "admin"] as const;
|
|
26
26
|
export type OrgChartRole = (typeof ORG_CHART_ROLES)[number];
|
|
27
27
|
|
|
28
28
|
export const OrgChartRoleSchema = z.enum(ORG_CHART_ROLES);
|
|
@@ -32,13 +32,13 @@ export const OrgChartRoleSchema = z.enum(ORG_CHART_ROLES);
|
|
|
32
32
|
* org-chart standing) renders as "Member" via {@link orgChartRoleLabel}.
|
|
33
33
|
*/
|
|
34
34
|
export const ORG_CHART_ROLE_LABELS: Record<OrgChartRole, string> = {
|
|
35
|
-
ceo:
|
|
36
|
-
leader:
|
|
37
|
-
delegate:
|
|
38
|
-
admin:
|
|
35
|
+
ceo: "CEO",
|
|
36
|
+
leader: "Leader",
|
|
37
|
+
delegate: "Delegate",
|
|
38
|
+
admin: "Admin",
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
/** Display label for a (possibly null) org-chart role; `null` = plain member. */
|
|
42
42
|
export function orgChartRoleLabel(role: OrgChartRole | null): string {
|
|
43
|
-
return role === null ?
|
|
43
|
+
return role === null ? "Member" : ORG_CHART_ROLE_LABELS[role];
|
|
44
44
|
}
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
* flow verbatim to the UI. The schema mirrors what the evaluator records into
|
|
18
18
|
* permission_decisions; the UI never re-derives.
|
|
19
19
|
*/
|
|
20
|
-
import { z } from
|
|
21
|
-
import { AccessLevelSchema } from
|
|
22
|
-
import { AccessSourceSchema } from
|
|
23
|
-
import { PrincipalSchema } from
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
import { AccessLevelSchema } from "./access-levels";
|
|
22
|
+
import { AccessSourceSchema } from "./access-source";
|
|
23
|
+
import { PrincipalSchema } from "./share-api";
|
|
24
24
|
|
|
25
25
|
// ---------------------------------------------------------------------------
|
|
26
26
|
// WhoCanAccess — every principal with effective access to an entity.
|
|
@@ -60,7 +60,9 @@ export const RecentDecisionsResponseSchema = z.object({
|
|
|
60
60
|
entity_id: z.string().uuid(),
|
|
61
61
|
rows: z.array(RecentDecisionSchema),
|
|
62
62
|
});
|
|
63
|
-
export type RecentDecisionsResponse = z.infer<
|
|
63
|
+
export type RecentDecisionsResponse = z.infer<
|
|
64
|
+
typeof RecentDecisionsResponseSchema
|
|
65
|
+
>;
|
|
64
66
|
|
|
65
67
|
export const RecentDecisionsQuerySchema = z.object({
|
|
66
68
|
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
* Authority: ADR-CTRL-085 (Rights Table), ADR-CTRL-086 (most-permissive
|
|
10
10
|
* aggregation), ADR-BE-181 (AUTH-006 compose model).
|
|
11
11
|
*/
|
|
12
|
-
import { z } from
|
|
13
|
-
import { AccessLevelSchema } from
|
|
14
|
-
import { AccessSourceSchema } from
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { AccessLevelSchema } from "./access-levels";
|
|
14
|
+
import { AccessSourceSchema } from "./access-source";
|
|
15
15
|
|
|
16
|
-
export const PrincipalTypeSchema = z.enum([
|
|
16
|
+
export const PrincipalTypeSchema = z.enum(["user", "unit", "org"]);
|
|
17
17
|
export type PrincipalType = z.infer<typeof PrincipalTypeSchema>;
|
|
18
18
|
|
|
19
19
|
export const PrincipalSchema = z.object({
|
|
@@ -22,10 +22,14 @@ export const PrincipalSchema = z.object({
|
|
|
22
22
|
});
|
|
23
23
|
export type Principal = z.infer<typeof PrincipalSchema>;
|
|
24
24
|
|
|
25
|
-
export const GrantableAccessLevelSchema = z.enum([
|
|
25
|
+
export const GrantableAccessLevelSchema = z.enum([
|
|
26
|
+
"editor",
|
|
27
|
+
"commenter",
|
|
28
|
+
"viewer",
|
|
29
|
+
]);
|
|
26
30
|
export type GrantableAccessLevel = z.infer<typeof GrantableAccessLevelSchema>;
|
|
27
31
|
|
|
28
|
-
export const EntityVisibilitySchema = z.enum([
|
|
32
|
+
export const EntityVisibilitySchema = z.enum(["private", "unit", "org"]);
|
|
29
33
|
export type EntityVisibility = z.infer<typeof EntityVisibilitySchema>;
|
|
30
34
|
|
|
31
35
|
export const AclGrantRequestSchema = z.object({
|
|
@@ -55,7 +59,9 @@ export type AclListResponse = z.infer<typeof AclListResponseSchema>;
|
|
|
55
59
|
export const VisibilityPatchRequestSchema = z.object({
|
|
56
60
|
tier: EntityVisibilitySchema,
|
|
57
61
|
});
|
|
58
|
-
export type VisibilityPatchRequest = z.infer<
|
|
62
|
+
export type VisibilityPatchRequest = z.infer<
|
|
63
|
+
typeof VisibilityPatchRequestSchema
|
|
64
|
+
>;
|
|
59
65
|
|
|
60
66
|
export const OwnerTransferRequestSchema = z.object({
|
|
61
67
|
new_owner_user_id: z.string().uuid(),
|
|
@@ -65,10 +71,14 @@ export type OwnerTransferRequest = z.infer<typeof OwnerTransferRequestSchema>;
|
|
|
65
71
|
export const EffectiveAccessRequestSchema = z.object({
|
|
66
72
|
principal: PrincipalSchema,
|
|
67
73
|
});
|
|
68
|
-
export type EffectiveAccessRequest = z.infer<
|
|
74
|
+
export type EffectiveAccessRequest = z.infer<
|
|
75
|
+
typeof EffectiveAccessRequestSchema
|
|
76
|
+
>;
|
|
69
77
|
|
|
70
78
|
export const EffectiveAccessResponseSchema = z.object({
|
|
71
79
|
access_level: AccessLevelSchema.nullable(),
|
|
72
80
|
source_chain: z.array(AccessSourceSchema),
|
|
73
81
|
});
|
|
74
|
-
export type EffectiveAccessResponse = z.infer<
|
|
82
|
+
export type EffectiveAccessResponse = z.infer<
|
|
83
|
+
typeof EffectiveAccessResponseSchema
|
|
84
|
+
>;
|
package/src/pressure.ts
CHANGED
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
* Canonical response header used to signal system pressure to clients.
|
|
19
19
|
* Frontend imports this to avoid stringly-typed header lookups.
|
|
20
20
|
*/
|
|
21
|
-
export const SYSTEM_PRESSURE_HEADER =
|
|
21
|
+
export const SYSTEM_PRESSURE_HEADER = "X-System-Pressure";
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Values carried on the `X-System-Pressure` header. `degraded` indicates the
|
|
25
25
|
* backend is actively shedding P3 traffic; `normal` indicates the controller
|
|
26
26
|
* is quiescent.
|
|
27
27
|
*/
|
|
28
|
-
export type SystemPressureValue =
|
|
28
|
+
export type SystemPressureValue = "normal" | "degraded";
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Heap-utilisation ratio above which the load-shed controller begins
|
|
@@ -51,7 +51,7 @@ export const CLEAR_HOLDDOWN_MS = 30_000;
|
|
|
51
51
|
* `retryAfter` mirrors the `Retry-After` header value (seconds).
|
|
52
52
|
*/
|
|
53
53
|
export type ShedResponse = {
|
|
54
|
-
error:
|
|
54
|
+
error: "tenant_quota_shed";
|
|
55
55
|
retryAfter: number;
|
|
56
|
-
reason:
|
|
56
|
+
reason: "heap_pressure" | "queue_depth";
|
|
57
57
|
};
|
package/src/queryIntent.ts
CHANGED
|
@@ -19,24 +19,24 @@
|
|
|
19
19
|
* authority for the intent set itself.
|
|
20
20
|
*/
|
|
21
21
|
export type QueryIntent =
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
22
|
+
| "me.read"
|
|
23
|
+
| "workspace.read"
|
|
24
|
+
| "workspace.write"
|
|
25
|
+
| "company-md.tree.read"
|
|
26
|
+
| "company-md.doc.read"
|
|
27
|
+
| "company-md.doc.write"
|
|
28
|
+
| "company-md.settings.read"
|
|
29
|
+
| "company-md.settings.write"
|
|
30
|
+
| "chats.events"
|
|
31
|
+
| "chats.write"
|
|
32
|
+
| "billing.read"
|
|
33
|
+
| "ai-usage.read"
|
|
34
|
+
| "audit.read"
|
|
35
|
+
| "invites.read"
|
|
36
|
+
| "invites.write"
|
|
37
|
+
| "integrations.status.read"
|
|
38
|
+
| "org.transfer.status.read"
|
|
39
|
+
| "org.deletion.eligibility.read"
|
|
40
|
+
| "user.preferences.read"
|
|
41
|
+
| "user.preferences.write"
|
|
42
|
+
| "admin.impersonate.events";
|