@proteos/sdk 0.18.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/LICENSE +40 -0
- package/dist/chunk-7RGN4E22.cjs +1185 -0
- package/dist/chunk-7RGN4E22.cjs.map +1 -0
- package/dist/chunk-XJP5WCRZ.js +1125 -0
- package/dist/chunk-XJP5WCRZ.js.map +1 -0
- package/dist/index.cjs +2384 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5225 -0
- package/dist/index.d.ts +5225 -0
- package/dist/index.js +2146 -0
- package/dist/index.js.map +1 -0
- package/dist/meta/index.cjs +204 -0
- package/dist/meta/index.cjs.map +1 -0
- package/dist/meta/index.d.cts +2 -0
- package/dist/meta/index.d.ts +2 -0
- package/dist/meta/index.js +3 -0
- package/dist/meta/index.js.map +1 -0
- package/dist/types-BNsjfU8N.d.cts +3299 -0
- package/dist/types-BNsjfU8N.d.ts +3299 -0
- package/package.json +86 -0
- package/src/agent/agents.ts +53 -0
- package/src/agent/index.ts +134 -0
- package/src/agent/mcp-servers.ts +102 -0
- package/src/agent/prompts.ts +80 -0
- package/src/agent/session-types.ts +397 -0
- package/src/agent/sessions.ts +197 -0
- package/src/agent/skills.ts +89 -0
- package/src/agent/tools.ts +53 -0
- package/src/agent/types.ts +362 -0
- package/src/auth/index.ts +111 -0
- package/src/auth/me.ts +46 -0
- package/src/auth/organizations.ts +128 -0
- package/src/auth/platform-entities.ts +78 -0
- package/src/auth/roles.ts +213 -0
- package/src/auth/types.ts +294 -0
- package/src/auth/users.ts +226 -0
- package/src/client.ts +441 -0
- package/src/connector/index.ts +120 -0
- package/src/connector/types.ts +150 -0
- package/src/conversation/index.ts +297 -0
- package/src/conversation/types.ts +590 -0
- package/src/conversation/voice.ts +123 -0
- package/src/data/index.ts +53 -0
- package/src/data/queries.ts +66 -0
- package/src/data/records.ts +122 -0
- package/src/data/types.ts +89 -0
- package/src/errors.ts +148 -0
- package/src/events/index.ts +172 -0
- package/src/events/types.ts +77 -0
- package/src/functions/actions.ts +95 -0
- package/src/functions/index.ts +32 -0
- package/src/functions/types.ts +71 -0
- package/src/http/index.ts +2 -0
- package/src/http/query-params.ts +106 -0
- package/src/index.ts +598 -0
- package/src/iterator.ts +183 -0
- package/src/knowledge/graph.ts +35 -0
- package/src/knowledge/index.ts +104 -0
- package/src/knowledge/labels.ts +70 -0
- package/src/knowledge/links.ts +65 -0
- package/src/knowledge/nodes.ts +198 -0
- package/src/knowledge/record-links.ts +66 -0
- package/src/knowledge/types.ts +569 -0
- package/src/meta/apps.ts +107 -0
- package/src/meta/components.ts +124 -0
- package/src/meta/currency/index.ts +202 -0
- package/src/meta/entities.ts +193 -0
- package/src/meta/filters.ts +76 -0
- package/src/meta/index.ts +227 -0
- package/src/meta/layout/common-props.ts +93 -0
- package/src/meta/layout/control-registry.json +70 -0
- package/src/meta/layout/control-registry.ts +92 -0
- package/src/meta/layout/elements.ts +203 -0
- package/src/meta/layout/index.ts +41 -0
- package/src/meta/layout/page-layout.ts +35 -0
- package/src/meta/layout/size-value.ts +27 -0
- package/src/meta/list-views.ts +109 -0
- package/src/meta/lists.ts +104 -0
- package/src/meta/menu-configurations.ts +128 -0
- package/src/meta/modules.ts +159 -0
- package/src/meta/pages.ts +106 -0
- package/src/meta/types.ts +1115 -0
- package/src/meta/variables.ts +98 -0
- package/src/storage/files.ts +183 -0
- package/src/storage/index.ts +33 -0
- package/src/storage/types.ts +70 -0
- package/src/types/common.ts +143 -0
- package/src/types/index.ts +28 -0
- package/src/types/options.ts +95 -0
- package/src/workflow/executions.ts +99 -0
- package/src/workflow/index.ts +109 -0
- package/src/workflow/node-types.ts +50 -0
- package/src/workflow/types.ts +658 -0
- package/src/workflow/workflows.ts +152 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical platform entities — the built-in system resources (users, roles,
|
|
3
|
+
* files, entities, …) that are permission targets alongside user-defined
|
|
4
|
+
* entities. Hand-maintained mirror of the Go registry in
|
|
5
|
+
* packages/go/model/platform/entities.go — keep the two in sync.
|
|
6
|
+
*
|
|
7
|
+
* Used by the role-permission UI to list grantable platform entities next to
|
|
8
|
+
* user-defined entities (from `meta.entities.list()`); permissions key on a
|
|
9
|
+
* free-form `entity_slug`, so the two are assigned uniformly.
|
|
10
|
+
*/
|
|
11
|
+
export interface PlatformEntity {
|
|
12
|
+
slug: string
|
|
13
|
+
/** Display label for the role-permission dropdown. */
|
|
14
|
+
name: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The canonical platform entities, in display order. */
|
|
18
|
+
export const PLATFORM_ENTITIES: readonly PlatformEntity[] = [
|
|
19
|
+
// Access (account-service)
|
|
20
|
+
{ slug: 'organizations', name: 'Organizations' },
|
|
21
|
+
{ slug: 'users', name: 'Users' },
|
|
22
|
+
{ slug: 'roles', name: 'Roles' },
|
|
23
|
+
{ slug: 'user-role-assignments', name: 'User Role Assignments' },
|
|
24
|
+
{ slug: 'role-entity-permissions', name: 'Role Entity Permissions' },
|
|
25
|
+
// Schema / content (metadata-service)
|
|
26
|
+
{ slug: 'entities', name: 'Entities' },
|
|
27
|
+
{ slug: 'pages', name: 'Pages' },
|
|
28
|
+
{ slug: 'menu-configurations', name: 'Menu Configurations' },
|
|
29
|
+
{ slug: 'apps', name: 'Apps' },
|
|
30
|
+
{ slug: 'components', name: 'Components' },
|
|
31
|
+
{ slug: 'lists', name: 'Lists' },
|
|
32
|
+
{ slug: 'list-views', name: 'List Views' },
|
|
33
|
+
// System (metadata-service)
|
|
34
|
+
{ slug: 'modules', name: 'Modules' },
|
|
35
|
+
{ slug: 'variables', name: 'Variables' },
|
|
36
|
+
{ slug: 'deployments', name: 'Deployments' },
|
|
37
|
+
// Storage (storage-service)
|
|
38
|
+
{ slug: 'files', name: 'Files' },
|
|
39
|
+
// Automation (function-service)
|
|
40
|
+
{ slug: 'hooks', name: 'Hooks' },
|
|
41
|
+
{ slug: 'actions', name: 'Actions' },
|
|
42
|
+
// Knowledge (knowledge-service)
|
|
43
|
+
{ slug: 'knowledge-nodes', name: 'Knowledge Nodes' },
|
|
44
|
+
{ slug: 'knowledge-links', name: 'Knowledge Links' },
|
|
45
|
+
{ slug: 'knowledge-labels', name: 'Knowledge Labels' },
|
|
46
|
+
// Agent suite (agent-service)
|
|
47
|
+
{ slug: 'agents', name: 'Agents' },
|
|
48
|
+
{ slug: 'prompts', name: 'Prompts' },
|
|
49
|
+
{ slug: 'skills', name: 'Skills' },
|
|
50
|
+
{ slug: 'tools', name: 'Tools' },
|
|
51
|
+
{ slug: 'mcp-servers', name: 'MCP Servers' },
|
|
52
|
+
{ slug: 'agent-sessions', name: 'Agent Sessions' },
|
|
53
|
+
// Messaging bus (event-service)
|
|
54
|
+
{ slug: 'topics', name: 'Topics' },
|
|
55
|
+
{ slug: 'events', name: 'Events' },
|
|
56
|
+
// Conversations (conversation-service). NOTE: `connections` is enforced by
|
|
57
|
+
// BOTH conversation-service and connector-service (2026-07 decision) — same
|
|
58
|
+
// concept in both; conversation connections migrate onto connector-service
|
|
59
|
+
// later.
|
|
60
|
+
{ slug: 'connections', name: 'Connections' },
|
|
61
|
+
{ slug: 'conversations', name: 'Conversations' },
|
|
62
|
+
{ slug: 'messages', name: 'Messages' },
|
|
63
|
+
{ slug: 'agent-listeners', name: 'Agent Listeners' },
|
|
64
|
+
{ slug: 'transcriptions', name: 'Transcriptions' },
|
|
65
|
+
// Connectors (connector-service). `connections` above is shared; this is the
|
|
66
|
+
// manifest catalog.
|
|
67
|
+
{ slug: 'connectors', name: 'Connectors' },
|
|
68
|
+
] as const
|
|
69
|
+
|
|
70
|
+
/** Just the platform entity slugs, in canonical order. */
|
|
71
|
+
export const PLATFORM_ENTITY_SLUGS: readonly string[] = PLATFORM_ENTITIES.map(
|
|
72
|
+
(entity) => entity.slug,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
/** True when `slug` belongs to a platform entity (reserved; can't be user-created). */
|
|
76
|
+
export function isPlatformEntity(slug: string): boolean {
|
|
77
|
+
return PLATFORM_ENTITY_SLUGS.includes(slug)
|
|
78
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { ProteosClient } from '../client.js'
|
|
2
|
+
import { PageIterator } from '../iterator.js'
|
|
3
|
+
import type { ListResult } from '../types/common.js'
|
|
4
|
+
import type {
|
|
5
|
+
AssignPermissionRequest,
|
|
6
|
+
CreateRoleRequest,
|
|
7
|
+
ListRolePermissionsOptions,
|
|
8
|
+
ListRolesOptions,
|
|
9
|
+
Role,
|
|
10
|
+
RoleEntityPermission,
|
|
11
|
+
UpdateRoleRequest,
|
|
12
|
+
} from './types.js'
|
|
13
|
+
|
|
14
|
+
const ROLES_BASE_PATH = '/accounts/v1/roles'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Service for managing roles.
|
|
18
|
+
* Handles role CRUD operations and permission assignments.
|
|
19
|
+
*/
|
|
20
|
+
export interface RoleService {
|
|
21
|
+
/**
|
|
22
|
+
* Lists roles with optional filtering.
|
|
23
|
+
* Returns an async iterator that automatically handles pagination.
|
|
24
|
+
*
|
|
25
|
+
* @param options - Filter and pagination options
|
|
26
|
+
* @returns Async iterator over roles
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* // Iterate over all roles
|
|
31
|
+
* for await (const role of service.list()) {
|
|
32
|
+
* console.log(role.name);
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* // With filtering
|
|
36
|
+
* for await (const role of service.list({ org_id: 'org-123' })) {
|
|
37
|
+
* console.log(role.slug);
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
list(options?: ListRolesOptions): PageIterator<Role, ListRolesOptions>
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Gets a single role by slug.
|
|
45
|
+
*
|
|
46
|
+
* @param slug - Role slug
|
|
47
|
+
* @returns The role
|
|
48
|
+
* @throws {ProteosError} If role not found (404)
|
|
49
|
+
*/
|
|
50
|
+
get(slug: string): Promise<Role>
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new role.
|
|
54
|
+
*
|
|
55
|
+
* @param request - Role creation request
|
|
56
|
+
* @returns The created role
|
|
57
|
+
* @throws {ProteosError} If validation fails (400) or conflict (409)
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const role = await service.create({
|
|
62
|
+
* org_id: 'org-123',
|
|
63
|
+
* slug: 'admin',
|
|
64
|
+
* name: 'Administrator',
|
|
65
|
+
* description: 'Full system access',
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
create(request: CreateRoleRequest): Promise<Role>
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Creates or updates a role idempotently by slug. The URL slug wins on
|
|
73
|
+
* mismatch with the body's slug field (`PUT /accounts/v1/roles/:slug`). The
|
|
74
|
+
* org is taken from the caller's token, not the body.
|
|
75
|
+
*
|
|
76
|
+
* @param slug - Role slug
|
|
77
|
+
* @param request - Full role body
|
|
78
|
+
* @returns The created or updated role
|
|
79
|
+
*/
|
|
80
|
+
upsert(slug: string, request: CreateRoleRequest): Promise<Role>
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Updates an existing role.
|
|
84
|
+
*
|
|
85
|
+
* @param slug - Role slug
|
|
86
|
+
* @param request - Fields to update
|
|
87
|
+
* @returns The updated role
|
|
88
|
+
* @throws {ProteosError} If role not found (404) or validation fails (400)
|
|
89
|
+
*/
|
|
90
|
+
update(slug: string, request: UpdateRoleRequest): Promise<Role>
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Deletes a role.
|
|
94
|
+
*
|
|
95
|
+
* @param slug - Role slug
|
|
96
|
+
* @throws {ProteosError} If role not found (404)
|
|
97
|
+
*/
|
|
98
|
+
delete(slug: string): Promise<void>
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Fetches a single page of roles.
|
|
102
|
+
*
|
|
103
|
+
* @param options - Filter and pagination options (including `page`)
|
|
104
|
+
* @returns A single page of roles with pagination metadata
|
|
105
|
+
*/
|
|
106
|
+
listPage(options?: ListRolesOptions): Promise<ListResult<Role>>
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Gets permissions assigned to a role.
|
|
110
|
+
* Returns an async iterator that automatically handles pagination.
|
|
111
|
+
*
|
|
112
|
+
* @param roleSlug - Role slug
|
|
113
|
+
* @param options - Filter and pagination options
|
|
114
|
+
* @returns Async iterator over role entity permissions
|
|
115
|
+
*/
|
|
116
|
+
getPermissions(
|
|
117
|
+
roleSlug: string,
|
|
118
|
+
options?: ListRolePermissionsOptions,
|
|
119
|
+
): PageIterator<RoleEntityPermission, ListRolePermissionsOptions>
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Assigns a permission to a role for an entity.
|
|
123
|
+
*
|
|
124
|
+
* @param roleSlug - Role slug
|
|
125
|
+
* @param request - Permission assignment request
|
|
126
|
+
* @returns The created role entity permission
|
|
127
|
+
* @throws {ProteosError} If role or entity not found (404)
|
|
128
|
+
*/
|
|
129
|
+
assignPermission(
|
|
130
|
+
roleSlug: string,
|
|
131
|
+
request: AssignPermissionRequest,
|
|
132
|
+
): Promise<RoleEntityPermission>
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Removes a permission from a role.
|
|
136
|
+
*
|
|
137
|
+
* @param roleSlug - Role slug
|
|
138
|
+
* @param permissionId - Permission ID to remove
|
|
139
|
+
* @throws {ProteosError} If permission not found (404)
|
|
140
|
+
*/
|
|
141
|
+
removePermission(roleSlug: string, permissionId: string): Promise<void>
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Implementation of RoleService.
|
|
146
|
+
*/
|
|
147
|
+
export class RoleServiceImpl implements RoleService {
|
|
148
|
+
constructor(private readonly client: ProteosClient) {}
|
|
149
|
+
|
|
150
|
+
list(options: ListRolesOptions = {}): PageIterator<Role, ListRolesOptions> {
|
|
151
|
+
return new PageIterator((opts) => this.listPage(opts), options)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async listPage(options: ListRolesOptions = {}): Promise<ListResult<Role>> {
|
|
155
|
+
return this.client.requestWithQuery<ListResult<Role>>('GET', ROLES_BASE_PATH, options)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async get(slug: string): Promise<Role> {
|
|
159
|
+
return this.client.request<Role>('GET', `${ROLES_BASE_PATH}/${slug}`)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async create(request: CreateRoleRequest): Promise<Role> {
|
|
163
|
+
return this.client.request<Role>('POST', ROLES_BASE_PATH, request)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async upsert(slug: string, request: CreateRoleRequest): Promise<Role> {
|
|
167
|
+
return this.client.request<Role>('PUT', `${ROLES_BASE_PATH}/${slug}`, { ...request, slug })
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async update(slug: string, request: UpdateRoleRequest): Promise<Role> {
|
|
171
|
+
return this.client.request<Role>('PATCH', `${ROLES_BASE_PATH}/${slug}`, request)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async delete(slug: string): Promise<void> {
|
|
175
|
+
await this.client.request<void>('DELETE', `${ROLES_BASE_PATH}/${slug}`)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
getPermissions(
|
|
179
|
+
roleSlug: string,
|
|
180
|
+
options: ListRolePermissionsOptions = {},
|
|
181
|
+
): PageIterator<RoleEntityPermission, ListRolePermissionsOptions> {
|
|
182
|
+
return new PageIterator((opts) => this.fetchPermissionsPage(roleSlug, opts), options)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async assignPermission(
|
|
186
|
+
roleSlug: string,
|
|
187
|
+
request: AssignPermissionRequest,
|
|
188
|
+
): Promise<RoleEntityPermission> {
|
|
189
|
+
return this.client.request<RoleEntityPermission>(
|
|
190
|
+
'POST',
|
|
191
|
+
`${ROLES_BASE_PATH}/${roleSlug}/permissions`,
|
|
192
|
+
request,
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async removePermission(roleSlug: string, permissionId: string): Promise<void> {
|
|
197
|
+
await this.client.request<void>(
|
|
198
|
+
'DELETE',
|
|
199
|
+
`${ROLES_BASE_PATH}/${roleSlug}/permissions/${permissionId}`,
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
private async fetchPermissionsPage(
|
|
204
|
+
roleSlug: string,
|
|
205
|
+
options: ListRolePermissionsOptions,
|
|
206
|
+
): Promise<ListResult<RoleEntityPermission>> {
|
|
207
|
+
return this.client.requestWithQuery<ListResult<RoleEntityPermission>>(
|
|
208
|
+
'GET',
|
|
209
|
+
`${ROLES_BASE_PATH}/${roleSlug}/permissions`,
|
|
210
|
+
options,
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { AuditFields, ListOptions } from '../types/common.js'
|
|
3
|
+
import { AuditFieldsSchema } from '../types/common.js'
|
|
4
|
+
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// Shared Auth Types
|
|
7
|
+
// ============================================================================
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Base list options with source filters for the auth namespace.
|
|
11
|
+
*/
|
|
12
|
+
export interface AuthListOptions extends ListOptions {
|
|
13
|
+
created_by?: string
|
|
14
|
+
updated_by?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Permission Types
|
|
19
|
+
// ============================================================================
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Permission level for entity access.
|
|
23
|
+
*/
|
|
24
|
+
export type Permission = 'read' | 'write' | 'delete'
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Role entity permission - permission granted to a role for a specific entity.
|
|
28
|
+
*/
|
|
29
|
+
export interface RoleEntityPermission extends AuditFields {
|
|
30
|
+
id: string
|
|
31
|
+
org_id: string
|
|
32
|
+
role_slug: string
|
|
33
|
+
entity_slug: string
|
|
34
|
+
permission: Permission
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const RoleEntityPermissionSchema = AuditFieldsSchema.extend({
|
|
38
|
+
id: z.string(),
|
|
39
|
+
role_slug: z.string(),
|
|
40
|
+
entity_slug: z.string(),
|
|
41
|
+
permission: z.enum(['read', 'write', 'delete']),
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Request to assign a permission to a role.
|
|
46
|
+
*/
|
|
47
|
+
export interface AssignPermissionRequest {
|
|
48
|
+
entity_slug: string
|
|
49
|
+
permission: Permission
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Options for listing role permissions.
|
|
54
|
+
*/
|
|
55
|
+
export interface ListRolePermissionsOptions extends AuthListOptions {
|
|
56
|
+
id?: string
|
|
57
|
+
entity_slug?: string
|
|
58
|
+
permission?: Permission
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// User Role Assignment Types
|
|
63
|
+
// ============================================================================
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* User role assignment - a role assigned to a user.
|
|
67
|
+
*/
|
|
68
|
+
export interface UserRoleAssignment extends AuditFields {
|
|
69
|
+
id: string
|
|
70
|
+
user_id: string
|
|
71
|
+
role_slug: string
|
|
72
|
+
org_id: string
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const UserRoleAssignmentSchema = AuditFieldsSchema.extend({
|
|
76
|
+
id: z.string(),
|
|
77
|
+
user_id: z.string(),
|
|
78
|
+
role_slug: z.string(),
|
|
79
|
+
org_id: z.string(),
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Request to assign a role to a user.
|
|
84
|
+
*/
|
|
85
|
+
export interface AssignRoleRequest {
|
|
86
|
+
role_slug: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Options for listing user role assignments.
|
|
91
|
+
*/
|
|
92
|
+
export interface ListUserRoleAssignmentsOptions extends AuthListOptions {
|
|
93
|
+
id?: string
|
|
94
|
+
role_slug?: string
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// ============================================================================
|
|
98
|
+
// User Types
|
|
99
|
+
// ============================================================================
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* User in the system.
|
|
103
|
+
*/
|
|
104
|
+
export interface User extends AuditFields {
|
|
105
|
+
id: string
|
|
106
|
+
email: string
|
|
107
|
+
given_name: string
|
|
108
|
+
family_name: string
|
|
109
|
+
external_id: string
|
|
110
|
+
default_org_id: string
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const UserSchema = AuditFieldsSchema.extend({
|
|
114
|
+
id: z.string(),
|
|
115
|
+
email: z.string(),
|
|
116
|
+
given_name: z.string(),
|
|
117
|
+
family_name: z.string(),
|
|
118
|
+
external_id: z.string(),
|
|
119
|
+
default_org_id: z.string(),
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Request to create a user.
|
|
124
|
+
*/
|
|
125
|
+
export interface CreateUserRequest {
|
|
126
|
+
given_name: string
|
|
127
|
+
family_name: string
|
|
128
|
+
email: string
|
|
129
|
+
default_org_id?: string
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Request to update a user.
|
|
134
|
+
*/
|
|
135
|
+
export interface UpdateUserRequest {
|
|
136
|
+
given_name?: string
|
|
137
|
+
family_name?: string
|
|
138
|
+
default_org_id?: string
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Options for listing users.
|
|
143
|
+
*/
|
|
144
|
+
export interface ListUsersOptions extends AuthListOptions {
|
|
145
|
+
id?: string
|
|
146
|
+
given_name?: string
|
|
147
|
+
family_name?: string
|
|
148
|
+
email?: string
|
|
149
|
+
default_org_id?: string
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ============================================================================
|
|
153
|
+
// Api Key Types
|
|
154
|
+
// ============================================================================
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* A user-scoped API key (pak_ token). Only the display hints
|
|
158
|
+
* (token_prefix/token_suffix) are readable after creation — the full token
|
|
159
|
+
* appears exactly once in {@link CreatedApiKey}.
|
|
160
|
+
*/
|
|
161
|
+
export interface ApiKey extends AuditFields {
|
|
162
|
+
id: string
|
|
163
|
+
user_id: string
|
|
164
|
+
org_id: string
|
|
165
|
+
name: string
|
|
166
|
+
token_prefix: string
|
|
167
|
+
token_suffix: string
|
|
168
|
+
/** ISO timestamp; null = the key never expires. */
|
|
169
|
+
expires_at: string | null
|
|
170
|
+
last_used_at: string | null
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export const ApiKeySchema = AuditFieldsSchema.extend({
|
|
174
|
+
id: z.string(),
|
|
175
|
+
user_id: z.string(),
|
|
176
|
+
org_id: z.string(),
|
|
177
|
+
name: z.string(),
|
|
178
|
+
token_prefix: z.string(),
|
|
179
|
+
token_suffix: z.string(),
|
|
180
|
+
expires_at: z.string().nullable(),
|
|
181
|
+
last_used_at: z.string().nullable(),
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Create response: the key plus the full token, returned exactly once.
|
|
186
|
+
* Store it immediately — it is not retrievable afterwards.
|
|
187
|
+
*/
|
|
188
|
+
export interface CreatedApiKey extends ApiKey {
|
|
189
|
+
token: string
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Request to create an API key. Omitting expires_at creates a key that never
|
|
194
|
+
* expires; omitting org_id binds the key to the user's default org.
|
|
195
|
+
*/
|
|
196
|
+
export interface CreateApiKeyRequest {
|
|
197
|
+
name: string
|
|
198
|
+
org_id?: string
|
|
199
|
+
expires_at?: string
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// ============================================================================
|
|
203
|
+
// Role Types
|
|
204
|
+
// ============================================================================
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Role in the system.
|
|
208
|
+
*/
|
|
209
|
+
export interface Role extends AuditFields {
|
|
210
|
+
slug: string
|
|
211
|
+
name: string
|
|
212
|
+
org_id: string
|
|
213
|
+
description: string
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export const RoleSchema = AuditFieldsSchema.extend({
|
|
217
|
+
slug: z.string(),
|
|
218
|
+
name: z.string(),
|
|
219
|
+
org_id: z.string(),
|
|
220
|
+
description: z.string(),
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Request to create a role.
|
|
225
|
+
*/
|
|
226
|
+
export interface CreateRoleRequest {
|
|
227
|
+
org_id: string
|
|
228
|
+
slug: string
|
|
229
|
+
name: string
|
|
230
|
+
description?: string
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Request to update a role.
|
|
235
|
+
*/
|
|
236
|
+
export interface UpdateRoleRequest {
|
|
237
|
+
org_id?: string
|
|
238
|
+
name?: string
|
|
239
|
+
description?: string
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Options for listing roles.
|
|
244
|
+
*/
|
|
245
|
+
export interface ListRolesOptions extends AuthListOptions {
|
|
246
|
+
org_id?: string
|
|
247
|
+
slug?: string
|
|
248
|
+
name?: string
|
|
249
|
+
description?: string
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// ============================================================================
|
|
253
|
+
// Organization Types
|
|
254
|
+
// ============================================================================
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Organization in the system.
|
|
258
|
+
*/
|
|
259
|
+
export interface Organization extends AuditFields {
|
|
260
|
+
id: string
|
|
261
|
+
name: string
|
|
262
|
+
description: string
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export const OrganizationSchema = AuditFieldsSchema.extend({
|
|
266
|
+
id: z.string(),
|
|
267
|
+
name: z.string(),
|
|
268
|
+
description: z.string(),
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Request to create an organization.
|
|
273
|
+
*/
|
|
274
|
+
export interface CreateOrganizationRequest {
|
|
275
|
+
name: string
|
|
276
|
+
description?: string
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Request to update an organization.
|
|
281
|
+
*/
|
|
282
|
+
export interface UpdateOrganizationRequest {
|
|
283
|
+
name?: string
|
|
284
|
+
description?: string
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Options for listing organizations.
|
|
289
|
+
*/
|
|
290
|
+
export interface ListOrganizationsOptions extends AuthListOptions {
|
|
291
|
+
id?: string
|
|
292
|
+
name?: string
|
|
293
|
+
description?: string
|
|
294
|
+
}
|