@company-semantics/contracts 0.102.1 → 0.103.1
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 +8 -3
- package/src/api/README.md +20 -2
- package/src/api/generated.ts +7118 -0
- package/src/api/index.ts +9 -0
- package/src/generated/openapi-routes.ts +92 -0
- package/src/index.ts +7 -0
- package/src/resource-keys.ts +39 -9
package/src/api/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Types Barrel
|
|
3
|
+
*
|
|
4
|
+
* Re-exports OpenAPI-generated types from the backend spec.
|
|
5
|
+
* Import from '@company-semantics/contracts' (root).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// OpenAPI generated types (from openapi/backend.yaml)
|
|
9
|
+
export type { paths, components, operations } from './generated'
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// AUTO-GENERATED — do not edit manually
|
|
2
|
+
// Generated from openapi/backend.yaml by scripts/generate-openapi-routes.ts
|
|
3
|
+
|
|
4
|
+
export const openApiRoutes = {
|
|
5
|
+
'/ai/chat': ['POST'],
|
|
6
|
+
'/api/account/cancel-deletion': ['POST'],
|
|
7
|
+
'/api/account/delete': ['POST'],
|
|
8
|
+
'/api/account/sessions': ['GET'],
|
|
9
|
+
'/api/account/sessions/{sessionId}': ['DELETE'],
|
|
10
|
+
'/api/capabilities/tools': ['GET'],
|
|
11
|
+
'/api/chats': ['GET', 'POST'],
|
|
12
|
+
'/api/chats/events': ['GET'],
|
|
13
|
+
'/api/chats/{chatId}/shares': ['GET', 'POST'],
|
|
14
|
+
'/api/chats/{id}': ['DELETE', 'GET', 'PATCH'],
|
|
15
|
+
'/api/chats/{id}/generate-title': ['POST'],
|
|
16
|
+
'/api/chats/{id}/messages': ['POST'],
|
|
17
|
+
'/api/chats/{id}/pin': ['DELETE', 'POST'],
|
|
18
|
+
'/api/departments': ['GET', 'POST'],
|
|
19
|
+
'/api/departments/{id}': ['DELETE', 'GET', 'PATCH'],
|
|
20
|
+
'/api/departments/{id}/members': ['POST'],
|
|
21
|
+
'/api/departments/{id}/members/{userId}': ['DELETE'],
|
|
22
|
+
'/api/drive/files': ['GET'],
|
|
23
|
+
'/api/drive/files/recent': ['GET'],
|
|
24
|
+
'/api/drive/files/{fileId}/content': ['GET'],
|
|
25
|
+
'/api/executions': ['GET', 'POST'],
|
|
26
|
+
'/api/executions/{executionId}/explanation': ['GET'],
|
|
27
|
+
'/api/executions/{executionId}/summary': ['GET'],
|
|
28
|
+
'/api/executions/{executionId}/timeline': ['GET'],
|
|
29
|
+
'/api/goals/docs/{slug}': ['GET'],
|
|
30
|
+
'/api/goals/docs/{slug}/content': ['PUT'],
|
|
31
|
+
'/api/goals/docs/{slug}/sharing': ['GET'],
|
|
32
|
+
'/api/goals/docs/{slug}/sharing/acl': ['POST'],
|
|
33
|
+
'/api/goals/docs/{slug}/sharing/acl/{aclId}': ['DELETE', 'PUT'],
|
|
34
|
+
'/api/goals/docs/{slug}/sharing/policy': ['PUT'],
|
|
35
|
+
'/api/goals/docs/{slug}/title': ['PUT'],
|
|
36
|
+
'/api/goals/extract': ['POST'],
|
|
37
|
+
'/api/goals/tree': ['GET'],
|
|
38
|
+
'/api/integrations/status': ['GET'],
|
|
39
|
+
'/api/me': ['GET'],
|
|
40
|
+
'/api/org/cancel-deletion': ['POST'],
|
|
41
|
+
'/api/org/delete': ['POST'],
|
|
42
|
+
'/api/org/deletion-eligibility': ['GET'],
|
|
43
|
+
'/api/org/transfer-eligibility': ['GET'],
|
|
44
|
+
'/api/org/transfer-ownership': ['DELETE', 'POST'],
|
|
45
|
+
'/api/org/transfer-ownership/accept': ['POST'],
|
|
46
|
+
'/api/org/transfer-ownership/preview': ['POST'],
|
|
47
|
+
'/api/org/transfer-ownership/status': ['GET'],
|
|
48
|
+
'/api/orgs/{orgId}/ai-usage': ['GET'],
|
|
49
|
+
'/api/orgs/{orgId}/billing': ['GET'],
|
|
50
|
+
'/api/orgs/{orgId}/budget-config': ['GET', 'PUT'],
|
|
51
|
+
'/api/shared/{token}': ['GET'],
|
|
52
|
+
'/api/shares/{shareId}': ['DELETE', 'PATCH'],
|
|
53
|
+
'/api/teams': ['GET', 'POST'],
|
|
54
|
+
'/api/teams/{teamId}': ['DELETE', 'GET', 'PUT'],
|
|
55
|
+
'/api/teams/{teamId}/members': ['POST'],
|
|
56
|
+
'/api/teams/{teamId}/members/{userId}': ['DELETE'],
|
|
57
|
+
'/api/teams/{teamId}/members/{userId}/role': ['PUT'],
|
|
58
|
+
'/api/timeline': ['GET'],
|
|
59
|
+
'/api/user/active-org': ['POST'],
|
|
60
|
+
'/api/user/orgs': ['GET'],
|
|
61
|
+
'/api/user/orgs/{orgId}/leave': ['POST'],
|
|
62
|
+
'/api/user/profile': ['PATCH'],
|
|
63
|
+
'/api/workspace': ['GET'],
|
|
64
|
+
'/api/workspace/access': ['GET'],
|
|
65
|
+
'/api/workspace/audit': ['GET'],
|
|
66
|
+
'/api/workspace/auth': ['GET'],
|
|
67
|
+
'/api/workspace/auth-policy': ['PATCH'],
|
|
68
|
+
'/api/workspace/auth-policy/test-sso': ['POST'],
|
|
69
|
+
'/api/workspace/auth-policy/test-sso/{attemptId}': ['GET'],
|
|
70
|
+
'/api/workspace/auth-policy/validate-oidc': ['POST'],
|
|
71
|
+
'/api/workspace/domains': ['GET', 'POST'],
|
|
72
|
+
'/api/workspace/domains/{id}': ['DELETE'],
|
|
73
|
+
'/api/workspace/domains/{id}/verify': ['POST'],
|
|
74
|
+
'/api/workspace/invites': ['GET', 'POST'],
|
|
75
|
+
'/api/workspace/invites/accept': ['POST'],
|
|
76
|
+
'/api/workspace/invites/{id}': ['DELETE'],
|
|
77
|
+
'/api/workspace/members': ['GET'],
|
|
78
|
+
'/api/workspace/members/{id}': ['DELETE'],
|
|
79
|
+
'/api/workspace/members/{id}/role': ['PATCH'],
|
|
80
|
+
'/auth/logout': ['POST'],
|
|
81
|
+
'/auth/me': ['GET'],
|
|
82
|
+
'/auth/sso/callback': ['GET', 'POST'],
|
|
83
|
+
'/auth/sso/{orgSlug}': ['GET'],
|
|
84
|
+
'/auth/start': ['POST'],
|
|
85
|
+
'/auth/verify': ['POST'],
|
|
86
|
+
'/connect/{provider}': ['GET'],
|
|
87
|
+
'/healthz': ['GET'],
|
|
88
|
+
'/oauth/{provider}/callback': ['GET'],
|
|
89
|
+
} as const;
|
|
90
|
+
|
|
91
|
+
export type OpenApiRoute = keyof typeof openApiRoutes;
|
|
92
|
+
export type OpenApiMethod = (typeof openApiRoutes)[OpenApiRoute][number];
|
package/src/index.ts
CHANGED
|
@@ -539,3 +539,10 @@ export { resolveScope, toQueryKey, fromQueryKey, resourceRelationships, matchesR
|
|
|
539
539
|
|
|
540
540
|
// Resource response wrapper (typed versioning for cache invalidation)
|
|
541
541
|
export type { ResourceResponse } from './resource-response'
|
|
542
|
+
|
|
543
|
+
// OpenAPI generated types (from openapi/backend.yaml)
|
|
544
|
+
// @see src/api/README.md for codegen details
|
|
545
|
+
export type { paths, components, operations } from './api/index'
|
|
546
|
+
|
|
547
|
+
// OpenAPI route registry (generated from openapi/backend.yaml)
|
|
548
|
+
export { openApiRoutes, type OpenApiRoute, type OpenApiMethod } from './generated/openapi-routes'
|
package/src/resource-keys.ts
CHANGED
|
@@ -15,7 +15,12 @@ export type ResourceKey =
|
|
|
15
15
|
| { type: 'timeline'; orgId: string }
|
|
16
16
|
// Identities (singular) — single entities
|
|
17
17
|
| { type: 'member'; orgId: string; memberId: string }
|
|
18
|
+
| { type: 'team'; orgId: string; teamId: string }
|
|
19
|
+
| { type: 'department'; orgId: string; departmentId: string }
|
|
20
|
+
| { type: 'chat'; orgId: string; chatId: string }
|
|
21
|
+
| { type: 'goalDoc'; orgId: string; slug: string }
|
|
18
22
|
| { type: 'workspace'; orgId: string }
|
|
23
|
+
| { type: 'workspaceDomains'; orgId: string }
|
|
19
24
|
| { type: 'authSettings'; orgId: string }
|
|
20
25
|
| { type: 'billing'; orgId: string }
|
|
21
26
|
| { type: 'aiUsage'; orgId: string }
|
|
@@ -25,7 +30,8 @@ export type ResourceKey =
|
|
|
25
30
|
// User-scoped
|
|
26
31
|
| { type: 'dismissedBanners'; userId: string }
|
|
27
32
|
| { type: 'userOrgs'; userId: string }
|
|
28
|
-
| { type: 'sessions'; userId: string }
|
|
33
|
+
| { type: 'sessions'; userId: string }
|
|
34
|
+
| { type: 'viewer'; userId: string };
|
|
29
35
|
|
|
30
36
|
/**
|
|
31
37
|
* Action — structured mutation key used across execution system, audit, permissions.
|
|
@@ -45,11 +51,11 @@ export function resolveScope(context: {
|
|
|
45
51
|
/** All ResourceKey type literals for exhaustive checking. */
|
|
46
52
|
const ORG_SCOPED_TYPES = [
|
|
47
53
|
'members', 'departments', 'chats', 'teams', 'integrations', 'invites',
|
|
48
|
-
'auditEvents', 'timeline', 'workspace', '
|
|
49
|
-
'deletionEligibility', 'transferOwnership', 'goals',
|
|
54
|
+
'auditEvents', 'timeline', 'workspace', 'workspaceDomains', 'authSettings',
|
|
55
|
+
'billing', 'aiUsage', 'deletionEligibility', 'transferOwnership', 'goals',
|
|
50
56
|
] as const;
|
|
51
57
|
|
|
52
|
-
const USER_SCOPED_TYPES = ['dismissedBanners', 'userOrgs', 'sessions'] as const;
|
|
58
|
+
const USER_SCOPED_TYPES = ['dismissedBanners', 'userOrgs', 'sessions', 'viewer'] as const;
|
|
53
59
|
|
|
54
60
|
/**
|
|
55
61
|
* Canonical ResourceKey → query key conversion.
|
|
@@ -62,14 +68,23 @@ const USER_SCOPED_TYPES = ['dismissedBanners', 'userOrgs', 'sessions'] as const;
|
|
|
62
68
|
*/
|
|
63
69
|
export function toQueryKey(key: ResourceKey): readonly string[] {
|
|
64
70
|
switch (key.type) {
|
|
65
|
-
//
|
|
71
|
+
// Identities with extra field
|
|
66
72
|
case 'member':
|
|
67
73
|
return [key.type, key.orgId, key.memberId] as const;
|
|
74
|
+
case 'team':
|
|
75
|
+
return [key.type, key.orgId, key.teamId] as const;
|
|
76
|
+
case 'department':
|
|
77
|
+
return [key.type, key.orgId, key.departmentId] as const;
|
|
78
|
+
case 'chat':
|
|
79
|
+
return [key.type, key.orgId, key.chatId] as const;
|
|
80
|
+
case 'goalDoc':
|
|
81
|
+
return [key.type, key.orgId, key.slug] as const;
|
|
68
82
|
|
|
69
83
|
// User-scoped
|
|
70
84
|
case 'dismissedBanners':
|
|
71
85
|
case 'userOrgs':
|
|
72
86
|
case 'sessions':
|
|
87
|
+
case 'viewer':
|
|
73
88
|
return [key.type, key.userId] as const;
|
|
74
89
|
|
|
75
90
|
// Org-scoped collections and identities
|
|
@@ -82,6 +97,7 @@ export function toQueryKey(key: ResourceKey): readonly string[] {
|
|
|
82
97
|
case 'auditEvents':
|
|
83
98
|
case 'timeline':
|
|
84
99
|
case 'workspace':
|
|
100
|
+
case 'workspaceDomains':
|
|
85
101
|
case 'authSettings':
|
|
86
102
|
case 'billing':
|
|
87
103
|
case 'aiUsage':
|
|
@@ -108,12 +124,20 @@ export function fromQueryKey(queryKey: readonly string[]): ResourceKey {
|
|
|
108
124
|
throw new Error(`Invalid query key: expected at least [type, scope], got ${JSON.stringify(queryKey)}`);
|
|
109
125
|
}
|
|
110
126
|
|
|
111
|
-
//
|
|
112
|
-
|
|
127
|
+
// Identities with extra field
|
|
128
|
+
const identityFields: Record<string, string> = {
|
|
129
|
+
member: 'memberId',
|
|
130
|
+
team: 'teamId',
|
|
131
|
+
department: 'departmentId',
|
|
132
|
+
chat: 'chatId',
|
|
133
|
+
goalDoc: 'slug',
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
if (type in identityFields) {
|
|
113
137
|
if (rest.length !== 2) {
|
|
114
|
-
throw new Error(`Invalid query key for '
|
|
138
|
+
throw new Error(`Invalid query key for '${type}': expected [type, orgId, ${identityFields[type]}], got ${JSON.stringify(queryKey)}`);
|
|
115
139
|
}
|
|
116
|
-
return { type
|
|
140
|
+
return { type, orgId: rest[0], [identityFields[type]]: rest[1] } as ResourceKey;
|
|
117
141
|
}
|
|
118
142
|
|
|
119
143
|
// User-scoped types
|
|
@@ -143,6 +167,8 @@ export const resourceRelationships: Record<string, string[]> = {
|
|
|
143
167
|
chat: ['chats'],
|
|
144
168
|
teams: ['team'],
|
|
145
169
|
team: ['teams'],
|
|
170
|
+
goals: ['goalDoc'],
|
|
171
|
+
goalDoc: ['goals'],
|
|
146
172
|
};
|
|
147
173
|
|
|
148
174
|
/**
|
|
@@ -167,6 +193,10 @@ export function matchesResourceKey(queryKey: readonly unknown[], targetKey: Reso
|
|
|
167
193
|
if ('orgId' in parsed && 'orgId' in targetKey && parsed.orgId !== targetKey.orgId) return false;
|
|
168
194
|
if ('userId' in parsed && 'userId' in targetKey && parsed.userId !== targetKey.userId) return false;
|
|
169
195
|
if ('memberId' in parsed && 'memberId' in targetKey && parsed.memberId !== targetKey.memberId) return false;
|
|
196
|
+
if ('teamId' in parsed && 'teamId' in targetKey && parsed.teamId !== targetKey.teamId) return false;
|
|
197
|
+
if ('departmentId' in parsed && 'departmentId' in targetKey && parsed.departmentId !== targetKey.departmentId) return false;
|
|
198
|
+
if ('chatId' in parsed && 'chatId' in targetKey && parsed.chatId !== targetKey.chatId) return false;
|
|
199
|
+
if ('slug' in parsed && 'slug' in targetKey && parsed.slug !== targetKey.slug) return false;
|
|
170
200
|
|
|
171
201
|
return true;
|
|
172
202
|
}
|