@agent-os-sdk/client 0.9.25 → 0.9.27
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/generated/openapi.d.ts +82 -0
- package/dist/generated/openapi.d.ts.map +1 -1
- package/dist/modules/runs.d.ts.map +1 -1
- package/dist/modules/templates.d.ts +23 -0
- package/dist/modules/templates.d.ts.map +1 -1
- package/dist/modules/templates.js +7 -0
- package/package.json +2 -2
- package/src/client/AgentOsClient.ts +0 -294
- package/src/client/HttpRequestBuilder.ts +0 -115
- package/src/client/OperationContext.ts +0 -22
- package/src/client/OperationContextProvider.ts +0 -89
- package/src/client/auth.ts +0 -136
- package/src/client/config.ts +0 -100
- package/src/client/helpers.ts +0 -98
- package/src/client/pagination.ts +0 -218
- package/src/client/raw.ts +0 -609
- package/src/client/retry.ts +0 -150
- package/src/client/sanitize.ts +0 -31
- package/src/client/timeout.ts +0 -59
- package/src/errors/factory.ts +0 -140
- package/src/errors/index.ts +0 -365
- package/src/generated/client.ts +0 -32
- package/src/generated/index.ts +0 -2
- package/src/generated/openapi.ts +0 -12302
- package/src/generated/swagger.json +0 -16851
- package/src/index.ts +0 -131
- package/src/modules/a2a.ts +0 -64
- package/src/modules/agents.ts +0 -604
- package/src/modules/apiTokens.ts +0 -101
- package/src/modules/approvals.ts +0 -151
- package/src/modules/audit.ts +0 -145
- package/src/modules/auth.ts +0 -33
- package/src/modules/catalog.ts +0 -241
- package/src/modules/chatwoot.ts +0 -242
- package/src/modules/checkpoints.ts +0 -87
- package/src/modules/contracts.ts +0 -80
- package/src/modules/credentials.ts +0 -216
- package/src/modules/crons.ts +0 -115
- package/src/modules/datasets.ts +0 -142
- package/src/modules/evaluation.ts +0 -269
- package/src/modules/files.ts +0 -208
- package/src/modules/improvements.ts +0 -71
- package/src/modules/info.ts +0 -143
- package/src/modules/me.ts +0 -74
- package/src/modules/members.ts +0 -199
- package/src/modules/memberships.ts +0 -42
- package/src/modules/metaAgent.ts +0 -131
- package/src/modules/metrics.ts +0 -34
- package/src/modules/observability.ts +0 -28
- package/src/modules/playground.ts +0 -68
- package/src/modules/presets.ts +0 -246
- package/src/modules/prompts.ts +0 -147
- package/src/modules/roles.ts +0 -112
- package/src/modules/runs.ts +0 -878
- package/src/modules/store.ts +0 -65
- package/src/modules/templates.ts +0 -40
- package/src/modules/tenants.ts +0 -79
- package/src/modules/threads.ts +0 -343
- package/src/modules/tools.ts +0 -91
- package/src/modules/traces.ts +0 -133
- package/src/modules/triggers.ts +0 -357
- package/src/modules/usage.ts +0 -117
- package/src/modules/vectorStores.ts +0 -257
- package/src/modules/workspaces.ts +0 -216
- package/src/sse/client.ts +0 -179
package/src/modules/files.ts
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Files Module - Fully Typed
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { RawClient, APIResponse, components } from "../client/raw.js";
|
|
6
|
-
|
|
7
|
-
type FileListItem = components["schemas"]["FileListItem"];
|
|
8
|
-
type FileDetail = components["schemas"]["FileDetail"];
|
|
9
|
-
type CreatePresignedUploadRequest = components["schemas"]["CreatePresignedUploadRequest"];
|
|
10
|
-
type PresignedUploadResponse = components["schemas"]["PresignedUploadResponse"];
|
|
11
|
-
type ConfirmUploadRequest = components["schemas"]["ConfirmUploadRequest"];
|
|
12
|
-
type FileConfirmResponse = components["schemas"]["FileConfirmResponse"];
|
|
13
|
-
type PresignedDownloadResponse = components["schemas"]["PresignedDownloadResponse"];
|
|
14
|
-
|
|
15
|
-
export interface StoredFile {
|
|
16
|
-
id: string;
|
|
17
|
-
filename: string;
|
|
18
|
-
content_type: string;
|
|
19
|
-
size_bytes: number;
|
|
20
|
-
sha256?: string;
|
|
21
|
-
status: "pending" | "confirmed" | "deleted";
|
|
22
|
-
created_at: string;
|
|
23
|
-
updated_at?: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface FileListResponse {
|
|
27
|
-
items: StoredFile[];
|
|
28
|
-
total: number;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface PresignedUpload {
|
|
32
|
-
file_id: string;
|
|
33
|
-
upload_url: string;
|
|
34
|
-
expires_in: number;
|
|
35
|
-
object_key: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface ConfirmedUpload {
|
|
39
|
-
file_id: string;
|
|
40
|
-
status: string;
|
|
41
|
-
size_bytes: number;
|
|
42
|
-
sha256?: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface PresignedDownload {
|
|
46
|
-
file_id: string;
|
|
47
|
-
download_url: string;
|
|
48
|
-
filename: string;
|
|
49
|
-
content_type: string;
|
|
50
|
-
size_bytes: number;
|
|
51
|
-
expires_in: number;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export class FilesModule {
|
|
55
|
-
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
56
|
-
|
|
57
|
-
private resolveWorkspaceId(workspaceId?: string): string {
|
|
58
|
-
if (workspaceId && workspaceId.trim().length > 0) {
|
|
59
|
-
return workspaceId.trim();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const headers = this.headers();
|
|
63
|
-
const fromHeader = headers["X-Workspace-Id"] ?? headers["x-workspace-id"];
|
|
64
|
-
if (fromHeader && fromHeader.trim().length > 0) {
|
|
65
|
-
return fromHeader.trim();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
throw new Error("workspace_id is required (pass workspaceId or set X-Workspace-Id in client headers)");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
private static toStoredFile(item: FileListItem | FileDetail): StoredFile {
|
|
72
|
-
return {
|
|
73
|
-
id: item.id ?? "",
|
|
74
|
-
filename: item.filename ?? "",
|
|
75
|
-
content_type: item.content_type ?? "application/octet-stream",
|
|
76
|
-
size_bytes: item.size_bytes ?? 0,
|
|
77
|
-
sha256: "sha256" in item ? item.sha256 ?? undefined : undefined,
|
|
78
|
-
status: (item.status ?? "pending") as StoredFile["status"],
|
|
79
|
-
created_at: item.created_at ?? "",
|
|
80
|
-
updated_at: "updated_at" in item ? item.updated_at ?? undefined : undefined,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* List files in a workspace.
|
|
86
|
-
*/
|
|
87
|
-
async list(params?: {
|
|
88
|
-
workspace_id?: string;
|
|
89
|
-
status?: string;
|
|
90
|
-
limit?: number;
|
|
91
|
-
offset?: number;
|
|
92
|
-
}): Promise<APIResponse<FileListResponse>> {
|
|
93
|
-
const workspaceId = this.resolveWorkspaceId(params?.workspace_id);
|
|
94
|
-
const response = await this.client.GET<FileListItem[]>("/v1/api/workspaces/{workspaceId}/files", {
|
|
95
|
-
params: {
|
|
96
|
-
path: { workspaceId },
|
|
97
|
-
query: {
|
|
98
|
-
status: params?.status,
|
|
99
|
-
limit: params?.limit,
|
|
100
|
-
offset: params?.offset,
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
headers: this.headers(),
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const items = Array.isArray(response.data)
|
|
107
|
-
? response.data.map((item) => FilesModule.toStoredFile(item))
|
|
108
|
-
: [];
|
|
109
|
-
|
|
110
|
-
return {
|
|
111
|
-
...response,
|
|
112
|
-
data: {
|
|
113
|
-
items,
|
|
114
|
-
total: items.length,
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Get a file by ID.
|
|
121
|
-
*/
|
|
122
|
-
async get(fileId: string, workspaceId?: string): Promise<APIResponse<StoredFile>> {
|
|
123
|
-
const resolvedWorkspaceId = this.resolveWorkspaceId(workspaceId);
|
|
124
|
-
const response = await this.client.GET<FileDetail>("/v1/api/workspaces/{workspaceId}/files/{fileId}", {
|
|
125
|
-
params: { path: { workspaceId: resolvedWorkspaceId, fileId } },
|
|
126
|
-
headers: this.headers(),
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
if (!response.data) {
|
|
130
|
-
return response as APIResponse<StoredFile>;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
...response,
|
|
135
|
-
data: FilesModule.toStoredFile(response.data),
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Create a presigned upload URL.
|
|
141
|
-
*/
|
|
142
|
-
async createUpload(body: {
|
|
143
|
-
filename: string;
|
|
144
|
-
content_type?: string;
|
|
145
|
-
size_bytes?: number;
|
|
146
|
-
expected_sha256?: string;
|
|
147
|
-
}, workspaceId?: string): Promise<APIResponse<PresignedUpload>> {
|
|
148
|
-
const resolvedWorkspaceId = this.resolveWorkspaceId(workspaceId);
|
|
149
|
-
const requestBody: CreatePresignedUploadRequest = {
|
|
150
|
-
filename: body.filename,
|
|
151
|
-
content_type: body.content_type,
|
|
152
|
-
size_bytes: body.size_bytes,
|
|
153
|
-
expected_sha256: body.expected_sha256,
|
|
154
|
-
};
|
|
155
|
-
return this.client.POST<PresignedUploadResponse>("/v1/api/workspaces/{workspaceId}/files/presign", {
|
|
156
|
-
params: { path: { workspaceId: resolvedWorkspaceId } },
|
|
157
|
-
body: requestBody,
|
|
158
|
-
headers: this.headers(),
|
|
159
|
-
}) as Promise<APIResponse<PresignedUpload>>;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Confirm an upload.
|
|
164
|
-
*/
|
|
165
|
-
async confirmUpload(fileId: string, sha256?: string, workspaceId?: string): Promise<APIResponse<ConfirmedUpload>> {
|
|
166
|
-
const resolvedWorkspaceId = this.resolveWorkspaceId(workspaceId);
|
|
167
|
-
const requestBody: ConfirmUploadRequest = { sha256 };
|
|
168
|
-
return this.client.POST<FileConfirmResponse>("/v1/api/workspaces/{workspaceId}/files/{fileId}/confirm", {
|
|
169
|
-
params: { path: { workspaceId: resolvedWorkspaceId, fileId } },
|
|
170
|
-
body: requestBody,
|
|
171
|
-
headers: this.headers(),
|
|
172
|
-
}) as Promise<APIResponse<ConfirmedUpload>>;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Get a presigned download URL.
|
|
177
|
-
*/
|
|
178
|
-
async getDownloadUrl(fileId: string, workspaceId?: string): Promise<APIResponse<PresignedDownload>> {
|
|
179
|
-
const resolvedWorkspaceId = this.resolveWorkspaceId(workspaceId);
|
|
180
|
-
return this.client.GET<PresignedDownloadResponse>("/v1/api/workspaces/{workspaceId}/files/{fileId}/download", {
|
|
181
|
-
params: { path: { workspaceId: resolvedWorkspaceId, fileId } },
|
|
182
|
-
headers: this.headers(),
|
|
183
|
-
}) as Promise<APIResponse<PresignedDownload>>;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Delete a file.
|
|
188
|
-
*/
|
|
189
|
-
async delete(fileId: string, workspaceId?: string): Promise<APIResponse<void>> {
|
|
190
|
-
const resolvedWorkspaceId = this.resolveWorkspaceId(workspaceId);
|
|
191
|
-
return this.client.DELETE<void>("/v1/api/workspaces/{workspaceId}/files/{fileId}", {
|
|
192
|
-
params: { path: { workspaceId: resolvedWorkspaceId, fileId } },
|
|
193
|
-
headers: this.headers(),
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Alias for createUpload with explicit semantic name.
|
|
199
|
-
*/
|
|
200
|
-
async createPresignedUpload(body: {
|
|
201
|
-
filename: string;
|
|
202
|
-
content_type?: string;
|
|
203
|
-
size_bytes?: number;
|
|
204
|
-
expected_sha256?: string;
|
|
205
|
-
}, workspaceId?: string): Promise<APIResponse<PresignedUpload>> {
|
|
206
|
-
return this.createUpload(body, workspaceId);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { APIResponse, RawClient } from "../client/raw.js";
|
|
2
|
-
|
|
3
|
-
export interface ImprovementCase {
|
|
4
|
-
id: string;
|
|
5
|
-
tenant_id: string;
|
|
6
|
-
workspace_id: string;
|
|
7
|
-
agent_id: string;
|
|
8
|
-
champion_bundle_id: string;
|
|
9
|
-
challenger_bundle_id: string;
|
|
10
|
-
eval_experiment_id?: string | null;
|
|
11
|
-
status: string;
|
|
12
|
-
trigger_kind: string;
|
|
13
|
-
improvement_policy_ref?: string | null;
|
|
14
|
-
summary?: string | null;
|
|
15
|
-
decision_comparison_id?: string | null;
|
|
16
|
-
approval_decision_reason?: string | null;
|
|
17
|
-
promotion_decision_reason?: string | null;
|
|
18
|
-
rejection_reason?: string | null;
|
|
19
|
-
rollback_reason?: string | null;
|
|
20
|
-
rollback_decision_comparison_id?: string | null;
|
|
21
|
-
rollback_source_bundle_id?: string | null;
|
|
22
|
-
rollback_target_bundle_id?: string | null;
|
|
23
|
-
created_by?: string | null;
|
|
24
|
-
approved_by?: string | null;
|
|
25
|
-
promoted_by?: string | null;
|
|
26
|
-
rejected_by?: string | null;
|
|
27
|
-
rolled_back_by?: string | null;
|
|
28
|
-
created_at: string;
|
|
29
|
-
updated_at: string;
|
|
30
|
-
approved_at?: string | null;
|
|
31
|
-
promoted_at?: string | null;
|
|
32
|
-
rejected_at?: string | null;
|
|
33
|
-
rolled_back_at?: string | null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface ImprovementCaseListResponse {
|
|
37
|
-
items: ImprovementCase[];
|
|
38
|
-
total: number;
|
|
39
|
-
skip: number;
|
|
40
|
-
take: number;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export class ImprovementsModule {
|
|
44
|
-
constructor(private client: RawClient, private headers: () => Record<string, string>) {}
|
|
45
|
-
|
|
46
|
-
async list(params?: {
|
|
47
|
-
agentId?: string;
|
|
48
|
-
status?: string;
|
|
49
|
-
skip?: number;
|
|
50
|
-
take?: number;
|
|
51
|
-
}): Promise<APIResponse<ImprovementCaseListResponse>> {
|
|
52
|
-
return this.client.GET<ImprovementCaseListResponse>("/v1/api/improvements/cases", {
|
|
53
|
-
params: {
|
|
54
|
-
query: {
|
|
55
|
-
agentId: params?.agentId,
|
|
56
|
-
status: params?.status,
|
|
57
|
-
skip: params?.skip,
|
|
58
|
-
take: params?.take,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
headers: this.headers(),
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
async get(caseId: string): Promise<APIResponse<ImprovementCase>> {
|
|
66
|
-
return this.client.GET<ImprovementCase>("/v1/api/improvements/cases/{caseId}", {
|
|
67
|
-
params: { path: { caseId } },
|
|
68
|
-
headers: this.headers(),
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
package/src/modules/info.ts
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Info Module - Fully Typed
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
6
|
-
|
|
7
|
-
export interface ServerInfo {
|
|
8
|
-
name: string;
|
|
9
|
-
version: string;
|
|
10
|
-
environment: string;
|
|
11
|
-
features?: string[];
|
|
12
|
-
uptime_seconds?: number;
|
|
13
|
-
commit_hash?: string;
|
|
14
|
-
api_version?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** Normalized server capabilities (camelCase, with defaults) */
|
|
18
|
-
export interface ServerCapabilities {
|
|
19
|
-
/** Server version */
|
|
20
|
-
version?: string;
|
|
21
|
-
/** Git commit hash */
|
|
22
|
-
commitHash?: string;
|
|
23
|
-
/** API version */
|
|
24
|
-
apiVersion?: string;
|
|
25
|
-
/** Environment (production, staging, development) */
|
|
26
|
-
environment?: string;
|
|
27
|
-
/** Feature flags - all default to false if not present */
|
|
28
|
-
features: {
|
|
29
|
-
sseResume: boolean;
|
|
30
|
-
cronTriggers: boolean;
|
|
31
|
-
batchRuns: boolean;
|
|
32
|
-
hitl: boolean;
|
|
33
|
-
traces: boolean;
|
|
34
|
-
vectorStores: boolean;
|
|
35
|
-
evaluations: boolean;
|
|
36
|
-
[key: string]: boolean;
|
|
37
|
-
};
|
|
38
|
-
/** Server limits */
|
|
39
|
-
limits?: {
|
|
40
|
-
maxBatchSize?: number;
|
|
41
|
-
maxFileSize?: number;
|
|
42
|
-
[key: string]: number | undefined;
|
|
43
|
-
};
|
|
44
|
-
/** SDK version that fetched this (useful for support) */
|
|
45
|
-
sdkVersion: string;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// SDK version from package (will be replaced at build time or use constant)
|
|
49
|
-
const SDK_VERSION = "0.4.0";
|
|
50
|
-
|
|
51
|
-
export class InfoModule {
|
|
52
|
-
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Get server information.
|
|
56
|
-
*/
|
|
57
|
-
async get(): Promise<APIResponse<ServerInfo>> {
|
|
58
|
-
return this.client.GET<ServerInfo>("/v1/info", {
|
|
59
|
-
headers: this.headers(),
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Health check endpoint.
|
|
65
|
-
*/
|
|
66
|
-
async health(): Promise<APIResponse<{ status: string }>> {
|
|
67
|
-
return this.client.GET<{ status: string }>("/health", {
|
|
68
|
-
headers: this.headers(),
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Get normalized server capabilities for feature detection.
|
|
74
|
-
*
|
|
75
|
-
* This method never assumes feature availability - all features
|
|
76
|
-
* default to false unless explicitly enabled by the server.
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```ts
|
|
80
|
-
* const caps = await client.info.capabilities();
|
|
81
|
-
* if (caps.data?.features.sseResume) {
|
|
82
|
-
* // Use follow() with resume
|
|
83
|
-
* } else {
|
|
84
|
-
* // Fall back to polling
|
|
85
|
-
* }
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
async capabilities(): Promise<APIResponse<ServerCapabilities>> {
|
|
89
|
-
const response = await this.get();
|
|
90
|
-
|
|
91
|
-
if (response.error || !response.data) {
|
|
92
|
-
// Pass through error - construct proper response without data
|
|
93
|
-
return {
|
|
94
|
-
error: response.error,
|
|
95
|
-
response: response.response,
|
|
96
|
-
meta: response.meta,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const info = response.data;
|
|
101
|
-
|
|
102
|
-
// Transform snake_case features array to camelCase object
|
|
103
|
-
// CRITICAL: Never assume true - default everything to false
|
|
104
|
-
const featureArray = info.features ?? [];
|
|
105
|
-
const features: ServerCapabilities["features"] = {
|
|
106
|
-
sseResume: featureArray.includes("sse_resume"),
|
|
107
|
-
cronTriggers: featureArray.includes("cron_triggers"),
|
|
108
|
-
batchRuns: featureArray.includes("batch_runs"),
|
|
109
|
-
hitl: featureArray.includes("hitl"),
|
|
110
|
-
traces: featureArray.includes("traces"),
|
|
111
|
-
vectorStores: featureArray.includes("vector_stores"),
|
|
112
|
-
evaluations: featureArray.includes("evaluations"),
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// Add any other features from array as snake_case → camelCase
|
|
116
|
-
for (const feature of featureArray) {
|
|
117
|
-
const camelCase = snakeToCamel(feature);
|
|
118
|
-
if (!(camelCase in features)) {
|
|
119
|
-
features[camelCase] = true;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const capabilities: ServerCapabilities = {
|
|
124
|
-
version: info.version,
|
|
125
|
-
commitHash: info.commit_hash,
|
|
126
|
-
apiVersion: info.api_version,
|
|
127
|
-
environment: info.environment,
|
|
128
|
-
features,
|
|
129
|
-
sdkVersion: SDK_VERSION,
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
return {
|
|
133
|
-
data: capabilities,
|
|
134
|
-
response: response.response,
|
|
135
|
-
meta: response.meta,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/** Convert snake_case to camelCase */
|
|
141
|
-
function snakeToCamel(str: string): string {
|
|
142
|
-
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
143
|
-
}
|
package/src/modules/me.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Me Module - Identity & Context
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
6
|
-
|
|
7
|
-
// ── Lightweight identity (GET /me) ──────────────────────────────
|
|
8
|
-
|
|
9
|
-
export interface MeResponse {
|
|
10
|
-
user_id: string;
|
|
11
|
-
email: string;
|
|
12
|
-
display_name?: string;
|
|
13
|
-
avatar_url?: string;
|
|
14
|
-
member_id?: string;
|
|
15
|
-
tenant_id?: string;
|
|
16
|
-
workspaces?: {
|
|
17
|
-
id: string;
|
|
18
|
-
name: string;
|
|
19
|
-
role: string;
|
|
20
|
-
}[];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// ── Full context (GET /me/context) ──────────────────────────────
|
|
24
|
-
|
|
25
|
-
export interface UserContextResponse {
|
|
26
|
-
user: {
|
|
27
|
-
id: string;
|
|
28
|
-
email: string;
|
|
29
|
-
};
|
|
30
|
-
memberships: MembershipContext[];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface MembershipContext {
|
|
34
|
-
member_id: string;
|
|
35
|
-
tenant: {
|
|
36
|
-
id: string;
|
|
37
|
-
name: string;
|
|
38
|
-
slug: string;
|
|
39
|
-
};
|
|
40
|
-
role: {
|
|
41
|
-
id: string;
|
|
42
|
-
name: string;
|
|
43
|
-
is_system: boolean;
|
|
44
|
-
permissions: string[];
|
|
45
|
-
};
|
|
46
|
-
workspaces: {
|
|
47
|
-
id: string;
|
|
48
|
-
name: string;
|
|
49
|
-
slug: string;
|
|
50
|
-
}[];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export class MeModule {
|
|
54
|
-
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Get current user information (lightweight, backward compatible).
|
|
58
|
-
*/
|
|
59
|
-
async get(): Promise<APIResponse<MeResponse>> {
|
|
60
|
-
return this.client.GET<MeResponse>("/v1/api/me", {
|
|
61
|
-
headers: this.headers(),
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Get full user context: all tenants, workspaces, roles, and permissions.
|
|
67
|
-
* This is the canonical endpoint for populating frontend layouts.
|
|
68
|
-
*/
|
|
69
|
-
async getContext(): Promise<APIResponse<UserContextResponse>> {
|
|
70
|
-
return this.client.GET<UserContextResponse>("/v1/api/me/context", {
|
|
71
|
-
headers: this.headers(),
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
package/src/modules/members.ts
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Members Module - Fully Typed
|
|
3
|
-
*
|
|
4
|
-
* Naming conventions:
|
|
5
|
-
* - get* for singular items
|
|
6
|
-
* - list* for collections
|
|
7
|
-
* - create*, update*, delete* for mutations (NOT remove!)
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { PaginatedResponse, PaginationParams } from "../client/helpers.js";
|
|
11
|
-
import type { APIResponse, RawClient } from "../client/raw.js";
|
|
12
|
-
|
|
13
|
-
export interface Member {
|
|
14
|
-
id: string;
|
|
15
|
-
tenant_id: string;
|
|
16
|
-
user_id?: string;
|
|
17
|
-
email?: string;
|
|
18
|
-
display_name?: string;
|
|
19
|
-
avatar_url?: string;
|
|
20
|
-
role_id?: string;
|
|
21
|
-
role_name?: string;
|
|
22
|
-
workspace_ids?: string[];
|
|
23
|
-
status: "active" | "pending" | "disabled";
|
|
24
|
-
created_at: string;
|
|
25
|
-
updated_at: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface Role {
|
|
29
|
-
id: string;
|
|
30
|
-
name: string;
|
|
31
|
-
is_system: boolean;
|
|
32
|
-
permissions?: string[];
|
|
33
|
-
created_at?: string;
|
|
34
|
-
members_count?: number;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface MemberInviteResponse {
|
|
38
|
-
member_id: string;
|
|
39
|
-
invite_token?: string;
|
|
40
|
-
email: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export type MemberListResponse = PaginatedResponse<Member>;
|
|
44
|
-
|
|
45
|
-
export class MembersModule {
|
|
46
|
-
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* List all members in the tenant.
|
|
50
|
-
*/
|
|
51
|
-
async list(params?: PaginationParams & {
|
|
52
|
-
workspace_id?: string;
|
|
53
|
-
role_id?: string;
|
|
54
|
-
status?: string;
|
|
55
|
-
}): Promise<APIResponse<MemberListResponse>> {
|
|
56
|
-
return this.client.GET<MemberListResponse>("/v1/api/members", {
|
|
57
|
-
params: { query: params },
|
|
58
|
-
headers: this.headers(),
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Get a member by ID.
|
|
64
|
-
*/
|
|
65
|
-
async get(memberId: string): Promise<APIResponse<Member>> {
|
|
66
|
-
return this.client.GET<Member>("/v1/api/members/{id}", {
|
|
67
|
-
params: { path: { id: memberId } },
|
|
68
|
-
headers: this.headers(),
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* List all roles in the tenant.
|
|
75
|
-
*/
|
|
76
|
-
async listRoles(): Promise<APIResponse<{ items: Role[] }>> {
|
|
77
|
-
return this.client.GET<{ items: Role[] }>("/v1/api/roles", {
|
|
78
|
-
headers: this.headers(),
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Get a role by ID.
|
|
84
|
-
*/
|
|
85
|
-
async getRole(roleId: string): Promise<APIResponse<Role>> {
|
|
86
|
-
return this.client.GET<Role>("/v1/api/roles/{id}", {
|
|
87
|
-
params: { path: { id: roleId } },
|
|
88
|
-
headers: this.headers(),
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Create a new custom role.
|
|
94
|
-
*/
|
|
95
|
-
async createRole(body: { name: string; permissions?: string[] }): Promise<APIResponse<Role>> {
|
|
96
|
-
return this.client.POST<Role>("/v1/api/roles", {
|
|
97
|
-
body,
|
|
98
|
-
headers: this.headers(),
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Update a custom role.
|
|
104
|
-
*/
|
|
105
|
-
async updateRole(roleId: string, body: { name?: string; permissions?: string[] }): Promise<APIResponse<Role>> {
|
|
106
|
-
return this.client.PUT<Role>("/v1/api/roles/{id}", {
|
|
107
|
-
params: { path: { id: roleId } },
|
|
108
|
-
body,
|
|
109
|
-
headers: this.headers(),
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Delete a custom role.
|
|
115
|
-
*/
|
|
116
|
-
async deleteRole(roleId: string): Promise<APIResponse<void>> {
|
|
117
|
-
return this.client.DELETE<void>("/v1/api/roles/{id}", {
|
|
118
|
-
params: { path: { id: roleId } },
|
|
119
|
-
headers: this.headers(),
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* List all available system permissions.
|
|
125
|
-
*/
|
|
126
|
-
async listPermissions(): Promise<APIResponse<{ items: string[] }>> {
|
|
127
|
-
return this.client.GET<{ items: string[] }>("/v1/api/roles/permissions", {
|
|
128
|
-
headers: this.headers(),
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Invite a new member.
|
|
134
|
-
*/
|
|
135
|
-
async invite(body: {
|
|
136
|
-
email: string;
|
|
137
|
-
role_id?: string;
|
|
138
|
-
workspace_ids?: string[];
|
|
139
|
-
}): Promise<APIResponse<MemberInviteResponse>> {
|
|
140
|
-
return this.client.POST<MemberInviteResponse>("/v1/api/members/invite", {
|
|
141
|
-
body,
|
|
142
|
-
headers: this.headers(),
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Update a member.
|
|
148
|
-
*/
|
|
149
|
-
async update(memberId: string, body: {
|
|
150
|
-
role_id?: string;
|
|
151
|
-
workspace_ids?: string[];
|
|
152
|
-
}): Promise<APIResponse<Member>> {
|
|
153
|
-
return this.client.PUT<Member>("/v1/api/members/{id}", {
|
|
154
|
-
params: { path: { id: memberId } },
|
|
155
|
-
body,
|
|
156
|
-
headers: this.headers(),
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Remove a member from the tenant.
|
|
162
|
-
*/
|
|
163
|
-
async delete(memberId: string): Promise<APIResponse<void>> {
|
|
164
|
-
return this.client.DELETE<void>("/v1/api/members/{id}", {
|
|
165
|
-
params: { path: { id: memberId } },
|
|
166
|
-
headers: this.headers(),
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Resend invitation email.
|
|
172
|
-
*/
|
|
173
|
-
async resendInvite(memberId: string): Promise<APIResponse<void>> {
|
|
174
|
-
return this.client.POST<void>("/v1/api/members/{id}/resend-invite", {
|
|
175
|
-
params: { path: { id: memberId } },
|
|
176
|
-
headers: this.headers(),
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Ensure membership exists (auto-create on first access).
|
|
182
|
-
* This is used by the frontend for onboarding.
|
|
183
|
-
*/
|
|
184
|
-
async ensure(tenantId?: string): Promise<APIResponse<Member>> {
|
|
185
|
-
return this.client.POST<Member>("/v1/api/memberships/ensure", {
|
|
186
|
-
body: { tenant_id: tenantId ?? null },
|
|
187
|
-
headers: this.headers(),
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Seed default permissions (Dev only)
|
|
193
|
-
*/
|
|
194
|
-
async seedDefaults(): Promise<APIResponse<{ message: string }>> {
|
|
195
|
-
return this.client.POST<{ message: string }>("/v1/api/roles/seed-defaults", {
|
|
196
|
-
headers: this.headers(),
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
}
|