@toshicloud/sdk 0.4.0 → 0.5.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/README.md +102 -19
- package/dist/client.d.ts +40 -4
- package/dist/client.js +35 -4
- package/dist/errors.d.ts +99 -0
- package/dist/errors.js +208 -0
- package/dist/gen/toshi/permission_pb.d.ts +244 -0
- package/dist/gen/toshi/permission_pb.js +94 -0
- package/dist/gen/toshi/workspace/v1/account_pb.d.ts +590 -0
- package/dist/gen/toshi/workspace/v1/account_pb.js +75 -0
- package/dist/gen/toshi/workspace/v1/artifacts_pb.d.ts +14 -8
- package/dist/gen/toshi/workspace/v1/artifacts_pb.js +10 -7
- package/dist/gen/toshi/workspace/v1/audit_events_pb.d.ts +191 -6
- package/dist/gen/toshi/workspace/v1/audit_events_pb.js +12 -1
- package/dist/gen/toshi/workspace/v1/channels_pb.d.ts +1194 -21
- package/dist/gen/toshi/workspace/v1/channels_pb.js +186 -39
- package/dist/gen/toshi/workspace/v1/connections_pb.d.ts +1481 -0
- package/dist/gen/toshi/workspace/v1/connections_pb.js +208 -0
- package/dist/gen/toshi/workspace/v1/discovery_pb.d.ts +924 -0
- package/dist/gen/toshi/workspace/v1/discovery_pb.js +231 -0
- package/dist/gen/toshi/workspace/v1/display_pb.d.ts +198 -15
- package/dist/gen/toshi/workspace/v1/display_pb.js +53 -2
- package/dist/gen/toshi/workspace/v1/domains_pb.d.ts +864 -0
- package/dist/gen/toshi/workspace/v1/domains_pb.js +152 -0
- package/dist/gen/toshi/workspace/v1/fillers_pb.d.ts +12 -4
- package/dist/gen/toshi/workspace/v1/fillers_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/grants_pb.d.ts +1297 -0
- package/dist/gen/toshi/workspace/v1/grants_pb.js +271 -0
- package/dist/gen/toshi/workspace/v1/hostjobs_pb.d.ts +315 -15
- package/dist/gen/toshi/workspace/v1/hostjobs_pb.js +11 -5
- package/dist/gen/toshi/workspace/v1/hosts_pb.d.ts +196 -7
- package/dist/gen/toshi/workspace/v1/hosts_pb.js +13 -7
- package/dist/gen/toshi/workspace/v1/images_pb.d.ts +1463 -0
- package/dist/gen/toshi/workspace/v1/images_pb.js +263 -0
- package/dist/gen/toshi/workspace/v1/products_pb.d.ts +506 -0
- package/dist/gen/toshi/workspace/v1/products_pb.js +60 -0
- package/dist/gen/toshi/workspace/v1/projects_pb.d.ts +1474 -99
- package/dist/gen/toshi/workspace/v1/projects_pb.js +151 -33
- package/dist/gen/toshi/workspace/v1/recordings_pb.d.ts +181 -14
- package/dist/gen/toshi/workspace/v1/recordings_pb.js +55 -14
- package/dist/gen/toshi/workspace/v1/roles_pb.d.ts +1994 -0
- package/dist/gen/toshi/workspace/v1/roles_pb.js +355 -0
- package/dist/gen/toshi/workspace/v1/secrets_pb.d.ts +314 -8
- package/dist/gen/toshi/workspace/v1/secrets_pb.js +43 -18
- package/dist/gen/toshi/workspace/v1/storage_providers_pb.d.ts +14 -0
- package/dist/gen/toshi/workspace/v1/storage_providers_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/tokens_pb.d.ts +434 -5
- package/dist/gen/toshi/workspace/v1/tokens_pb.js +66 -8
- package/dist/gen/toshi/workspace/v1/triggers_pb.d.ts +1099 -0
- package/dist/gen/toshi/workspace/v1/triggers_pb.js +185 -0
- package/dist/gen/toshi/workspace/v1/volumes_pb.d.ts +1052 -33
- package/dist/gen/toshi/workspace/v1/volumes_pb.js +170 -11
- package/dist/gen/toshi/workspace/v1/webhook_pb.d.ts +66 -8
- package/dist/gen/toshi/workspace/v1/webhook_pb.js +5 -4
- package/dist/gen/toshi/workspace/v1/workloads_pb.d.ts +2043 -54
- package/dist/gen/toshi/workspace/v1/workloads_pb.js +205 -54
- package/dist/gen/toshi/workspace/v1/workspace_pb.d.ts +6292 -939
- package/dist/gen/toshi/workspace/v1/workspace_pb.js +801 -88
- package/dist/gen/toshi/workspace/v1/workspace_service_pb.d.ts +2176 -630
- package/dist/gen/toshi/workspace/v1/workspace_service_pb.js +192 -74
- package/dist/index.d.ts +10 -1
- package/dist/index.js +10 -1
- package/dist/interceptors.d.ts +11 -1
- package/dist/interceptors.js +38 -4
- package/dist/retry.d.ts +18 -0
- package/dist/retry.js +228 -22
- package/dist/test/procedures.js +100 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/wait.d.ts +4 -0
- package/dist/wait.js +24 -1
- package/package.json +3 -2
package/dist/errors.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BinaryReader, WireType } from "@bufbuild/protobuf/wire";
|
|
2
|
+
import { ConnectError } from "@connectrpc/connect";
|
|
1
3
|
/** A command that ended non-zero, or was cancelled before it had a status (errors.go:9-26). */
|
|
2
4
|
export class ExitError extends Error {
|
|
3
5
|
/** The execution the exit belongs to. */
|
|
@@ -75,3 +77,209 @@ function describe(cause) {
|
|
|
75
77
|
}
|
|
76
78
|
return "the stream ended";
|
|
77
79
|
}
|
|
80
|
+
/** The reasons a call is refused for a product. */
|
|
81
|
+
export const ProductReason = {
|
|
82
|
+
/**
|
|
83
|
+
* The product is off for the workspace; the code is FailedPrecondition, and
|
|
84
|
+
* `cause` says which input turned it off.
|
|
85
|
+
*/
|
|
86
|
+
Unavailable: "PRODUCT_UNAVAILABLE",
|
|
87
|
+
};
|
|
88
|
+
/** The inputs that turn a product off. */
|
|
89
|
+
export const ProductCause = {
|
|
90
|
+
/** The deployment's build does not include the product. */
|
|
91
|
+
Build: "build",
|
|
92
|
+
/** The deployment's config turns the product off. */
|
|
93
|
+
Operator: "operator",
|
|
94
|
+
/** The workspace's plan leaves the product out. */
|
|
95
|
+
Plan: "plan",
|
|
96
|
+
/** The workspace's settings turn the product off. */
|
|
97
|
+
Workspace: "workspace",
|
|
98
|
+
};
|
|
99
|
+
const productReasons = new Set(Object.values(ProductReason));
|
|
100
|
+
/** The reasons the API names on a refusal that is not a product's. */
|
|
101
|
+
export const RefusalReason = {
|
|
102
|
+
/** The Windows VM takes no display input; the code is FailedPrecondition. */
|
|
103
|
+
DisplayInputNotEnabled: "DISPLAY_INPUT_NOT_ENABLED",
|
|
104
|
+
/** The image already has a build running; the code is FailedPrecondition. */
|
|
105
|
+
ImageBuildInProgress: "IMAGE_BUILD_IN_PROGRESS",
|
|
106
|
+
/** The registry of the revision's image could not say whether it serves the digest; the code is FailedPrecondition. */
|
|
107
|
+
ImageCheckFailed: "IMAGE_CHECK_FAILED",
|
|
108
|
+
/** A workload or a service revision still uses the image; the code is FailedPrecondition. */
|
|
109
|
+
ImageInUse: "IMAGE_IN_USE",
|
|
110
|
+
/** Another live image of the workspace has the name; the code is AlreadyExists. */
|
|
111
|
+
ImageNameTaken: "IMAGE_NAME_TAKEN",
|
|
112
|
+
/** A workspace image named by a job, a sandbox or a service revision has no ready version; the code is FailedPrecondition. */
|
|
113
|
+
ImageNotReady: "IMAGE_NOT_READY",
|
|
114
|
+
/** The revision's registry answered that it does not serve the image digest; the code is FailedPrecondition. */
|
|
115
|
+
ImageNotServed: "IMAGE_NOT_SERVED",
|
|
116
|
+
/** The call would remove the caller's last identity; the code is FailedPrecondition. */
|
|
117
|
+
LastIdentity: "LAST_IDENTITY",
|
|
118
|
+
/** The call would remove the workspace's last member; the code is FailedPrecondition. */
|
|
119
|
+
LastMember: "LAST_MEMBER",
|
|
120
|
+
/** The call would leave the workspace without an owner; the code is FailedPrecondition. */
|
|
121
|
+
LastOwner: "LAST_OWNER",
|
|
122
|
+
/** A role change names a permission the caller does not hold where the role applies; the code is PermissionDenied. */
|
|
123
|
+
PermissionMissing: "PERMISSION_MISSING",
|
|
124
|
+
/** The workspace's plan does not include images; the code is FailedPrecondition. */
|
|
125
|
+
PlanExcludesImages: "PLAN_EXCLUDES_IMAGES",
|
|
126
|
+
/** A Windows job Toshi licenses opens no display session; the code is FailedPrecondition. */
|
|
127
|
+
ToshiLicensedWindows: "TOSHI_LICENSED_WINDOWS",
|
|
128
|
+
};
|
|
129
|
+
const refusalReasons = new Set(Object.values(RefusalReason));
|
|
130
|
+
// The ErrorInfo domain of the API's refusals.
|
|
131
|
+
const errorInfoDomain = "toshi.run";
|
|
132
|
+
/**
|
|
133
|
+
* The API's refusal of a call for a product that is off for the workspace.
|
|
134
|
+
* Every call the client makes throws it in place of the ConnectError, wait,
|
|
135
|
+
* watch and execute included. It is a ConnectError, so `instanceof
|
|
136
|
+
* ConnectError` and `code` read as before; test for it with
|
|
137
|
+
* {@link isProductError}.
|
|
138
|
+
*/
|
|
139
|
+
export class ProductError extends ConnectError {
|
|
140
|
+
/** The product's ID, such as `runners`. */
|
|
141
|
+
product;
|
|
142
|
+
reason;
|
|
143
|
+
/** The input that turned the product off, the refusal's `cause` metadata: `build`, `operator`, `plan` or `workspace`. */
|
|
144
|
+
productCause;
|
|
145
|
+
/** How far a product the deployment turns off has wound down: `no_new_work`, `draining` or `stopped`; empty otherwise. */
|
|
146
|
+
state;
|
|
147
|
+
constructor(err, reason, metadata) {
|
|
148
|
+
super(err.rawMessage, err.code, err.metadata, undefined, err);
|
|
149
|
+
// ConnectError's instanceof accepts a subclass only by this name.
|
|
150
|
+
this.name = "ConnectError";
|
|
151
|
+
this.details = err.details;
|
|
152
|
+
this.product = metadata.get("product") ?? "";
|
|
153
|
+
this.reason = reason;
|
|
154
|
+
this.productCause = (metadata.get("cause") ?? "");
|
|
155
|
+
this.state = metadata.get("state") ?? "";
|
|
156
|
+
}
|
|
157
|
+
// ConnectError's own check would accept any ConnectError.
|
|
158
|
+
static [Symbol.hasInstance](v) {
|
|
159
|
+
return Function.prototype[Symbol.hasInstance].call(ProductError, v);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/** Reports whether err is a product's refusal. */
|
|
163
|
+
export function isProductError(err) {
|
|
164
|
+
return err instanceof ProductError;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* The API's refusal that names a reason: an image still in use, a plan
|
|
168
|
+
* without images, a last identity, a rollback whose revision's image is gone,
|
|
169
|
+
* and the rest of {@link RefusalReason}. Every call the client makes throws
|
|
170
|
+
* it in place of the ConnectError. It is a ConnectError, so `instanceof
|
|
171
|
+
* ConnectError` and `code` read as before; test for it with
|
|
172
|
+
* {@link isRefusalError}.
|
|
173
|
+
*/
|
|
174
|
+
export class RefusalError extends ConnectError {
|
|
175
|
+
reason;
|
|
176
|
+
constructor(err, reason) {
|
|
177
|
+
super(err.rawMessage, err.code, err.metadata, undefined, err);
|
|
178
|
+
// ConnectError's instanceof accepts a subclass only by this name.
|
|
179
|
+
this.name = "ConnectError";
|
|
180
|
+
this.details = err.details;
|
|
181
|
+
this.reason = reason;
|
|
182
|
+
}
|
|
183
|
+
// ConnectError's own check would accept any ConnectError.
|
|
184
|
+
static [Symbol.hasInstance](v) {
|
|
185
|
+
return Function.prototype[Symbol.hasInstance].call(RefusalError, v);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/** Reports whether err is a refusal that names a reason this module knows. */
|
|
189
|
+
export function isRefusalError(err) {
|
|
190
|
+
return err instanceof RefusalError;
|
|
191
|
+
}
|
|
192
|
+
/** err as a ProductError when it is a product's refusal, and err unchanged otherwise. */
|
|
193
|
+
export function asProductError(err) {
|
|
194
|
+
if (!(err instanceof ConnectError) || err instanceof ProductError) {
|
|
195
|
+
return err;
|
|
196
|
+
}
|
|
197
|
+
for (const detail of err.details) {
|
|
198
|
+
if (!("type" in detail) || detail.type !== "google.rpc.ErrorInfo") {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const info = decodeErrorInfo(detail.value);
|
|
202
|
+
if (info === undefined || info.domain !== errorInfoDomain || !productReasons.has(info.reason)) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
return new ProductError(err, info.reason, info.metadata);
|
|
206
|
+
}
|
|
207
|
+
return err;
|
|
208
|
+
}
|
|
209
|
+
/** err as a RefusalError when it is a refusal that names a reason this module knows, and err unchanged otherwise. */
|
|
210
|
+
export function asRefusalError(err) {
|
|
211
|
+
if (!(err instanceof ConnectError) || err instanceof RefusalError) {
|
|
212
|
+
return err;
|
|
213
|
+
}
|
|
214
|
+
for (const detail of err.details) {
|
|
215
|
+
if (!("type" in detail) || detail.type !== "google.rpc.ErrorInfo") {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
const info = decodeErrorInfo(detail.value);
|
|
219
|
+
if (info === undefined || info.domain !== errorInfoDomain || !refusalReasons.has(info.reason)) {
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
return new RefusalError(err, info.reason);
|
|
223
|
+
}
|
|
224
|
+
return err;
|
|
225
|
+
}
|
|
226
|
+
/** err as one of this module's typed errors when the API's ErrorInfo detail names a reason it knows, and err unchanged otherwise. */
|
|
227
|
+
export function asTypedError(err) {
|
|
228
|
+
return asRefusalError(asProductError(err));
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Reads a google.rpc.ErrorInfo message: reason (1), domain (2) and metadata
|
|
232
|
+
* (3), a map of strings. It reads the wire format itself, so the SDK needs no
|
|
233
|
+
* package for the googleapis types.
|
|
234
|
+
*/
|
|
235
|
+
function decodeErrorInfo(bytes) {
|
|
236
|
+
const info = { reason: "", domain: "", metadata: new Map() };
|
|
237
|
+
try {
|
|
238
|
+
const reader = new BinaryReader(bytes);
|
|
239
|
+
while (reader.pos < reader.len) {
|
|
240
|
+
const [field, wireType] = reader.tag();
|
|
241
|
+
if (wireType !== WireType.LengthDelimited) {
|
|
242
|
+
reader.skip(wireType);
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
switch (field) {
|
|
246
|
+
case 1:
|
|
247
|
+
info.reason = reader.string();
|
|
248
|
+
break;
|
|
249
|
+
case 2:
|
|
250
|
+
info.domain = reader.string();
|
|
251
|
+
break;
|
|
252
|
+
case 3: {
|
|
253
|
+
const [key, value] = decodeMapEntry(reader.bytes());
|
|
254
|
+
info.metadata.set(key, value);
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
default:
|
|
258
|
+
reader.skip(wireType);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
return info;
|
|
266
|
+
}
|
|
267
|
+
/** Reads one entry of a map<string, string>: key (1), value (2). */
|
|
268
|
+
function decodeMapEntry(bytes) {
|
|
269
|
+
let key = "";
|
|
270
|
+
let value = "";
|
|
271
|
+
const reader = new BinaryReader(bytes);
|
|
272
|
+
while (reader.pos < reader.len) {
|
|
273
|
+
const [field, wireType] = reader.tag();
|
|
274
|
+
if (wireType === WireType.LengthDelimited && field === 1) {
|
|
275
|
+
key = reader.string();
|
|
276
|
+
}
|
|
277
|
+
else if (wireType === WireType.LengthDelimited && field === 2) {
|
|
278
|
+
value = reader.string();
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
reader.skip(wireType);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return [key, value];
|
|
285
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import type { GenExtension, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2";
|
|
2
|
+
import type { FieldOptions, MethodOptions } from "@bufbuild/protobuf/wkt";
|
|
3
|
+
import type { Message } from "@bufbuild/protobuf";
|
|
4
|
+
/**
|
|
5
|
+
* Describes the file toshi/permission.proto.
|
|
6
|
+
*/
|
|
7
|
+
export declare const file_toshi_permission: GenFile;
|
|
8
|
+
/**
|
|
9
|
+
* Audit is the audit event a call records.
|
|
10
|
+
*
|
|
11
|
+
* @generated from message toshi.Audit
|
|
12
|
+
*/
|
|
13
|
+
export type Audit = Message<"toshi.Audit"> & {
|
|
14
|
+
/**
|
|
15
|
+
* action is "<noun>.<verb>" with the verb in the past tense. Unset, it is
|
|
16
|
+
* the method's name: CreateSandbox records "sandbox.created". The build
|
|
17
|
+
* fails a method whose verb it cannot put in the past tense, or whose name
|
|
18
|
+
* gives the action this field names. "none" records nothing, for a call
|
|
19
|
+
* no Workspace API caller makes, such as a workload's upload.
|
|
20
|
+
*
|
|
21
|
+
* @generated from field: string action = 1;
|
|
22
|
+
*/
|
|
23
|
+
action: string;
|
|
24
|
+
/**
|
|
25
|
+
* target is what the call acts on, as "<kind>:<source>", or "none". Unset,
|
|
26
|
+
* the kind is the action's noun and the source the response's id for a
|
|
27
|
+
* call that creates (Create, Reserve, Open) and the request's id
|
|
28
|
+
* otherwise: "id" or "<kind>_id", or for a create "<kind>.id" of the
|
|
29
|
+
* response. A source is a request field path, such as "job_id" or
|
|
30
|
+
* "start.sandbox_id", a response field path after "response.", such as
|
|
31
|
+
* "response.endpoint.id", "workspace" for the call's workspace, or
|
|
32
|
+
* "project" for the project the call resolved.
|
|
33
|
+
*
|
|
34
|
+
* @generated from field: string target = 2;
|
|
35
|
+
*/
|
|
36
|
+
target: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Audit is the audit event a call records.
|
|
40
|
+
*
|
|
41
|
+
* @generated from message toshi.Audit
|
|
42
|
+
*/
|
|
43
|
+
export type AuditJson = {
|
|
44
|
+
/**
|
|
45
|
+
* action is "<noun>.<verb>" with the verb in the past tense. Unset, it is
|
|
46
|
+
* the method's name: CreateSandbox records "sandbox.created". The build
|
|
47
|
+
* fails a method whose verb it cannot put in the past tense, or whose name
|
|
48
|
+
* gives the action this field names. "none" records nothing, for a call
|
|
49
|
+
* no Workspace API caller makes, such as a workload's upload.
|
|
50
|
+
*
|
|
51
|
+
* @generated from field: string action = 1;
|
|
52
|
+
*/
|
|
53
|
+
action?: string;
|
|
54
|
+
/**
|
|
55
|
+
* target is what the call acts on, as "<kind>:<source>", or "none". Unset,
|
|
56
|
+
* the kind is the action's noun and the source the response's id for a
|
|
57
|
+
* call that creates (Create, Reserve, Open) and the request's id
|
|
58
|
+
* otherwise: "id" or "<kind>_id", or for a create "<kind>.id" of the
|
|
59
|
+
* response. A source is a request field path, such as "job_id" or
|
|
60
|
+
* "start.sandbox_id", a response field path after "response.", such as
|
|
61
|
+
* "response.endpoint.id", "workspace" for the call's workspace, or
|
|
62
|
+
* "project" for the project the call resolved.
|
|
63
|
+
*
|
|
64
|
+
* @generated from field: string target = 2;
|
|
65
|
+
*/
|
|
66
|
+
target?: string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Describes the message toshi.Audit.
|
|
70
|
+
* Use `create(AuditSchema)` to create a new message.
|
|
71
|
+
*/
|
|
72
|
+
export declare const AuditSchema: GenMessage<Audit, {
|
|
73
|
+
jsonType: AuditJson;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* MCP is how a call appears as a tool of the MCP server: each hint that is
|
|
77
|
+
* set replaces the one the generator's rules give, and exclude leaves the
|
|
78
|
+
* call out of the tool list.
|
|
79
|
+
*
|
|
80
|
+
* @generated from message toshi.MCP
|
|
81
|
+
*/
|
|
82
|
+
export type MCP = Message<"toshi.MCP"> & {
|
|
83
|
+
/**
|
|
84
|
+
* read_only is the tool's readOnlyHint: the call changes nothing.
|
|
85
|
+
*
|
|
86
|
+
* @generated from field: optional bool read_only = 1;
|
|
87
|
+
*/
|
|
88
|
+
readOnly?: boolean | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* destructive is the tool's destructiveHint: the call may end or remove
|
|
91
|
+
* something it cannot bring back.
|
|
92
|
+
*
|
|
93
|
+
* @generated from field: optional bool destructive = 2;
|
|
94
|
+
*/
|
|
95
|
+
destructive?: boolean | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* idempotent is the tool's idempotentHint: a second call with the same
|
|
98
|
+
* input changes nothing more.
|
|
99
|
+
*
|
|
100
|
+
* @generated from field: optional bool idempotent = 3;
|
|
101
|
+
*/
|
|
102
|
+
idempotent?: boolean | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* open_world is the tool's openWorldHint: the call reaches past the
|
|
105
|
+
* workspace, such as a workload that reaches what its network policy
|
|
106
|
+
* allows.
|
|
107
|
+
*
|
|
108
|
+
* @generated from field: optional bool open_world = 4;
|
|
109
|
+
*/
|
|
110
|
+
openWorld?: boolean | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* exclude leaves the call out, for a call that makes no sense as a tool,
|
|
113
|
+
* such as one only a workload's own token may make.
|
|
114
|
+
*
|
|
115
|
+
* @generated from field: bool exclude = 5;
|
|
116
|
+
*/
|
|
117
|
+
exclude: boolean;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* MCP is how a call appears as a tool of the MCP server: each hint that is
|
|
121
|
+
* set replaces the one the generator's rules give, and exclude leaves the
|
|
122
|
+
* call out of the tool list.
|
|
123
|
+
*
|
|
124
|
+
* @generated from message toshi.MCP
|
|
125
|
+
*/
|
|
126
|
+
export type MCPJson = {
|
|
127
|
+
/**
|
|
128
|
+
* read_only is the tool's readOnlyHint: the call changes nothing.
|
|
129
|
+
*
|
|
130
|
+
* @generated from field: optional bool read_only = 1;
|
|
131
|
+
*/
|
|
132
|
+
readOnly?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* destructive is the tool's destructiveHint: the call may end or remove
|
|
135
|
+
* something it cannot bring back.
|
|
136
|
+
*
|
|
137
|
+
* @generated from field: optional bool destructive = 2;
|
|
138
|
+
*/
|
|
139
|
+
destructive?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* idempotent is the tool's idempotentHint: a second call with the same
|
|
142
|
+
* input changes nothing more.
|
|
143
|
+
*
|
|
144
|
+
* @generated from field: optional bool idempotent = 3;
|
|
145
|
+
*/
|
|
146
|
+
idempotent?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* open_world is the tool's openWorldHint: the call reaches past the
|
|
149
|
+
* workspace, such as a workload that reaches what its network policy
|
|
150
|
+
* allows.
|
|
151
|
+
*
|
|
152
|
+
* @generated from field: optional bool open_world = 4;
|
|
153
|
+
*/
|
|
154
|
+
openWorld?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* exclude leaves the call out, for a call that makes no sense as a tool,
|
|
157
|
+
* such as one only a workload's own token may make.
|
|
158
|
+
*
|
|
159
|
+
* @generated from field: bool exclude = 5;
|
|
160
|
+
*/
|
|
161
|
+
exclude?: boolean;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Describes the message toshi.MCP.
|
|
165
|
+
* Use `create(MCPSchema)` to create a new message.
|
|
166
|
+
*/
|
|
167
|
+
export declare const MCPSchema: GenMessage<MCP, {
|
|
168
|
+
jsonType: MCPJson;
|
|
169
|
+
}>;
|
|
170
|
+
/**
|
|
171
|
+
* permission names what a caller needs to make the call: an area and a
|
|
172
|
+
* level. "<area>.read" sees what the area holds and "<area>.write" changes
|
|
173
|
+
* it, where the area is a product, such as "sandboxes", or a part of the
|
|
174
|
+
* workspace, such as "secrets". A call that needs more than its area's
|
|
175
|
+
* level names a permission of its own, such as "debug.connect" for the key
|
|
176
|
+
* into a host job's debug session.
|
|
177
|
+
*
|
|
178
|
+
* Every Workspace API method carries it, and a method without it fails the
|
|
179
|
+
* build: the control plane's check table and the permissions page are
|
|
180
|
+
* generated from it. A workspace that is suspended keeps the calls whose
|
|
181
|
+
* level is "read".
|
|
182
|
+
*
|
|
183
|
+
* @generated from extension: string permission = 51000;
|
|
184
|
+
*/
|
|
185
|
+
export declare const permission: GenExtension<MethodOptions, string>;
|
|
186
|
+
/**
|
|
187
|
+
* scope names what a call acts in: "workspace", the default when the
|
|
188
|
+
* option is absent, or "project" or "environment" for a call that names a
|
|
189
|
+
* project or an environment of the workspace, or a resource that belongs
|
|
190
|
+
* to one. A token limited to a project, or to one of its environments,
|
|
191
|
+
* makes only the calls whose scope is "project" or "environment".
|
|
192
|
+
*
|
|
193
|
+
* A method whose request has a project or environment field (project,
|
|
194
|
+
* project_id, environment, environment_id) names its scope, and the build
|
|
195
|
+
* checks it against that field: "environment" when the request has an
|
|
196
|
+
* environment field, "project" when it has only a project field, or
|
|
197
|
+
* "workspace" when the field is not where the call acts, such as the
|
|
198
|
+
* project a new token is limited to.
|
|
199
|
+
*
|
|
200
|
+
* @generated from extension: string scope = 51001;
|
|
201
|
+
*/
|
|
202
|
+
export declare const scope: GenExtension<MethodOptions, string>;
|
|
203
|
+
/**
|
|
204
|
+
* audit names the audit event a call records when its action or target
|
|
205
|
+
* is not the one its name gives. Every call that changes something
|
|
206
|
+
* records one event: on the Workspace API a call whose permission's level
|
|
207
|
+
* is not "read", on the operator API a call whose verb is not a read
|
|
208
|
+
* (Get, List, Watch, Wait, Summarise, Suggest, Export, Discover). A read
|
|
209
|
+
* whose option names an action records one too.
|
|
210
|
+
*
|
|
211
|
+
* @generated from extension: toshi.Audit audit = 51002;
|
|
212
|
+
*/
|
|
213
|
+
export declare const audit: GenExtension<MethodOptions, Audit>;
|
|
214
|
+
/**
|
|
215
|
+
* by_field marks an update call that needs no permission of its own: each
|
|
216
|
+
* field its mask names needs its field group's permission, the field's
|
|
217
|
+
* field_permission or, for a field without one, the method's permission.
|
|
218
|
+
* The caller needs at least one of them to make the call, and the
|
|
219
|
+
* handler checks each field the mask names before it writes; a mask that
|
|
220
|
+
* names nothing needs any one.
|
|
221
|
+
*
|
|
222
|
+
* @generated from extension: bool by_field = 51004;
|
|
223
|
+
*/
|
|
224
|
+
export declare const by_field: GenExtension<MethodOptions, boolean>;
|
|
225
|
+
/**
|
|
226
|
+
* mcp sets how the call appears as a tool of the MCP server, where the
|
|
227
|
+
* rules its generator applies give the wrong answer. Without it a call
|
|
228
|
+
* whose permission's level is "read" is read-only and idempotent, a call
|
|
229
|
+
* whose name begins with Delete, Cancel, Revoke, Remove, Stop or Rollback
|
|
230
|
+
* is destructive, and no call reaches outside the workspace.
|
|
231
|
+
*
|
|
232
|
+
* @generated from extension: toshi.MCP mcp = 51005;
|
|
233
|
+
*/
|
|
234
|
+
export declare const mcp: GenExtension<MethodOptions, MCP>;
|
|
235
|
+
/**
|
|
236
|
+
* field_permission names what a caller needs to change the field through
|
|
237
|
+
* the mask of an update call marked by_field: a field group of its own,
|
|
238
|
+
* such as "billing.write" for a workspace's spending limits. A field
|
|
239
|
+
* without it needs the method's permission. The build checks the name's
|
|
240
|
+
* shape, and the permissions page lists the field groups.
|
|
241
|
+
*
|
|
242
|
+
* @generated from extension: string field_permission = 51003;
|
|
243
|
+
*/
|
|
244
|
+
export declare const field_permission: GenExtension<FieldOptions, string>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// @generated by protoc-gen-es v2.16.0 with parameter "target=ts,json_types=true,import_extension=js"
|
|
2
|
+
// @generated from file toshi/permission.proto (package toshi, syntax proto3)
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
import { extDesc, fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2";
|
|
5
|
+
import { file_google_protobuf_descriptor } from "@bufbuild/protobuf/wkt";
|
|
6
|
+
/**
|
|
7
|
+
* Describes the file toshi/permission.proto.
|
|
8
|
+
*/
|
|
9
|
+
export const file_toshi_permission = /*@__PURE__*/ fileDesc("ChZ0b3NoaS9wZXJtaXNzaW9uLnByb3RvEgV0b3NoaSInCgVBdWRpdBIOCgZhY3Rpb24YASABKAkSDgoGdGFyZ2V0GAIgASgJIrYBCgNNQ1ASFgoJcmVhZF9vbmx5GAEgASgISACIAQESGAoLZGVzdHJ1Y3RpdmUYAiABKAhIAYgBARIXCgppZGVtcG90ZW50GAMgASgISAKIAQESFwoKb3Blbl93b3JsZBgEIAEoCEgDiAEBEg8KB2V4Y2x1ZGUYBSABKAhCDAoKX3JlYWRfb25seUIOCgxfZGVzdHJ1Y3RpdmVCDQoLX2lkZW1wb3RlbnRCDQoLX29wZW5fd29ybGQ6QAoKcGVybWlzc2lvbhIeLmdvb2dsZS5wcm90b2J1Zi5NZXRob2RPcHRpb25zGLiOAyABKAlSCnBlcm1pc3Npb246NgoFc2NvcGUSHi5nb29nbGUucHJvdG9idWYuTWV0aG9kT3B0aW9ucxi5jgMgASgJUgVzY29wZTpECgVhdWRpdBIeLmdvb2dsZS5wcm90b2J1Zi5NZXRob2RPcHRpb25zGLqOAyABKAsyDC50b3NoaS5BdWRpdFIFYXVkaXQ6OwoIYnlfZmllbGQSHi5nb29nbGUucHJvdG9idWYuTWV0aG9kT3B0aW9ucxi8jgMgASgIUgdieUZpZWxkOj4KA21jcBIeLmdvb2dsZS5wcm90b2J1Zi5NZXRob2RPcHRpb25zGL2OAyABKAsyCi50b3NoaS5NQ1BSA21jcDpKChBmaWVsZF9wZXJtaXNzaW9uEh0uZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucxi7jgMgASgJUg9maWVsZFBlcm1pc3Npb25CHlocZ28udG9zaGljbG91ZC5pby9hcGkvdG9zaGlwYmIGcHJvdG8z", [file_google_protobuf_descriptor]);
|
|
10
|
+
/**
|
|
11
|
+
* Describes the message toshi.Audit.
|
|
12
|
+
* Use `create(AuditSchema)` to create a new message.
|
|
13
|
+
*/
|
|
14
|
+
export const AuditSchema = /*@__PURE__*/ messageDesc(file_toshi_permission, 0);
|
|
15
|
+
/**
|
|
16
|
+
* Describes the message toshi.MCP.
|
|
17
|
+
* Use `create(MCPSchema)` to create a new message.
|
|
18
|
+
*/
|
|
19
|
+
export const MCPSchema = /*@__PURE__*/ messageDesc(file_toshi_permission, 1);
|
|
20
|
+
/**
|
|
21
|
+
* permission names what a caller needs to make the call: an area and a
|
|
22
|
+
* level. "<area>.read" sees what the area holds and "<area>.write" changes
|
|
23
|
+
* it, where the area is a product, such as "sandboxes", or a part of the
|
|
24
|
+
* workspace, such as "secrets". A call that needs more than its area's
|
|
25
|
+
* level names a permission of its own, such as "debug.connect" for the key
|
|
26
|
+
* into a host job's debug session.
|
|
27
|
+
*
|
|
28
|
+
* Every Workspace API method carries it, and a method without it fails the
|
|
29
|
+
* build: the control plane's check table and the permissions page are
|
|
30
|
+
* generated from it. A workspace that is suspended keeps the calls whose
|
|
31
|
+
* level is "read".
|
|
32
|
+
*
|
|
33
|
+
* @generated from extension: string permission = 51000;
|
|
34
|
+
*/
|
|
35
|
+
export const permission = /*@__PURE__*/ extDesc(file_toshi_permission, 0);
|
|
36
|
+
/**
|
|
37
|
+
* scope names what a call acts in: "workspace", the default when the
|
|
38
|
+
* option is absent, or "project" or "environment" for a call that names a
|
|
39
|
+
* project or an environment of the workspace, or a resource that belongs
|
|
40
|
+
* to one. A token limited to a project, or to one of its environments,
|
|
41
|
+
* makes only the calls whose scope is "project" or "environment".
|
|
42
|
+
*
|
|
43
|
+
* A method whose request has a project or environment field (project,
|
|
44
|
+
* project_id, environment, environment_id) names its scope, and the build
|
|
45
|
+
* checks it against that field: "environment" when the request has an
|
|
46
|
+
* environment field, "project" when it has only a project field, or
|
|
47
|
+
* "workspace" when the field is not where the call acts, such as the
|
|
48
|
+
* project a new token is limited to.
|
|
49
|
+
*
|
|
50
|
+
* @generated from extension: string scope = 51001;
|
|
51
|
+
*/
|
|
52
|
+
export const scope = /*@__PURE__*/ extDesc(file_toshi_permission, 1);
|
|
53
|
+
/**
|
|
54
|
+
* audit names the audit event a call records when its action or target
|
|
55
|
+
* is not the one its name gives. Every call that changes something
|
|
56
|
+
* records one event: on the Workspace API a call whose permission's level
|
|
57
|
+
* is not "read", on the operator API a call whose verb is not a read
|
|
58
|
+
* (Get, List, Watch, Wait, Summarise, Suggest, Export, Discover). A read
|
|
59
|
+
* whose option names an action records one too.
|
|
60
|
+
*
|
|
61
|
+
* @generated from extension: toshi.Audit audit = 51002;
|
|
62
|
+
*/
|
|
63
|
+
export const audit = /*@__PURE__*/ extDesc(file_toshi_permission, 2);
|
|
64
|
+
/**
|
|
65
|
+
* by_field marks an update call that needs no permission of its own: each
|
|
66
|
+
* field its mask names needs its field group's permission, the field's
|
|
67
|
+
* field_permission or, for a field without one, the method's permission.
|
|
68
|
+
* The caller needs at least one of them to make the call, and the
|
|
69
|
+
* handler checks each field the mask names before it writes; a mask that
|
|
70
|
+
* names nothing needs any one.
|
|
71
|
+
*
|
|
72
|
+
* @generated from extension: bool by_field = 51004;
|
|
73
|
+
*/
|
|
74
|
+
export const by_field = /*@__PURE__*/ extDesc(file_toshi_permission, 3);
|
|
75
|
+
/**
|
|
76
|
+
* mcp sets how the call appears as a tool of the MCP server, where the
|
|
77
|
+
* rules its generator applies give the wrong answer. Without it a call
|
|
78
|
+
* whose permission's level is "read" is read-only and idempotent, a call
|
|
79
|
+
* whose name begins with Delete, Cancel, Revoke, Remove, Stop or Rollback
|
|
80
|
+
* is destructive, and no call reaches outside the workspace.
|
|
81
|
+
*
|
|
82
|
+
* @generated from extension: toshi.MCP mcp = 51005;
|
|
83
|
+
*/
|
|
84
|
+
export const mcp = /*@__PURE__*/ extDesc(file_toshi_permission, 4);
|
|
85
|
+
/**
|
|
86
|
+
* field_permission names what a caller needs to change the field through
|
|
87
|
+
* the mask of an update call marked by_field: a field group of its own,
|
|
88
|
+
* such as "billing.write" for a workspace's spending limits. A field
|
|
89
|
+
* without it needs the method's permission. The build checks the name's
|
|
90
|
+
* shape, and the permissions page lists the field groups.
|
|
91
|
+
*
|
|
92
|
+
* @generated from extension: string field_permission = 51003;
|
|
93
|
+
*/
|
|
94
|
+
export const field_permission = /*@__PURE__*/ extDesc(file_toshi_permission, 5);
|