@celestoai/sdk 0.1.0 → 0.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.
@@ -0,0 +1,131 @@
1
+ import { C as ClientConfig, R as RequestOverrides } from '../config-BTTpuv_b.cjs';
2
+
3
+ type ComputerStatus = "creating" | "running" | "stopping" | "stopped" | "starting" | "restoring" | "restorable" | "deleting" | "deleted" | "error";
4
+ interface ComputerConnectionInfo {
5
+ ssh?: string;
6
+ accessUrl?: string;
7
+ }
8
+ interface ComputerInfo {
9
+ id: string;
10
+ name: string;
11
+ status: ComputerStatus;
12
+ vcpus: number;
13
+ ramMb: number;
14
+ diskSizeMb: number;
15
+ image: string;
16
+ templateId: string;
17
+ templateVersion?: string | null;
18
+ connection?: ComputerConnectionInfo;
19
+ lastError?: string | null;
20
+ createdAt: string;
21
+ stoppedAt?: string | null;
22
+ }
23
+ interface ComputerListResponse {
24
+ computers: ComputerInfo[];
25
+ count: number;
26
+ }
27
+ interface ComputerExecResponse {
28
+ exitCode: number;
29
+ stdout: string;
30
+ stderr: string;
31
+ }
32
+ interface SandboxTemplateInfo {
33
+ id: string;
34
+ displayName: string;
35
+ description: string;
36
+ defaultVcpus: number;
37
+ defaultRamMb: number;
38
+ defaultDiskSizeMb: number;
39
+ version?: string | null;
40
+ experimental: boolean;
41
+ }
42
+ interface CreateComputerParams {
43
+ /** Number of virtual CPUs (1-16). Alias for vcpus. */
44
+ cpus?: number;
45
+ /** Number of virtual CPUs (1-16). */
46
+ vcpus?: number;
47
+ /** Memory in MB (512-32768). Alias for ramMb. */
48
+ memory?: number;
49
+ /** Memory in MB (512-32768). */
50
+ ramMb?: number;
51
+ /** Disk size in MB (512-51200). */
52
+ diskSizeMb?: number;
53
+ /** Legacy OS image selector. */
54
+ image?: string;
55
+ /** Sandbox template id, such as "scratch" or "coding-agent". */
56
+ templateId?: string;
57
+ /** Optional immutable template version. */
58
+ templateVersion?: string;
59
+ }
60
+ interface ExecParams {
61
+ /** Timeout in seconds (1-300). Defaults to 30. */
62
+ timeout?: number;
63
+ }
64
+ /**
65
+ * Everything needed to open a WebSocket terminal connection.
66
+ *
67
+ * Use with any WebSocket library:
68
+ * ```ts
69
+ * const conn = await celesto.computers.getTerminalConnection("my-computer");
70
+ * const ws = new WebSocket(conn.url, { headers: conn.headers });
71
+ * ws.on("open", () => ws.send(conn.firstMessage));
72
+ * ```
73
+ */
74
+ interface TerminalConnectionInfo {
75
+ /** The wss:// URL to connect to. */
76
+ url: string;
77
+ /** Headers to send on the WebSocket handshake (includes Authorization). */
78
+ headers: Record<string, string>;
79
+ /** JSON string to send as the first message after connect (legacy token auth). */
80
+ firstMessage: string;
81
+ }
82
+
83
+ /**
84
+ * Client for managing sandboxed computers (AI sandboxes).
85
+ *
86
+ * Provides create/list/get/exec/stop/start/delete over HTTP, plus
87
+ * `getTerminalConnection()` which returns the URL and headers needed
88
+ * to open a WebSocket terminal with any WS library of your choice.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * const celesto = new Celesto({ token: process.env.CELESTO_API_KEY });
93
+ * const computer = await celesto.computers.create({ templateId: "coding-agent" });
94
+ * const result = await celesto.computers.exec(computer.id, "uname -a");
95
+ * console.log(result.stdout);
96
+ * await celesto.computers.delete(computer.id);
97
+ * ```
98
+ */
99
+ declare class ComputersClient {
100
+ private readonly config;
101
+ constructor(config: ClientConfig);
102
+ create(params?: CreateComputerParams, options?: RequestOverrides): Promise<ComputerInfo>;
103
+ listTemplates(options?: RequestOverrides): Promise<SandboxTemplateInfo[]>;
104
+ list(options?: RequestOverrides): Promise<ComputerListResponse>;
105
+ get(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
106
+ exec(computerId: string, command: string, params?: ExecParams, options?: RequestOverrides): Promise<ComputerExecResponse>;
107
+ stop(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
108
+ start(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
109
+ delete(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
110
+ /**
111
+ * Get connection info for opening a WebSocket terminal session.
112
+ *
113
+ * Accepts either a computer ID (e.g. `cmp_xxx`) or a human-readable name.
114
+ * The name is resolved to the canonical ID via a GET call — the backend's
115
+ * WebSocket endpoint does not resolve names on its own.
116
+ *
117
+ * Returns the URL, headers, and first message needed to open the connection
118
+ * with any WebSocket library of your choice.
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * const conn = await celesto.computers.getTerminalConnection("my-computer");
123
+ * const ws = new WebSocket(conn.url, { headers: conn.headers });
124
+ * ws.on("open", () => ws.send(conn.firstMessage));
125
+ * ws.on("message", (data) => process.stdout.write(data));
126
+ * ```
127
+ */
128
+ getTerminalConnection(computerIdOrName: string): Promise<TerminalConnectionInfo>;
129
+ }
130
+
131
+ export { type ComputerConnectionInfo, type ComputerExecResponse, type ComputerInfo, type ComputerListResponse, type ComputerStatus, ComputersClient, type CreateComputerParams, type ExecParams, type SandboxTemplateInfo, type TerminalConnectionInfo };
@@ -0,0 +1,131 @@
1
+ import { C as ClientConfig, R as RequestOverrides } from '../config-BTTpuv_b.js';
2
+
3
+ type ComputerStatus = "creating" | "running" | "stopping" | "stopped" | "starting" | "restoring" | "restorable" | "deleting" | "deleted" | "error";
4
+ interface ComputerConnectionInfo {
5
+ ssh?: string;
6
+ accessUrl?: string;
7
+ }
8
+ interface ComputerInfo {
9
+ id: string;
10
+ name: string;
11
+ status: ComputerStatus;
12
+ vcpus: number;
13
+ ramMb: number;
14
+ diskSizeMb: number;
15
+ image: string;
16
+ templateId: string;
17
+ templateVersion?: string | null;
18
+ connection?: ComputerConnectionInfo;
19
+ lastError?: string | null;
20
+ createdAt: string;
21
+ stoppedAt?: string | null;
22
+ }
23
+ interface ComputerListResponse {
24
+ computers: ComputerInfo[];
25
+ count: number;
26
+ }
27
+ interface ComputerExecResponse {
28
+ exitCode: number;
29
+ stdout: string;
30
+ stderr: string;
31
+ }
32
+ interface SandboxTemplateInfo {
33
+ id: string;
34
+ displayName: string;
35
+ description: string;
36
+ defaultVcpus: number;
37
+ defaultRamMb: number;
38
+ defaultDiskSizeMb: number;
39
+ version?: string | null;
40
+ experimental: boolean;
41
+ }
42
+ interface CreateComputerParams {
43
+ /** Number of virtual CPUs (1-16). Alias for vcpus. */
44
+ cpus?: number;
45
+ /** Number of virtual CPUs (1-16). */
46
+ vcpus?: number;
47
+ /** Memory in MB (512-32768). Alias for ramMb. */
48
+ memory?: number;
49
+ /** Memory in MB (512-32768). */
50
+ ramMb?: number;
51
+ /** Disk size in MB (512-51200). */
52
+ diskSizeMb?: number;
53
+ /** Legacy OS image selector. */
54
+ image?: string;
55
+ /** Sandbox template id, such as "scratch" or "coding-agent". */
56
+ templateId?: string;
57
+ /** Optional immutable template version. */
58
+ templateVersion?: string;
59
+ }
60
+ interface ExecParams {
61
+ /** Timeout in seconds (1-300). Defaults to 30. */
62
+ timeout?: number;
63
+ }
64
+ /**
65
+ * Everything needed to open a WebSocket terminal connection.
66
+ *
67
+ * Use with any WebSocket library:
68
+ * ```ts
69
+ * const conn = await celesto.computers.getTerminalConnection("my-computer");
70
+ * const ws = new WebSocket(conn.url, { headers: conn.headers });
71
+ * ws.on("open", () => ws.send(conn.firstMessage));
72
+ * ```
73
+ */
74
+ interface TerminalConnectionInfo {
75
+ /** The wss:// URL to connect to. */
76
+ url: string;
77
+ /** Headers to send on the WebSocket handshake (includes Authorization). */
78
+ headers: Record<string, string>;
79
+ /** JSON string to send as the first message after connect (legacy token auth). */
80
+ firstMessage: string;
81
+ }
82
+
83
+ /**
84
+ * Client for managing sandboxed computers (AI sandboxes).
85
+ *
86
+ * Provides create/list/get/exec/stop/start/delete over HTTP, plus
87
+ * `getTerminalConnection()` which returns the URL and headers needed
88
+ * to open a WebSocket terminal with any WS library of your choice.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * const celesto = new Celesto({ token: process.env.CELESTO_API_KEY });
93
+ * const computer = await celesto.computers.create({ templateId: "coding-agent" });
94
+ * const result = await celesto.computers.exec(computer.id, "uname -a");
95
+ * console.log(result.stdout);
96
+ * await celesto.computers.delete(computer.id);
97
+ * ```
98
+ */
99
+ declare class ComputersClient {
100
+ private readonly config;
101
+ constructor(config: ClientConfig);
102
+ create(params?: CreateComputerParams, options?: RequestOverrides): Promise<ComputerInfo>;
103
+ listTemplates(options?: RequestOverrides): Promise<SandboxTemplateInfo[]>;
104
+ list(options?: RequestOverrides): Promise<ComputerListResponse>;
105
+ get(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
106
+ exec(computerId: string, command: string, params?: ExecParams, options?: RequestOverrides): Promise<ComputerExecResponse>;
107
+ stop(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
108
+ start(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
109
+ delete(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
110
+ /**
111
+ * Get connection info for opening a WebSocket terminal session.
112
+ *
113
+ * Accepts either a computer ID (e.g. `cmp_xxx`) or a human-readable name.
114
+ * The name is resolved to the canonical ID via a GET call — the backend's
115
+ * WebSocket endpoint does not resolve names on its own.
116
+ *
117
+ * Returns the URL, headers, and first message needed to open the connection
118
+ * with any WebSocket library of your choice.
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * const conn = await celesto.computers.getTerminalConnection("my-computer");
123
+ * const ws = new WebSocket(conn.url, { headers: conn.headers });
124
+ * ws.on("open", () => ws.send(conn.firstMessage));
125
+ * ws.on("message", (data) => process.stdout.write(data));
126
+ * ```
127
+ */
128
+ getTerminalConnection(computerIdOrName: string): Promise<TerminalConnectionInfo>;
129
+ }
130
+
131
+ export { type ComputerConnectionInfo, type ComputerExecResponse, type ComputerInfo, type ComputerListResponse, type ComputerStatus, ComputersClient, type CreateComputerParams, type ExecParams, type SandboxTemplateInfo, type TerminalConnectionInfo };
@@ -0,0 +1,8 @@
1
+ import {
2
+ ComputersClient
3
+ } from "../chunk-7OJDEZ7J.js";
4
+ import "../chunk-N3HU6ONW.js";
5
+ export {
6
+ ComputersClient
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,25 @@
1
+ type FetchLike = typeof fetch;
2
+ interface ClientConfig {
3
+ /** Base API URL, e.g. https://api.celesto.ai */
4
+ baseUrl?: string;
5
+ /** Bearer token (API key or JWT). */
6
+ token?: string;
7
+ /** Alias for token. */
8
+ apiKey?: string;
9
+ /** Organization ID to send as X-Current-Organization. */
10
+ organizationId?: string;
11
+ /** Optional user agent for server-side requests. */
12
+ userAgent?: string;
13
+ /** Default request timeout in milliseconds. */
14
+ timeoutMs?: number;
15
+ /** Override fetch implementation (useful for testing). */
16
+ fetch?: FetchLike;
17
+ /** Default headers to include in every request. */
18
+ headers?: Record<string, string>;
19
+ }
20
+ interface RequestOverrides {
21
+ headers?: Record<string, string>;
22
+ signal?: AbortSignal;
23
+ }
24
+
25
+ export type { ClientConfig as C, RequestOverrides as R };
@@ -0,0 +1,25 @@
1
+ type FetchLike = typeof fetch;
2
+ interface ClientConfig {
3
+ /** Base API URL, e.g. https://api.celesto.ai */
4
+ baseUrl?: string;
5
+ /** Bearer token (API key or JWT). */
6
+ token?: string;
7
+ /** Alias for token. */
8
+ apiKey?: string;
9
+ /** Organization ID to send as X-Current-Organization. */
10
+ organizationId?: string;
11
+ /** Optional user agent for server-side requests. */
12
+ userAgent?: string;
13
+ /** Default request timeout in milliseconds. */
14
+ timeoutMs?: number;
15
+ /** Override fetch implementation (useful for testing). */
16
+ fetch?: FetchLike;
17
+ /** Default headers to include in every request. */
18
+ headers?: Record<string, string>;
19
+ }
20
+ interface RequestOverrides {
21
+ headers?: Record<string, string>;
22
+ signal?: AbortSignal;
23
+ }
24
+
25
+ export type { ClientConfig as C, RequestOverrides as R };
@@ -0,0 +1,338 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/gatekeeper/index.ts
21
+ var gatekeeper_exports = {};
22
+ __export(gatekeeper_exports, {
23
+ GatekeeperClient: () => GatekeeperClient
24
+ });
25
+ module.exports = __toCommonJS(gatekeeper_exports);
26
+
27
+ // src/core/config.ts
28
+ var DEFAULT_BASE_URL = "https://api.celesto.ai";
29
+ var buildRequestContext = (config) => ({
30
+ fetch: config.fetch ?? fetch,
31
+ baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,
32
+ token: config.token ?? config.apiKey,
33
+ organizationId: config.organizationId,
34
+ userAgent: config.userAgent,
35
+ timeoutMs: config.timeoutMs,
36
+ headers: config.headers
37
+ });
38
+
39
+ // src/core/errors.ts
40
+ var CelestoError = class extends Error {
41
+ constructor(message) {
42
+ super(message);
43
+ this.name = "CelestoError";
44
+ }
45
+ };
46
+ var CelestoApiError = class extends CelestoError {
47
+ constructor(message, status, data, requestId) {
48
+ super(message);
49
+ this.name = "CelestoApiError";
50
+ this.status = status;
51
+ this.data = data;
52
+ this.requestId = requestId;
53
+ }
54
+ };
55
+ var CelestoNetworkError = class extends CelestoError {
56
+ constructor(message, cause) {
57
+ super(message);
58
+ this.name = "CelestoNetworkError";
59
+ this.cause = cause;
60
+ }
61
+ };
62
+
63
+ // src/core/http.ts
64
+ var joinUrl = (baseUrl, path) => {
65
+ const trimmedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
66
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
67
+ return `${trimmedBase}${normalizedPath}`;
68
+ };
69
+ var buildQuery = (query) => {
70
+ if (!query) {
71
+ return "";
72
+ }
73
+ const params = new URLSearchParams();
74
+ for (const [key, value] of Object.entries(query)) {
75
+ if (value === void 0 || value === null) {
76
+ continue;
77
+ }
78
+ if (Array.isArray(value)) {
79
+ for (const item of value) {
80
+ params.append(key, String(item));
81
+ }
82
+ continue;
83
+ }
84
+ params.set(key, String(value));
85
+ }
86
+ const serialized = params.toString();
87
+ return serialized ? `?${serialized}` : "";
88
+ };
89
+ var parseResponseBody = async (response) => {
90
+ if (response.status === 204) {
91
+ return void 0;
92
+ }
93
+ const contentType = response.headers.get("content-type") ?? "";
94
+ if (contentType.includes("application/json")) {
95
+ return response.json();
96
+ }
97
+ return response.text();
98
+ };
99
+ var extractErrorMessage = (data, status) => {
100
+ if (data && typeof data === "object") {
101
+ const record = data;
102
+ if (typeof record.detail === "string") {
103
+ return record.detail;
104
+ }
105
+ if (typeof record.message === "string") {
106
+ return record.message;
107
+ }
108
+ if (typeof record.error === "string") {
109
+ return record.error;
110
+ }
111
+ }
112
+ return `Request failed with status ${status}`;
113
+ };
114
+ var request = async (ctx, options) => {
115
+ const url = `${joinUrl(ctx.baseUrl, options.path)}${buildQuery(options.query)}`;
116
+ const headers = {
117
+ ...ctx.headers ?? {},
118
+ ...options.headers ?? {}
119
+ };
120
+ if (ctx.token) {
121
+ headers.Authorization = `Bearer ${ctx.token}`;
122
+ }
123
+ if (ctx.organizationId) {
124
+ headers["X-Current-Organization"] = ctx.organizationId;
125
+ }
126
+ if (ctx.userAgent && !headers["User-Agent"]) {
127
+ headers["User-Agent"] = ctx.userAgent;
128
+ }
129
+ const init = {
130
+ method: options.method,
131
+ headers,
132
+ body: void 0,
133
+ signal: options.signal
134
+ };
135
+ if (options.body !== void 0) {
136
+ headers["Content-Type"] = headers["Content-Type"] ?? "application/json";
137
+ init.body = headers["Content-Type"].includes("application/json") ? JSON.stringify(options.body) : options.body;
138
+ }
139
+ let timeoutId;
140
+ let controller;
141
+ if (!options.signal && ctx.timeoutMs && ctx.timeoutMs > 0) {
142
+ controller = new AbortController();
143
+ timeoutId = setTimeout(() => controller?.abort(), ctx.timeoutMs);
144
+ init.signal = controller.signal;
145
+ }
146
+ try {
147
+ const response = await ctx.fetch(url, init);
148
+ const data = await parseResponseBody(response);
149
+ if (!response.ok) {
150
+ const message = extractErrorMessage(data, response.status);
151
+ throw new CelestoApiError(message, response.status, data, response.headers.get("x-request-id") ?? void 0);
152
+ }
153
+ return data;
154
+ } catch (err) {
155
+ if (err instanceof CelestoApiError) {
156
+ throw err;
157
+ }
158
+ const error = err instanceof Error ? err : new Error(String(err));
159
+ throw new CelestoNetworkError(error.message, error);
160
+ } finally {
161
+ if (timeoutId) {
162
+ clearTimeout(timeoutId);
163
+ }
164
+ }
165
+ };
166
+
167
+ // src/gatekeeper/client.ts
168
+ var toConnectRequest = (payload) => ({
169
+ subject: payload.subject,
170
+ provider: payload.provider ?? "google_drive",
171
+ project_name: payload.projectName,
172
+ redirect_uri: payload.redirectUri
173
+ });
174
+ var toConnectResponse = (payload) => ({
175
+ status: payload.status,
176
+ oauthUrl: payload.oauth_url ?? void 0,
177
+ connectionId: payload.connection_id ?? void 0
178
+ });
179
+ var toConnection = (payload) => ({
180
+ id: payload.id,
181
+ subject: payload.subject,
182
+ provider: payload.provider,
183
+ projectId: payload.project_id,
184
+ accountEmail: payload.account_email ?? null,
185
+ scopes: payload.scopes ?? [],
186
+ status: payload.status,
187
+ createdAt: payload.created_at,
188
+ updatedAt: payload.updated_at,
189
+ lastUsedAt: payload.last_used_at ?? null,
190
+ accessRules: payload.access_rules ? {
191
+ version: payload.access_rules.version ?? "1",
192
+ allowedFolders: payload.access_rules.allowed_folders ?? [],
193
+ allowedFiles: payload.access_rules.allowed_files ?? [],
194
+ unrestricted: false
195
+ } : null
196
+ });
197
+ var toAccessRules = (payload) => ({
198
+ version: payload.version,
199
+ allowedFolders: payload.allowed_folders ?? [],
200
+ allowedFiles: payload.allowed_files ?? [],
201
+ unrestricted: payload.unrestricted
202
+ });
203
+ var toDriveFile = (payload) => ({
204
+ id: payload.id,
205
+ name: payload.name ?? null,
206
+ mimeType: payload.mime_type ?? null,
207
+ size: payload.size ?? null,
208
+ modifiedTime: payload.modified_time ?? null,
209
+ createdTime: payload.created_time ?? null,
210
+ webViewLink: payload.web_view_link ?? null,
211
+ iconLink: payload.icon_link ?? null,
212
+ thumbnailLink: payload.thumbnail_link ?? null,
213
+ parents: payload.parents ?? null,
214
+ driveId: payload.drive_id ?? null,
215
+ shared: payload.shared ?? null,
216
+ ownedByMe: payload.owned_by_me ?? null
217
+ });
218
+ var gatekeeperPath = (path) => `/v1/gatekeeper${path}`;
219
+ var pickOverrides = (options) => ({
220
+ headers: options?.headers,
221
+ signal: options?.signal
222
+ });
223
+ var GatekeeperClient = class {
224
+ constructor(config) {
225
+ this.config = config;
226
+ }
227
+ async connect(payload, options) {
228
+ const ctx = buildRequestContext(this.config);
229
+ const data = await request(ctx, {
230
+ method: "POST",
231
+ path: gatekeeperPath("/connect"),
232
+ body: toConnectRequest(payload),
233
+ ...pickOverrides(options)
234
+ });
235
+ return toConnectResponse(data);
236
+ }
237
+ async listConnections(params, options) {
238
+ const ctx = buildRequestContext(this.config);
239
+ const data = await request(ctx, {
240
+ method: "GET",
241
+ path: gatekeeperPath("/connections"),
242
+ query: {
243
+ project_name: params.projectName,
244
+ status_filter: params.statusFilter
245
+ },
246
+ ...pickOverrides(options)
247
+ });
248
+ return {
249
+ total: data.total,
250
+ data: data.data.map(toConnection)
251
+ };
252
+ }
253
+ async getConnection(connectionId, options) {
254
+ const ctx = buildRequestContext(this.config);
255
+ const data = await request(ctx, {
256
+ method: "GET",
257
+ path: gatekeeperPath(`/connections/${connectionId}`),
258
+ ...pickOverrides(options)
259
+ });
260
+ return toConnection(data);
261
+ }
262
+ async revokeConnection(params, options) {
263
+ const ctx = buildRequestContext(this.config);
264
+ return request(ctx, {
265
+ method: "DELETE",
266
+ path: gatekeeperPath("/connections"),
267
+ query: {
268
+ subject: params.subject,
269
+ project_name: params.projectName,
270
+ provider: params.provider
271
+ },
272
+ ...pickOverrides(options)
273
+ });
274
+ }
275
+ async listDriveFiles(params, options) {
276
+ const ctx = buildRequestContext(this.config);
277
+ const data = await request(ctx, {
278
+ method: "GET",
279
+ path: gatekeeperPath("/connectors/drive/files"),
280
+ query: {
281
+ project_name: params.projectName,
282
+ subject: params.subject,
283
+ page_size: params.pageSize,
284
+ page_token: params.pageToken,
285
+ folder_id: params.folderId,
286
+ query: params.query,
287
+ include_folders: params.includeFolders,
288
+ order_by: params.orderBy
289
+ },
290
+ ...pickOverrides(options)
291
+ });
292
+ return {
293
+ files: data.files.map(toDriveFile),
294
+ nextPageToken: data.next_page_token ?? null
295
+ };
296
+ }
297
+ async getAccessRules(connectionId, options) {
298
+ const ctx = buildRequestContext(this.config);
299
+ const data = await request(ctx, {
300
+ method: "GET",
301
+ path: gatekeeperPath(`/connections/${connectionId}/access-rules`),
302
+ ...pickOverrides(options)
303
+ });
304
+ return toAccessRules(data);
305
+ }
306
+ async updateAccessRules(params, options) {
307
+ const ctx = buildRequestContext(this.config);
308
+ const data = await request(ctx, {
309
+ method: "PUT",
310
+ path: gatekeeperPath("/connections/access-rules"),
311
+ query: {
312
+ subject: params.subject,
313
+ project_name: params.projectName,
314
+ provider: params.provider
315
+ },
316
+ body: {
317
+ allowed_folders: params.accessRules.allowedFolders ?? [],
318
+ allowed_files: params.accessRules.allowedFiles ?? []
319
+ },
320
+ ...pickOverrides(options)
321
+ });
322
+ return toAccessRules(data);
323
+ }
324
+ async clearAccessRules(connectionId, options) {
325
+ const ctx = buildRequestContext(this.config);
326
+ const data = await request(ctx, {
327
+ method: "DELETE",
328
+ path: gatekeeperPath(`/connections/${connectionId}/access-rules`),
329
+ ...pickOverrides(options)
330
+ });
331
+ return toAccessRules(data);
332
+ }
333
+ };
334
+ // Annotate the CommonJS export names for ESM import in node:
335
+ 0 && (module.exports = {
336
+ GatekeeperClient
337
+ });
338
+ //# sourceMappingURL=index.cjs.map