roe-typescript 1.1.0 → 1.1.2
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/README.md +49 -34
- package/dist/api/_generated.d.ts +9 -0
- package/dist/api/_generated.js +9 -0
- package/dist/api/agents.d.ts +14 -1
- package/dist/api/agents.js +73 -8
- package/dist/api/connections.d.ts +58 -0
- package/dist/api/connections.js +139 -0
- package/dist/api/connectors.d.ts +18 -0
- package/dist/api/connectors.js +26 -0
- package/dist/api/discovery.d.ts +2 -0
- package/dist/api/discovery.js +6 -0
- package/dist/api/knowledge_base.d.ts +67 -0
- package/dist/api/knowledge_base.js +202 -0
- package/dist/api/policies.d.ts +23 -6
- package/dist/api/policies.js +69 -33
- package/dist/api/tables.d.ts +25 -1
- package/dist/api/tables.js +49 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +3 -3
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1 -1
- package/dist/config.js +3 -1
- package/dist/exceptions.js +3 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +7 -7
- package/dist/models/file.js +5 -3
- package/dist/models/job.d.ts +1 -1
- package/dist/models/job.js +15 -4
- package/dist/utils/dynamicInputs.js +4 -2
- package/dist/utils/fileDetection.js +1 -1
- package/dist/utils/middleware.d.ts +1 -1
- package/dist/utils/middleware.js +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { RoeConfig } from "../config.js";
|
|
2
|
+
import type { RoeRawClient } from "../generated/client.js";
|
|
3
|
+
import type { components } from "../generated/schema.js";
|
|
4
|
+
type CreateKnowledgeBase = components["schemas"]["CreateKnowledgeBase"];
|
|
5
|
+
type Draft = components["schemas"]["Draft"];
|
|
6
|
+
type KnowledgeBase = components["schemas"]["KnowledgeBase"];
|
|
7
|
+
type PaginatedKnowledgeBaseList = components["schemas"]["PaginatedKnowledgeBaseList"];
|
|
8
|
+
export declare class KnowledgeBaseAPI {
|
|
9
|
+
readonly config: RoeConfig;
|
|
10
|
+
readonly raw: RoeRawClient;
|
|
11
|
+
/** API for managing Knowledge Base lenses and drafts. */
|
|
12
|
+
constructor(config: RoeConfig, raw: RoeRawClient);
|
|
13
|
+
protected get rawClient(): RoeRawClient;
|
|
14
|
+
protected get organizationId(): string;
|
|
15
|
+
/** List all knowledge bases for the organisation. */
|
|
16
|
+
list(params?: {
|
|
17
|
+
page?: number;
|
|
18
|
+
pageSize?: number;
|
|
19
|
+
}): Promise<PaginatedKnowledgeBaseList>;
|
|
20
|
+
/** Create a new knowledge base draft (async generation). */
|
|
21
|
+
create(params: {
|
|
22
|
+
company: string;
|
|
23
|
+
brief: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
productName?: string;
|
|
26
|
+
websiteUrl?: string;
|
|
27
|
+
}): Promise<CreateKnowledgeBase>;
|
|
28
|
+
/** Retrieve a single knowledge base record. */
|
|
29
|
+
retrieve(knowledgeBaseId: string): Promise<KnowledgeBase>;
|
|
30
|
+
/** Delete a knowledge base and its associated Atlas draft or lens. */
|
|
31
|
+
delete(knowledgeBaseId: string): Promise<void>;
|
|
32
|
+
/** Unlink a knowledge base locally, preserving the Atlas lens. */
|
|
33
|
+
unlink(knowledgeBaseId: string): Promise<void>;
|
|
34
|
+
/** Poll the Atlas draft status until ready or error. */
|
|
35
|
+
pollDraft(knowledgeBaseId: string): Promise<Draft>;
|
|
36
|
+
/** Patch the draft's typology/tactic selection. */
|
|
37
|
+
patchSelection(knowledgeBaseId: string, selection: {
|
|
38
|
+
refs: Record<string, unknown>[];
|
|
39
|
+
suggestedName?: string;
|
|
40
|
+
}): Promise<Draft>;
|
|
41
|
+
/** Kick off an async regeneration round with optional feedback. */
|
|
42
|
+
regenerate(knowledgeBaseId: string, params?: {
|
|
43
|
+
feedback?: string;
|
|
44
|
+
}): Promise<Draft>;
|
|
45
|
+
/** Approve or decline a pending regeneration proposal. */
|
|
46
|
+
resolve(knowledgeBaseId: string, params?: {
|
|
47
|
+
refs?: Record<string, unknown>[];
|
|
48
|
+
suggestedName?: string;
|
|
49
|
+
acceptSummary?: boolean;
|
|
50
|
+
discard?: boolean;
|
|
51
|
+
}): Promise<Draft>;
|
|
52
|
+
/** Commit the draft into a permanent Atlas lens. */
|
|
53
|
+
finalize(knowledgeBaseId: string, params?: {
|
|
54
|
+
name?: string;
|
|
55
|
+
mcpEnabled?: boolean;
|
|
56
|
+
public?: boolean;
|
|
57
|
+
}): Promise<KnowledgeBase>;
|
|
58
|
+
/** Sync the lens snapshot from Atlas (best-effort). */
|
|
59
|
+
sync(knowledgeBaseId: string): Promise<KnowledgeBase>;
|
|
60
|
+
/** Fetch the names-only typology and tactic catalog. */
|
|
61
|
+
catalog(): Promise<unknown>;
|
|
62
|
+
/** Fetch and optionally sync a lens by its Atlas ID. */
|
|
63
|
+
lensByAtlasId(atlasLensId: string): Promise<unknown>;
|
|
64
|
+
/** Import a finalized Atlas lens into roe-main by its atlas_lens_id. */
|
|
65
|
+
importLens(atlasLensId: string): Promise<KnowledgeBase>;
|
|
66
|
+
}
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { BadRequestError } from "../exceptions.js";
|
|
2
|
+
import { isUuidString } from "../utils/fileDetection.js";
|
|
3
|
+
function validateUuid(value, fieldName) {
|
|
4
|
+
if (!isUuidString(value)) {
|
|
5
|
+
throw new BadRequestError(`Invalid ${fieldName}: "${value}" is not a valid UUID`, 400);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export class KnowledgeBaseAPI {
|
|
9
|
+
/** API for managing Knowledge Base lenses and drafts. */
|
|
10
|
+
constructor(config, raw) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.raw = raw;
|
|
13
|
+
}
|
|
14
|
+
get rawClient() {
|
|
15
|
+
return this.raw;
|
|
16
|
+
}
|
|
17
|
+
get organizationId() {
|
|
18
|
+
return this.config.organizationId;
|
|
19
|
+
}
|
|
20
|
+
/** List all knowledge bases for the organisation. */
|
|
21
|
+
async list(params) {
|
|
22
|
+
const { data } = await this.rawClient.GET("/v1/knowledge-base/", {
|
|
23
|
+
params: {
|
|
24
|
+
query: {
|
|
25
|
+
organization_id: this.organizationId,
|
|
26
|
+
...(params?.page !== undefined ? { page: params.page } : {}),
|
|
27
|
+
...(params?.pageSize !== undefined
|
|
28
|
+
? { page_size: params.pageSize }
|
|
29
|
+
: {}),
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
/** Create a new knowledge base draft (async generation). */
|
|
36
|
+
async create(params) {
|
|
37
|
+
const body = {
|
|
38
|
+
company: params.company,
|
|
39
|
+
brief: params.brief,
|
|
40
|
+
...(params.name !== undefined ? { name: params.name } : {}),
|
|
41
|
+
...(params.productName !== undefined
|
|
42
|
+
? { product_name: params.productName }
|
|
43
|
+
: {}),
|
|
44
|
+
...(params.websiteUrl !== undefined
|
|
45
|
+
? { website_url: params.websiteUrl }
|
|
46
|
+
: {}),
|
|
47
|
+
};
|
|
48
|
+
const { data } = await this.rawClient.POST("/v1/knowledge-base/", {
|
|
49
|
+
params: { query: { organization_id: this.organizationId } },
|
|
50
|
+
body,
|
|
51
|
+
});
|
|
52
|
+
return data;
|
|
53
|
+
}
|
|
54
|
+
/** Retrieve a single knowledge base record. */
|
|
55
|
+
async retrieve(knowledgeBaseId) {
|
|
56
|
+
validateUuid(knowledgeBaseId, "knowledgeBaseId");
|
|
57
|
+
const { data } = await this.rawClient.GET("/v1/knowledge-base/{id}/", {
|
|
58
|
+
params: {
|
|
59
|
+
path: { id: knowledgeBaseId },
|
|
60
|
+
query: { organization_id: this.organizationId },
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
return data;
|
|
64
|
+
}
|
|
65
|
+
/** Delete a knowledge base and its associated Atlas draft or lens. */
|
|
66
|
+
async delete(knowledgeBaseId) {
|
|
67
|
+
validateUuid(knowledgeBaseId, "knowledgeBaseId");
|
|
68
|
+
await this.rawClient.DELETE("/v1/knowledge-base/{id}/", {
|
|
69
|
+
params: {
|
|
70
|
+
path: { id: knowledgeBaseId },
|
|
71
|
+
query: { organization_id: this.organizationId },
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/** Unlink a knowledge base locally, preserving the Atlas lens. */
|
|
76
|
+
async unlink(knowledgeBaseId) {
|
|
77
|
+
validateUuid(knowledgeBaseId, "knowledgeBaseId");
|
|
78
|
+
await this.rawClient.DELETE("/v1/knowledge-base/{id}/unlink/", {
|
|
79
|
+
params: {
|
|
80
|
+
path: { id: knowledgeBaseId },
|
|
81
|
+
query: { organization_id: this.organizationId },
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/** Poll the Atlas draft status until ready or error. */
|
|
86
|
+
async pollDraft(knowledgeBaseId) {
|
|
87
|
+
validateUuid(knowledgeBaseId, "knowledgeBaseId");
|
|
88
|
+
const { data } = await this.rawClient.GET("/v1/knowledge-base/{id}/draft/", {
|
|
89
|
+
params: {
|
|
90
|
+
path: { id: knowledgeBaseId },
|
|
91
|
+
query: { organization_id: this.organizationId },
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
return data;
|
|
95
|
+
}
|
|
96
|
+
/** Patch the draft's typology/tactic selection. */
|
|
97
|
+
async patchSelection(knowledgeBaseId, selection) {
|
|
98
|
+
validateUuid(knowledgeBaseId, "knowledgeBaseId");
|
|
99
|
+
const body = {
|
|
100
|
+
refs: selection.refs,
|
|
101
|
+
...(selection.suggestedName !== undefined
|
|
102
|
+
? { suggested_name: selection.suggestedName }
|
|
103
|
+
: {}),
|
|
104
|
+
};
|
|
105
|
+
const { data } = await this.rawClient.PATCH("/v1/knowledge-base/{id}/selection/", {
|
|
106
|
+
params: {
|
|
107
|
+
path: { id: knowledgeBaseId },
|
|
108
|
+
query: { organization_id: this.organizationId },
|
|
109
|
+
},
|
|
110
|
+
body,
|
|
111
|
+
});
|
|
112
|
+
return data;
|
|
113
|
+
}
|
|
114
|
+
/** Kick off an async regeneration round with optional feedback. */
|
|
115
|
+
async regenerate(knowledgeBaseId, params) {
|
|
116
|
+
validateUuid(knowledgeBaseId, "knowledgeBaseId");
|
|
117
|
+
const body = {
|
|
118
|
+
...(params?.feedback !== undefined ? { feedback: params.feedback } : {}),
|
|
119
|
+
};
|
|
120
|
+
const { data } = await this.rawClient.POST("/v1/knowledge-base/{id}/regenerate/", {
|
|
121
|
+
params: {
|
|
122
|
+
path: { id: knowledgeBaseId },
|
|
123
|
+
query: { organization_id: this.organizationId },
|
|
124
|
+
},
|
|
125
|
+
body,
|
|
126
|
+
});
|
|
127
|
+
return data;
|
|
128
|
+
}
|
|
129
|
+
/** Approve or decline a pending regeneration proposal. */
|
|
130
|
+
async resolve(knowledgeBaseId, params) {
|
|
131
|
+
validateUuid(knowledgeBaseId, "knowledgeBaseId");
|
|
132
|
+
const body = {
|
|
133
|
+
accept_summary: params?.acceptSummary ?? false,
|
|
134
|
+
discard: params?.discard ?? false,
|
|
135
|
+
...(params?.refs !== undefined ? { refs: params.refs } : {}),
|
|
136
|
+
...(params?.suggestedName !== undefined
|
|
137
|
+
? { suggested_name: params.suggestedName }
|
|
138
|
+
: {}),
|
|
139
|
+
};
|
|
140
|
+
const { data } = await this.rawClient.POST("/v1/knowledge-base/{id}/resolve/", {
|
|
141
|
+
params: {
|
|
142
|
+
path: { id: knowledgeBaseId },
|
|
143
|
+
query: { organization_id: this.organizationId },
|
|
144
|
+
},
|
|
145
|
+
body,
|
|
146
|
+
});
|
|
147
|
+
return data;
|
|
148
|
+
}
|
|
149
|
+
/** Commit the draft into a permanent Atlas lens. */
|
|
150
|
+
async finalize(knowledgeBaseId, params) {
|
|
151
|
+
validateUuid(knowledgeBaseId, "knowledgeBaseId");
|
|
152
|
+
const body = {
|
|
153
|
+
mcp_enabled: params?.mcpEnabled ?? true,
|
|
154
|
+
public: params?.public ?? true,
|
|
155
|
+
...(params?.name !== undefined ? { name: params.name } : {}),
|
|
156
|
+
};
|
|
157
|
+
const { data } = await this.rawClient.POST("/v1/knowledge-base/{id}/finalize/", {
|
|
158
|
+
params: {
|
|
159
|
+
path: { id: knowledgeBaseId },
|
|
160
|
+
query: { organization_id: this.organizationId },
|
|
161
|
+
},
|
|
162
|
+
body,
|
|
163
|
+
});
|
|
164
|
+
return data;
|
|
165
|
+
}
|
|
166
|
+
/** Sync the lens snapshot from Atlas (best-effort). */
|
|
167
|
+
async sync(knowledgeBaseId) {
|
|
168
|
+
validateUuid(knowledgeBaseId, "knowledgeBaseId");
|
|
169
|
+
const { data } = await this.rawClient.POST("/v1/knowledge-base/{id}/sync/", {
|
|
170
|
+
params: {
|
|
171
|
+
path: { id: knowledgeBaseId },
|
|
172
|
+
query: { organization_id: this.organizationId },
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
return data;
|
|
176
|
+
}
|
|
177
|
+
/** Fetch the names-only typology and tactic catalog. */
|
|
178
|
+
async catalog() {
|
|
179
|
+
const { data } = await this.rawClient.GET("/v1/knowledge-base/catalog/", {
|
|
180
|
+
params: { query: { organization_id: this.organizationId } },
|
|
181
|
+
});
|
|
182
|
+
return data;
|
|
183
|
+
}
|
|
184
|
+
/** Fetch and optionally sync a lens by its Atlas ID. */
|
|
185
|
+
async lensByAtlasId(atlasLensId) {
|
|
186
|
+
const { data } = await this.rawClient.GET("/v1/knowledge-base/lens/{atlas_lens_id}/", {
|
|
187
|
+
params: {
|
|
188
|
+
path: { atlas_lens_id: atlasLensId },
|
|
189
|
+
query: { organization_id: this.organizationId },
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
return data;
|
|
193
|
+
}
|
|
194
|
+
/** Import a finalized Atlas lens into roe-main by its atlas_lens_id. */
|
|
195
|
+
async importLens(atlasLensId) {
|
|
196
|
+
const { data } = await this.rawClient.POST("/v1/knowledge-base/import-lens/", {
|
|
197
|
+
params: { query: { organization_id: this.organizationId } },
|
|
198
|
+
body: { atlas_lens_id: atlasLensId },
|
|
199
|
+
});
|
|
200
|
+
return data;
|
|
201
|
+
}
|
|
202
|
+
}
|
package/dist/api/policies.d.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import { RoeConfig } from "../config.js";
|
|
1
|
+
import type { RoeConfig } from "../config.js";
|
|
2
2
|
import type { RoeRawClient } from "../generated/client.js";
|
|
3
3
|
import type { components } from "../generated/schema.js";
|
|
4
|
-
type Policy = components["schemas"]["Policy"];
|
|
5
4
|
type CreatePolicy = components["schemas"]["CreatePolicy"];
|
|
6
|
-
type UpdatePolicy = components["schemas"]["UpdatePolicy"];
|
|
7
|
-
type PolicyVersion = components["schemas"]["PolicyVersion"];
|
|
8
5
|
type PaginatedPolicyList = components["schemas"]["PaginatedPolicyList"];
|
|
6
|
+
type Policy = components["schemas"]["Policy"];
|
|
7
|
+
type PolicyVersion = components["schemas"]["PolicyVersion"];
|
|
8
|
+
type UpdatePolicy = components["schemas"]["UpdatePolicy"];
|
|
9
9
|
export declare class PolicyVersionsAPI {
|
|
10
10
|
private readonly policiesApi;
|
|
11
|
+
/** API for managing the versions of a policy. */
|
|
11
12
|
constructor(policiesApi: PoliciesAPI);
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
protected get rawClient(): RoeRawClient;
|
|
14
|
+
protected get organizationId(): string;
|
|
15
|
+
/** List all versions of a policy. */
|
|
14
16
|
list(policyId: string): Promise<PolicyVersion[]>;
|
|
17
|
+
/** Retrieve a single policy version. */
|
|
15
18
|
retrieve(policyId: string, versionId: string): Promise<PolicyVersion>;
|
|
19
|
+
/** Create a new version of a policy. */
|
|
16
20
|
create(params: {
|
|
17
21
|
policyId: string;
|
|
18
22
|
content: Record<string, unknown>;
|
|
@@ -23,23 +27,36 @@ export declare class PolicyVersionsAPI {
|
|
|
23
27
|
export declare class PoliciesAPI {
|
|
24
28
|
readonly config: RoeConfig;
|
|
25
29
|
readonly raw: RoeRawClient;
|
|
30
|
+
/** API for managing Roe policies and their versions. */
|
|
26
31
|
readonly versions: PolicyVersionsAPI;
|
|
27
32
|
constructor(config: RoeConfig, raw: RoeRawClient);
|
|
33
|
+
protected get rawClient(): RoeRawClient;
|
|
34
|
+
protected get organizationId(): string;
|
|
35
|
+
/** List policies in the organization (paginated). */
|
|
28
36
|
list(params?: {
|
|
29
37
|
page?: number;
|
|
30
38
|
pageSize?: number;
|
|
31
39
|
}): Promise<PaginatedPolicyList>;
|
|
40
|
+
/** Retrieve a single policy by ID. */
|
|
32
41
|
retrieve(policyId: string): Promise<Policy>;
|
|
42
|
+
/** Create a new policy together with its first version. */
|
|
33
43
|
create(params: {
|
|
34
44
|
name: string;
|
|
35
45
|
content: Record<string, unknown>;
|
|
36
46
|
description?: string;
|
|
37
47
|
versionName?: string;
|
|
38
48
|
}): Promise<CreatePolicy>;
|
|
49
|
+
/** Update mutable fields of a policy. */
|
|
39
50
|
update(policyId: string, updates: {
|
|
40
51
|
name?: string;
|
|
41
52
|
description?: string;
|
|
42
53
|
}): Promise<UpdatePolicy>;
|
|
54
|
+
/** Replace a policy. */
|
|
55
|
+
replace(policyId: string, replacement: {
|
|
56
|
+
name: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
}): Promise<UpdatePolicy>;
|
|
59
|
+
/** Delete a policy. */
|
|
43
60
|
delete(policyId: string): Promise<void>;
|
|
44
61
|
}
|
|
45
62
|
export {};
|
package/dist/api/policies.js
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
// Auto-generated friendly API facades for the Roe SDK.
|
|
2
|
+
// Generated by scripts/generate-sdk from openapi/wrappers.yml.
|
|
3
|
+
// Do not edit by hand.
|
|
2
4
|
import { BadRequestError, RoeAPIException } from "../exceptions.js";
|
|
3
|
-
|
|
4
|
-
* Validates that a value is a valid UUID string.
|
|
5
|
-
* @throws BadRequestError if the value is not a valid UUID
|
|
6
|
-
*/
|
|
5
|
+
import { isUuidString } from "../utils/fileDetection.js";
|
|
7
6
|
function validateUuid(value, fieldName) {
|
|
8
7
|
if (!isUuidString(value)) {
|
|
9
8
|
throw new BadRequestError(`Invalid ${fieldName}: "${value}" is not a valid UUID`, 400);
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
11
|
export class PolicyVersionsAPI {
|
|
12
|
+
/** API for managing the versions of a policy. */
|
|
13
13
|
constructor(policiesApi) {
|
|
14
14
|
this.policiesApi = policiesApi;
|
|
15
15
|
}
|
|
16
|
-
get
|
|
16
|
+
get rawClient() {
|
|
17
17
|
return this.policiesApi.raw;
|
|
18
18
|
}
|
|
19
19
|
get organizationId() {
|
|
20
20
|
return this.policiesApi.config.organizationId;
|
|
21
21
|
}
|
|
22
|
+
/** List all versions of a policy. */
|
|
22
23
|
async list(policyId) {
|
|
23
24
|
validateUuid(policyId, "policyId");
|
|
24
|
-
const { data } = await this.
|
|
25
|
+
const { data } = await this.rawClient.GET("/v1/policies/{policy_id}/versions/", {
|
|
25
26
|
params: {
|
|
26
27
|
path: { policy_id: policyId },
|
|
27
28
|
query: { organization_id: this.organizationId },
|
|
28
29
|
},
|
|
29
30
|
});
|
|
30
|
-
return data?.results ?? [];
|
|
31
|
+
return (data?.results ?? []);
|
|
31
32
|
}
|
|
33
|
+
/** Retrieve a single policy version. */
|
|
32
34
|
async retrieve(policyId, versionId) {
|
|
33
35
|
validateUuid(policyId, "policyId");
|
|
34
36
|
validateUuid(versionId, "versionId");
|
|
35
|
-
const { data } = await this.
|
|
37
|
+
const { data } = await this.rawClient.GET("/v1/policies/{policy_id}/versions/{version_id}/", {
|
|
36
38
|
params: {
|
|
37
39
|
path: { policy_id: policyId, version_id: versionId },
|
|
38
40
|
query: { organization_id: this.organizationId },
|
|
@@ -40,18 +42,21 @@ export class PolicyVersionsAPI {
|
|
|
40
42
|
});
|
|
41
43
|
return data;
|
|
42
44
|
}
|
|
45
|
+
/** Create a new version of a policy. */
|
|
43
46
|
async create(params) {
|
|
44
47
|
validateUuid(params.policyId, "policyId");
|
|
45
|
-
if (params.baseVersionId
|
|
48
|
+
if (params.baseVersionId != null)
|
|
46
49
|
validateUuid(params.baseVersionId, "baseVersionId");
|
|
47
50
|
const body = {
|
|
48
51
|
content: params.content,
|
|
52
|
+
...(params.versionName !== undefined
|
|
53
|
+
? { version_name: params.versionName }
|
|
54
|
+
: {}),
|
|
55
|
+
...(params.baseVersionId !== undefined
|
|
56
|
+
? { base_version_id: params.baseVersionId }
|
|
57
|
+
: {}),
|
|
49
58
|
};
|
|
50
|
-
|
|
51
|
-
body.version_name = params.versionName;
|
|
52
|
-
if (params.baseVersionId !== undefined)
|
|
53
|
-
body.base_version_id = params.baseVersionId;
|
|
54
|
-
const { data } = await this.raw.POST("/v1/policies/{policy_id}/versions/", {
|
|
59
|
+
const { data } = await this.rawClient.POST("/v1/policies/{policy_id}/versions/", {
|
|
55
60
|
params: {
|
|
56
61
|
path: { policy_id: params.policyId },
|
|
57
62
|
query: { organization_id: this.organizationId },
|
|
@@ -61,7 +66,6 @@ export class PolicyVersionsAPI {
|
|
|
61
66
|
if (!data?.id) {
|
|
62
67
|
throw new RoeAPIException(`Unexpected response from server: ${JSON.stringify(data)}`);
|
|
63
68
|
}
|
|
64
|
-
// POST returns a partial CreatePolicyVersion; re-fetch to get the full version.
|
|
65
69
|
return this.retrieve(params.policyId, data.id);
|
|
66
70
|
}
|
|
67
71
|
}
|
|
@@ -71,28 +75,39 @@ export class PoliciesAPI {
|
|
|
71
75
|
this.raw = raw;
|
|
72
76
|
this.versions = new PolicyVersionsAPI(this);
|
|
73
77
|
}
|
|
78
|
+
get rawClient() {
|
|
79
|
+
return this.raw;
|
|
80
|
+
}
|
|
81
|
+
get organizationId() {
|
|
82
|
+
return this.config.organizationId;
|
|
83
|
+
}
|
|
84
|
+
/** List policies in the organization (paginated). */
|
|
74
85
|
async list(params) {
|
|
75
|
-
const { data } = await this.
|
|
86
|
+
const { data } = await this.rawClient.GET("/v1/policies/", {
|
|
76
87
|
params: {
|
|
77
88
|
query: {
|
|
78
|
-
organization_id: this.
|
|
79
|
-
page: params?.page,
|
|
80
|
-
|
|
89
|
+
organization_id: this.organizationId,
|
|
90
|
+
...(params?.page !== undefined ? { page: params?.page } : {}),
|
|
91
|
+
...(params?.pageSize !== undefined
|
|
92
|
+
? { page_size: params?.pageSize }
|
|
93
|
+
: {}),
|
|
81
94
|
},
|
|
82
95
|
},
|
|
83
96
|
});
|
|
84
97
|
return data;
|
|
85
98
|
}
|
|
99
|
+
/** Retrieve a single policy by ID. */
|
|
86
100
|
async retrieve(policyId) {
|
|
87
101
|
validateUuid(policyId, "policyId");
|
|
88
|
-
const { data } = await this.
|
|
102
|
+
const { data } = await this.rawClient.GET("/v1/policies/{id}/", {
|
|
89
103
|
params: {
|
|
90
104
|
path: { id: policyId },
|
|
91
|
-
query: { organization_id: this.
|
|
105
|
+
query: { organization_id: this.organizationId },
|
|
92
106
|
},
|
|
93
107
|
});
|
|
94
108
|
return data;
|
|
95
109
|
}
|
|
110
|
+
/** Create a new policy together with its first version. */
|
|
96
111
|
async create(params) {
|
|
97
112
|
const body = {
|
|
98
113
|
name: params.name,
|
|
@@ -100,34 +115,55 @@ export class PoliciesAPI {
|
|
|
100
115
|
description: params.description ?? "",
|
|
101
116
|
version_name: params.versionName ?? "version 1",
|
|
102
117
|
};
|
|
103
|
-
const { data } = await this.
|
|
104
|
-
params: { query: { organization_id: this.
|
|
118
|
+
const { data } = await this.rawClient.POST("/v1/policies/", {
|
|
119
|
+
params: { query: { organization_id: this.organizationId } },
|
|
105
120
|
body,
|
|
106
121
|
});
|
|
107
122
|
return data;
|
|
108
123
|
}
|
|
124
|
+
/** Update mutable fields of a policy. */
|
|
109
125
|
async update(policyId, updates) {
|
|
110
126
|
validateUuid(policyId, "policyId");
|
|
111
|
-
const body = {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
127
|
+
const body = {
|
|
128
|
+
...(updates.name !== undefined ? { name: updates.name } : {}),
|
|
129
|
+
...(updates.description !== undefined
|
|
130
|
+
? { description: updates.description }
|
|
131
|
+
: {}),
|
|
132
|
+
};
|
|
133
|
+
const { data } = await this.rawClient.PATCH("/v1/policies/{id}/", {
|
|
117
134
|
params: {
|
|
118
135
|
path: { id: policyId },
|
|
119
|
-
query: { organization_id: this.
|
|
136
|
+
query: { organization_id: this.organizationId },
|
|
120
137
|
},
|
|
121
138
|
body,
|
|
122
139
|
});
|
|
123
140
|
return data;
|
|
124
141
|
}
|
|
142
|
+
/** Replace a policy. */
|
|
143
|
+
async replace(policyId, replacement) {
|
|
144
|
+
validateUuid(policyId, "policyId");
|
|
145
|
+
const body = {
|
|
146
|
+
name: replacement.name,
|
|
147
|
+
...(replacement.description !== undefined
|
|
148
|
+
? { description: replacement.description }
|
|
149
|
+
: {}),
|
|
150
|
+
};
|
|
151
|
+
const { data } = await this.rawClient.PUT("/v1/policies/{id}/", {
|
|
152
|
+
params: {
|
|
153
|
+
path: { id: policyId },
|
|
154
|
+
query: { organization_id: this.organizationId },
|
|
155
|
+
},
|
|
156
|
+
body,
|
|
157
|
+
});
|
|
158
|
+
return data;
|
|
159
|
+
}
|
|
160
|
+
/** Delete a policy. */
|
|
125
161
|
async delete(policyId) {
|
|
126
162
|
validateUuid(policyId, "policyId");
|
|
127
|
-
await this.
|
|
163
|
+
await this.rawClient.DELETE("/v1/policies/{id}/", {
|
|
128
164
|
params: {
|
|
129
165
|
path: { id: policyId },
|
|
130
|
-
query: { organization_id: this.
|
|
166
|
+
query: { organization_id: this.organizationId },
|
|
131
167
|
},
|
|
132
168
|
});
|
|
133
169
|
}
|
package/dist/api/tables.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ import type { RoeConfig } from "../config.js";
|
|
|
2
2
|
import type { RoeRawClient } from "../generated/client.js";
|
|
3
3
|
import type { components } from "../generated/schema.js";
|
|
4
4
|
import type { FileUpload } from "../models/file.js";
|
|
5
|
+
type TableDescribeResponse = components["schemas"]["TableDescribeResponse"];
|
|
6
|
+
type TableListResponse = components["schemas"]["TableListResponse"];
|
|
7
|
+
type TablePreviewResponse = components["schemas"]["TablePreviewResponse"];
|
|
8
|
+
type TableQueryResultResponse = components["schemas"]["TableQueryResultResponse"];
|
|
9
|
+
type TableQuerySubmitResponse = components["schemas"]["TableQuerySubmitResponse"];
|
|
5
10
|
type TableUploadResponse = components["schemas"]["TableUploadResponse"];
|
|
6
11
|
export type TableUploadFile = string | NodeJS.ReadableStream | FileUpload;
|
|
7
12
|
export type TableUploadParams = {
|
|
@@ -13,9 +18,28 @@ export type TableUploadParams = {
|
|
|
13
18
|
export declare class TablesAPI {
|
|
14
19
|
readonly config: RoeConfig;
|
|
15
20
|
readonly raw: RoeRawClient;
|
|
16
|
-
/** API for
|
|
21
|
+
/** API for managing Roe tables. */
|
|
17
22
|
constructor(config: RoeConfig, raw: RoeRawClient);
|
|
23
|
+
protected get rawClient(): RoeRawClient;
|
|
24
|
+
protected get organizationId(): string;
|
|
25
|
+
/** List Roe tables. */
|
|
26
|
+
list(): Promise<TableListResponse>;
|
|
18
27
|
/** Upload a CSV file and create a Roe table. */
|
|
19
28
|
upload(params: TableUploadParams): Promise<TableUploadResponse>;
|
|
29
|
+
/** Run a read-only query against Roe tables. */
|
|
30
|
+
query(params: {
|
|
31
|
+
sql: string;
|
|
32
|
+
limit?: number;
|
|
33
|
+
}): Promise<TableQuerySubmitResponse>;
|
|
34
|
+
/** Get the result for a submitted table query. */
|
|
35
|
+
queryResult(tableQueryId: string): Promise<TableQueryResultResponse>;
|
|
36
|
+
/** Describe a Roe table. */
|
|
37
|
+
describe(tableName: string): Promise<TableDescribeResponse>;
|
|
38
|
+
/** Preview rows from a Roe table. */
|
|
39
|
+
preview(tableName: string, options?: {
|
|
40
|
+
limit?: number;
|
|
41
|
+
}): Promise<TablePreviewResponse>;
|
|
42
|
+
/** Delete a Roe table. */
|
|
43
|
+
delete(tableName: string): Promise<void>;
|
|
20
44
|
}
|
|
21
45
|
export {};
|
package/dist/api/tables.js
CHANGED
|
@@ -4,11 +4,22 @@
|
|
|
4
4
|
import { RoeAPIException } from "../exceptions.js";
|
|
5
5
|
import { postDynamicInputs } from "../utils/dynamicInputs.js";
|
|
6
6
|
export class TablesAPI {
|
|
7
|
-
/** API for
|
|
7
|
+
/** API for managing Roe tables. */
|
|
8
8
|
constructor(config, raw) {
|
|
9
9
|
this.config = config;
|
|
10
10
|
this.raw = raw;
|
|
11
11
|
}
|
|
12
|
+
get rawClient() {
|
|
13
|
+
return this.raw;
|
|
14
|
+
}
|
|
15
|
+
get organizationId() {
|
|
16
|
+
return this.config.organizationId;
|
|
17
|
+
}
|
|
18
|
+
/** List Roe tables. */
|
|
19
|
+
async list() {
|
|
20
|
+
const { data } = await this.rawClient.GET("/v1/tables/", {});
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
12
23
|
/** Upload a CSV file and create a Roe table. */
|
|
13
24
|
async upload(params) {
|
|
14
25
|
const inputs = {
|
|
@@ -23,4 +34,41 @@ export class TablesAPI {
|
|
|
23
34
|
}
|
|
24
35
|
return data;
|
|
25
36
|
}
|
|
37
|
+
/** Run a read-only query against Roe tables. */
|
|
38
|
+
async query(params) {
|
|
39
|
+
const body = {
|
|
40
|
+
sql: params.sql,
|
|
41
|
+
limit: params.limit ?? 1000,
|
|
42
|
+
};
|
|
43
|
+
const { data } = await this.rawClient.POST("/v1/tables/query/", { body });
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
/** Get the result for a submitted table query. */
|
|
47
|
+
async queryResult(tableQueryId) {
|
|
48
|
+
const { data } = await this.rawClient.GET("/v1/tables/query/{table_query_id}/result/", { params: { path: { table_query_id: tableQueryId } } });
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
51
|
+
/** Describe a Roe table. */
|
|
52
|
+
async describe(tableName) {
|
|
53
|
+
const { data } = await this.rawClient.GET("/v1/tables/{table_name}/describe/", { params: { path: { table_name: tableName } } });
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
/** Preview rows from a Roe table. */
|
|
57
|
+
async preview(tableName, options) {
|
|
58
|
+
const { data } = await this.rawClient.GET("/v1/tables/{table_name}/preview/", {
|
|
59
|
+
params: {
|
|
60
|
+
path: { table_name: tableName },
|
|
61
|
+
query: {
|
|
62
|
+
...(options?.limit !== undefined ? { limit: options?.limit } : {}),
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
return data;
|
|
67
|
+
}
|
|
68
|
+
/** Delete a Roe table. */
|
|
69
|
+
async delete(tableName) {
|
|
70
|
+
await this.rawClient.DELETE("/v1/tables/{table_name}/", {
|
|
71
|
+
params: { path: { table_name: tableName } },
|
|
72
|
+
});
|
|
73
|
+
}
|
|
26
74
|
}
|
package/dist/auth.d.ts
CHANGED
package/dist/auth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { readFileSync } from "fs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
4
|
// Resolve the package's own version at runtime so the User-Agent doesn't
|
|
5
5
|
// silently drift across releases when the auto-release pipeline bumps
|
|
6
6
|
// package.json without touching this file. Falls back to "0.0.0" if the
|
package/dist/client.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AgentsAPI } from "./api/agents.js";
|
|
2
1
|
import { type GeneratedApis } from "./api/_generated.js";
|
|
2
|
+
import { AgentsAPI } from "./api/agents.js";
|
|
3
3
|
import { PoliciesAPI } from "./api/policies.js";
|
|
4
4
|
import { UsersAPI } from "./api/users.js";
|
|
5
5
|
import { RoeAuth } from "./auth.js";
|
|
6
|
-
import { RoeConfig, RoeConfigInput } from "./config.js";
|
|
6
|
+
import { RoeConfig, type RoeConfigInput } from "./config.js";
|
|
7
7
|
import { type RoeRawClient } from "./generated/client.js";
|
|
8
8
|
export declare class RoeClient {
|
|
9
9
|
readonly config: RoeConfig;
|