@celestoai/sdk 0.1.2 → 0.1.4
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 +242 -52
- package/dist/{chunk-4KVRJSVJ.js → chunk-5VVB6N33.js} +2 -2
- package/dist/{chunk-N3HU6ONW.js → chunk-JS6BTDP5.js} +31 -4
- package/dist/chunk-JS6BTDP5.js.map +1 -0
- package/dist/chunk-XNTZDOKY.js +747 -0
- package/dist/chunk-XNTZDOKY.js.map +1 -0
- package/dist/computers/index.cjs +638 -65
- package/dist/computers/index.cjs.map +1 -1
- package/dist/computers/index.d.cts +159 -61
- package/dist/computers/index.d.ts +159 -61
- package/dist/computers/index.js +10 -4
- package/dist/gatekeeper/index.cjs +5 -2
- package/dist/gatekeeper/index.cjs.map +1 -1
- package/dist/gatekeeper/index.js +2 -2
- package/dist/index.cjs +783 -222
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -13
- package/dist/index.d.ts +4 -13
- package/dist/index.js +12 -15
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
- package/dist/chunk-7OJDEZ7J.js +0 -212
- package/dist/chunk-7OJDEZ7J.js.map +0 -1
- package/dist/chunk-N3HU6ONW.js.map +0 -1
- /package/dist/{chunk-4KVRJSVJ.js.map → chunk-5VVB6N33.js.map} +0 -0
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import { C as ClientConfig
|
|
1
|
+
import { C as ClientConfig } from '../config-BTTpuv_b.js';
|
|
2
2
|
|
|
3
3
|
type ComputerStatus = "creating" | "running" | "stopping" | "stopped" | "starting" | "restoring" | "restorable" | "deleting" | "deleted" | "error";
|
|
4
4
|
interface ComputerConnectionInfo {
|
|
5
5
|
ssh?: string;
|
|
6
6
|
accessUrl?: string;
|
|
7
7
|
}
|
|
8
|
+
type PublishedPortStatus = "publishing" | "published" | "unpublishing" | "unpublished" | "error";
|
|
9
|
+
interface ComputerPublishedPortInfo {
|
|
10
|
+
id?: string | null;
|
|
11
|
+
computerId: string;
|
|
12
|
+
port: number;
|
|
13
|
+
url?: string | null;
|
|
14
|
+
status: PublishedPortStatus;
|
|
15
|
+
createdAt?: string | null;
|
|
16
|
+
}
|
|
8
17
|
interface ComputerInfo {
|
|
9
18
|
id: string;
|
|
10
19
|
name: string;
|
|
@@ -16,6 +25,7 @@ interface ComputerInfo {
|
|
|
16
25
|
templateId: string;
|
|
17
26
|
templateVersion?: string | null;
|
|
18
27
|
connection?: ComputerConnectionInfo;
|
|
28
|
+
publishedPorts?: ComputerPublishedPortInfo[];
|
|
19
29
|
lastError?: string | null;
|
|
20
30
|
createdAt: string;
|
|
21
31
|
stoppedAt?: string | null;
|
|
@@ -24,10 +34,57 @@ interface ComputerListResponse {
|
|
|
24
34
|
computers: ComputerInfo[];
|
|
25
35
|
count: number;
|
|
26
36
|
}
|
|
37
|
+
interface ListComputersParams {
|
|
38
|
+
/** Optional status filter, such as "running" or "stopped". */
|
|
39
|
+
status?: ComputerStatus;
|
|
40
|
+
/** Optional template filter, such as "coding-agent". */
|
|
41
|
+
templateId?: string;
|
|
42
|
+
/** Optional project ID filter. */
|
|
43
|
+
projectId?: string;
|
|
44
|
+
/** Optional maximum number of computers to return. */
|
|
45
|
+
limit?: number;
|
|
46
|
+
}
|
|
27
47
|
interface ComputerExecResponse {
|
|
28
48
|
exitCode: number;
|
|
29
49
|
stdout: string;
|
|
30
50
|
stderr: string;
|
|
51
|
+
commandId?: string | null;
|
|
52
|
+
durationMs?: number | null;
|
|
53
|
+
timedOut?: boolean | null;
|
|
54
|
+
}
|
|
55
|
+
type ComputerExecStreamEvent = {
|
|
56
|
+
type: "started";
|
|
57
|
+
commandId: string;
|
|
58
|
+
startedAtUnixMs: number;
|
|
59
|
+
timeoutSeconds: number;
|
|
60
|
+
} | {
|
|
61
|
+
type: "stdout" | "stderr";
|
|
62
|
+
data: string;
|
|
63
|
+
} | {
|
|
64
|
+
type: "exit";
|
|
65
|
+
exitCode: number;
|
|
66
|
+
commandId?: string;
|
|
67
|
+
startedAtUnixMs?: number;
|
|
68
|
+
endedAtUnixMs?: number;
|
|
69
|
+
durationMs?: number;
|
|
70
|
+
timedOut?: boolean;
|
|
71
|
+
};
|
|
72
|
+
interface ComputerCommandHistoryEntry {
|
|
73
|
+
commandId: string;
|
|
74
|
+
source: string;
|
|
75
|
+
status: string;
|
|
76
|
+
startedAt?: string | null;
|
|
77
|
+
endedAt?: string | null;
|
|
78
|
+
durationMs?: number | null;
|
|
79
|
+
timeoutSeconds?: number | null;
|
|
80
|
+
exitCode?: number | null;
|
|
81
|
+
stdoutBytes?: number | null;
|
|
82
|
+
stderrBytes?: number | null;
|
|
83
|
+
errorType?: string | null;
|
|
84
|
+
}
|
|
85
|
+
interface ComputerCommandHistoryResponse {
|
|
86
|
+
commands: ComputerCommandHistoryEntry[];
|
|
87
|
+
count: number;
|
|
31
88
|
}
|
|
32
89
|
interface SandboxTemplateInfo {
|
|
33
90
|
id: string;
|
|
@@ -48,6 +105,8 @@ interface CreateComputerParams {
|
|
|
48
105
|
memory?: number;
|
|
49
106
|
/** Memory in MB (512-32768). */
|
|
50
107
|
ramMb?: number;
|
|
108
|
+
/** Disk size as MB or a string like "2gb". Alias for diskSizeMb. */
|
|
109
|
+
disk?: number | string;
|
|
51
110
|
/** Disk size in MB (512-51200). */
|
|
52
111
|
diskSizeMb?: number;
|
|
53
112
|
/** Legacy OS image selector. */
|
|
@@ -60,72 +119,111 @@ interface CreateComputerParams {
|
|
|
60
119
|
interface ExecParams {
|
|
61
120
|
/** Timeout in seconds (1-300). Defaults to 30. */
|
|
62
121
|
timeout?: number;
|
|
122
|
+
/** Abort the HTTP request. Streaming requests also stop the remote command. */
|
|
123
|
+
signal?: AbortSignal;
|
|
124
|
+
}
|
|
125
|
+
interface ListCommandHistoryParams {
|
|
126
|
+
/** Maximum command records to return (1-200). Defaults to 50. */
|
|
127
|
+
limit?: number;
|
|
63
128
|
}
|
|
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
|
-
*/
|
|
129
|
+
/** Legacy WebSocket connection fields retained for source compatibility. */
|
|
74
130
|
interface TerminalConnectionInfo {
|
|
75
|
-
/**
|
|
131
|
+
/** Authenticated wss:// URL ready to pass to a WebSocket constructor. */
|
|
76
132
|
url: string;
|
|
77
|
-
/**
|
|
133
|
+
/** @deprecated The fast terminal gateway does not require custom headers. */
|
|
78
134
|
headers: Record<string, string>;
|
|
79
|
-
/**
|
|
135
|
+
/** @deprecated The fast terminal gateway does not require a first message. */
|
|
80
136
|
firstMessage: string;
|
|
81
137
|
}
|
|
138
|
+
/** A short-lived direct connection to Celesto's fast terminal gateway. */
|
|
139
|
+
interface TerminalSessionInfo extends TerminalConnectionInfo {
|
|
140
|
+
/** Durable terminal session ID. */
|
|
141
|
+
terminalId: string;
|
|
142
|
+
/** Gateway URL without credentials. */
|
|
143
|
+
gatewayUrl: string;
|
|
144
|
+
/** Short-lived terminal token. Treat this value as a secret. */
|
|
145
|
+
token: string;
|
|
146
|
+
/** ISO 8601 expiry time for the terminal token. */
|
|
147
|
+
expiresAt: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Convenience object for one Celesto computer. */
|
|
151
|
+
declare class Computer {
|
|
152
|
+
private readonly client;
|
|
153
|
+
private info;
|
|
154
|
+
private constructor();
|
|
155
|
+
/** Create a new computer and return an object with methods on it. */
|
|
156
|
+
static create(params?: CreateComputerParams, config?: ClientConfig): Promise<Computer>;
|
|
157
|
+
/** Load an existing computer by name or ID. */
|
|
158
|
+
static get(computerIdOrName: string, config?: ClientConfig): Promise<Computer>;
|
|
159
|
+
/** List computers in the current account. */
|
|
160
|
+
static list(params?: ListComputersParams, config?: ClientConfig): Promise<Computer[]>;
|
|
161
|
+
/** List available computer templates. */
|
|
162
|
+
static listTemplates(config?: ClientConfig): Promise<SandboxTemplateInfo[]>;
|
|
163
|
+
/** Wrap an existing API response in the convenience object. */
|
|
164
|
+
static fromInfo(info: ComputerInfo, config?: ClientConfig): Computer;
|
|
165
|
+
get id(): string;
|
|
166
|
+
get name(): string;
|
|
167
|
+
get status(): ComputerStatus;
|
|
168
|
+
get vcpus(): number;
|
|
169
|
+
get ramMb(): number;
|
|
170
|
+
get diskSizeMb(): number;
|
|
171
|
+
get image(): string;
|
|
172
|
+
get templateId(): string;
|
|
173
|
+
get templateVersion(): string | null | undefined;
|
|
174
|
+
get connection(): ComputerConnectionInfo | undefined;
|
|
175
|
+
get publishedPorts(): ComputerPublishedPortInfo[] | undefined;
|
|
176
|
+
get lastError(): string | null | undefined;
|
|
177
|
+
get createdAt(): string;
|
|
178
|
+
get stoppedAt(): string | null | undefined;
|
|
179
|
+
/** Get one field from the latest computer data. */
|
|
180
|
+
get<K extends keyof ComputerInfo>(key: K): ComputerInfo[K];
|
|
181
|
+
/** Return a copy of the latest computer data. */
|
|
182
|
+
toJSON(): ComputerInfo;
|
|
183
|
+
/** Reload this computer from Celesto. */
|
|
184
|
+
refresh(): Promise<this>;
|
|
185
|
+
/** Run a shell command on this computer. */
|
|
186
|
+
run(command: string, params?: ExecParams): Promise<ComputerExecResponse>;
|
|
187
|
+
/** Alias for run(). */
|
|
188
|
+
exec(command: string, params?: ExecParams): Promise<ComputerExecResponse>;
|
|
189
|
+
/** Run a shell command and stream output and exit events as they arrive. */
|
|
190
|
+
runStream(command: string, params?: ExecParams): AsyncGenerator<ComputerExecStreamEvent>;
|
|
191
|
+
/** Alias for runStream(). */
|
|
192
|
+
execStream(command: string, params?: ExecParams): AsyncGenerator<ComputerExecStreamEvent>;
|
|
193
|
+
/** List recent commands executed on this computer. */
|
|
194
|
+
listCommandHistory(params?: ListCommandHistoryParams): Promise<ComputerCommandHistoryResponse>;
|
|
195
|
+
/** Create a short-lived direct connection to Celesto's terminal gateway. */
|
|
196
|
+
createTerminalSession(): Promise<TerminalSessionInfo>;
|
|
197
|
+
/** @deprecated Use createTerminalSession(). */
|
|
198
|
+
getTerminalConnection(): Promise<TerminalSessionInfo>;
|
|
199
|
+
/** Stop this computer and update the local data. */
|
|
200
|
+
stop(): Promise<this>;
|
|
201
|
+
/** Start this computer and update the local data. */
|
|
202
|
+
start(): Promise<this>;
|
|
203
|
+
/** Delete this computer and update the local data. */
|
|
204
|
+
delete(): Promise<this>;
|
|
205
|
+
/** Publish a port and return its public URL when the API provides one. */
|
|
206
|
+
publishPort(port?: number): Promise<string | null>;
|
|
207
|
+
/** List public ports for this computer. */
|
|
208
|
+
listPublishedPorts(): Promise<ComputerPublishedPortInfo[]>;
|
|
209
|
+
/** Remove a public port route. */
|
|
210
|
+
unpublishPort(port?: number): Promise<ComputerPublishedPortInfo>;
|
|
211
|
+
}
|
|
82
212
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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>;
|
|
213
|
+
declare const MISSING_CREDENTIALS_MESSAGE = "No Celesto credentials found. Run pip install celesto && celesto auth login, or export CELESTO_API_KEY.";
|
|
214
|
+
interface CredentialResolutionOptions {
|
|
215
|
+
/** Directory containing the local .env file. Defaults to process.cwd(). */
|
|
216
|
+
cwd?: string;
|
|
217
|
+
/** Environment variables to inspect. Defaults to process.env. */
|
|
218
|
+
env?: NodeJS.ProcessEnv;
|
|
219
|
+
/** Test or host override for reading .env. */
|
|
220
|
+
readDotEnv?: (filePath: string) => Promise<string>;
|
|
221
|
+
/** Test or host override for loading credentials saved by the Celesto CLI. */
|
|
222
|
+
loadSavedApiKey?: () => Promise<string | undefined>;
|
|
129
223
|
}
|
|
224
|
+
/** Resolve a Celesto API key from local sources, in precedence order. */
|
|
225
|
+
declare function resolveCelestoApiKey(options?: CredentialResolutionOptions): Promise<string | undefined>;
|
|
226
|
+
/** Resolve an API key while preserving explicit SDK configuration. */
|
|
227
|
+
declare function resolveClientConfig(config?: ClientConfig, options?: CredentialResolutionOptions): Promise<ClientConfig>;
|
|
130
228
|
|
|
131
|
-
export { type ComputerConnectionInfo, type ComputerExecResponse, type ComputerInfo, type ComputerListResponse, type
|
|
229
|
+
export { Computer, type ComputerCommandHistoryEntry, type ComputerCommandHistoryResponse, type ComputerConnectionInfo, type ComputerExecResponse, type ComputerExecStreamEvent, type ComputerInfo, type ComputerListResponse, type ComputerPublishedPortInfo, type ComputerStatus, type CreateComputerParams, type CredentialResolutionOptions, type ExecParams, type ListCommandHistoryParams, type ListComputersParams, MISSING_CREDENTIALS_MESSAGE, type PublishedPortStatus, type SandboxTemplateInfo, type TerminalConnectionInfo, type TerminalSessionInfo, resolveCelestoApiKey, resolveClientConfig };
|
package/dist/computers/index.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Computer,
|
|
3
|
+
MISSING_CREDENTIALS_MESSAGE,
|
|
4
|
+
resolveCelestoApiKey,
|
|
5
|
+
resolveClientConfig
|
|
6
|
+
} from "../chunk-XNTZDOKY.js";
|
|
7
|
+
import "../chunk-JS6BTDP5.js";
|
|
5
8
|
export {
|
|
6
|
-
|
|
9
|
+
Computer,
|
|
10
|
+
MISSING_CREDENTIALS_MESSAGE,
|
|
11
|
+
resolveCelestoApiKey,
|
|
12
|
+
resolveClientConfig
|
|
7
13
|
};
|
|
8
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -111,7 +111,7 @@ var extractErrorMessage = (data, status) => {
|
|
|
111
111
|
}
|
|
112
112
|
return `Request failed with status ${status}`;
|
|
113
113
|
};
|
|
114
|
-
var
|
|
114
|
+
var buildRequestInit = (ctx, options) => {
|
|
115
115
|
const url = `${joinUrl(ctx.baseUrl, options.path)}${buildQuery(options.query)}`;
|
|
116
116
|
const headers = {
|
|
117
117
|
...ctx.headers ?? {},
|
|
@@ -129,13 +129,16 @@ var request = async (ctx, options) => {
|
|
|
129
129
|
const init = {
|
|
130
130
|
method: options.method,
|
|
131
131
|
headers,
|
|
132
|
-
body: void 0,
|
|
133
132
|
signal: options.signal
|
|
134
133
|
};
|
|
135
134
|
if (options.body !== void 0) {
|
|
136
135
|
headers["Content-Type"] = headers["Content-Type"] ?? "application/json";
|
|
137
136
|
init.body = headers["Content-Type"].includes("application/json") ? JSON.stringify(options.body) : options.body;
|
|
138
137
|
}
|
|
138
|
+
return { url, init };
|
|
139
|
+
};
|
|
140
|
+
var request = async (ctx, options) => {
|
|
141
|
+
const { url, init } = buildRequestInit(ctx, options);
|
|
139
142
|
let timeoutId;
|
|
140
143
|
let controller;
|
|
141
144
|
if (!options.signal && ctx.timeoutMs && ctx.timeoutMs > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/gatekeeper/index.ts","../../src/core/config.ts","../../src/core/errors.ts","../../src/core/http.ts","../../src/gatekeeper/client.ts"],"sourcesContent":["export { GatekeeperClient } from \"./client\";\nexport type {\n GatekeeperAccessRules,\n GatekeeperAccessRulesParams,\n GatekeeperAccessRulesUpdate,\n GatekeeperConnectRequest,\n GatekeeperConnectResponse,\n GatekeeperConnection,\n GatekeeperDriveFile,\n GatekeeperDriveListParams,\n GatekeeperDriveListResponse,\n GatekeeperListConnectionsParams,\n GatekeeperListConnectionsResponse,\n GatekeeperRevokeParams,\n GatekeeperRevokeResponse,\n} from \"./types\";\nexport type { RequestOverrides } from \"../core/config\";\n","export type FetchLike = typeof fetch;\n\nexport interface ClientConfig {\n /** Base API URL, e.g. https://api.celesto.ai */\n baseUrl?: string;\n /** Bearer token (API key or JWT). */\n token?: string;\n /** Alias for token. */\n apiKey?: string;\n /** Organization ID to send as X-Current-Organization. */\n organizationId?: string;\n /** Optional user agent for server-side requests. */\n userAgent?: string;\n /** Default request timeout in milliseconds. */\n timeoutMs?: number;\n /** Override fetch implementation (useful for testing). */\n fetch?: FetchLike;\n /** Default headers to include in every request. */\n headers?: Record<string, string>;\n}\n\nexport interface RequestOptions {\n method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n path: string;\n query?: Record<string, string | number | boolean | undefined | null | (string | number | boolean)[]>;\n body?: unknown;\n headers?: Record<string, string>;\n signal?: AbortSignal;\n}\n\nexport interface RequestOverrides {\n headers?: Record<string, string>;\n signal?: AbortSignal;\n}\n\nexport interface RequestContext {\n fetch: FetchLike;\n baseUrl: string;\n token?: string;\n organizationId?: string;\n userAgent?: string;\n timeoutMs?: number;\n headers?: Record<string, string>;\n}\n\nexport const DEFAULT_BASE_URL = \"https://api.celesto.ai\";\n\nexport const buildRequestContext = (config: ClientConfig): RequestContext => ({\n fetch: config.fetch ?? fetch,\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n token: config.token ?? config.apiKey,\n organizationId: config.organizationId,\n userAgent: config.userAgent,\n timeoutMs: config.timeoutMs,\n headers: config.headers,\n});\n","/** Base error for all Celesto SDK errors. */\nexport class CelestoError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"CelestoError\";\n }\n}\n\n/** Thrown when an API request returns a non-2xx HTTP status. */\nexport class CelestoApiError extends CelestoError {\n readonly status: number;\n readonly data: unknown;\n readonly requestId?: string;\n\n constructor(message: string, status: number, data: unknown, requestId?: string) {\n super(message);\n this.name = \"CelestoApiError\";\n this.status = status;\n this.data = data;\n this.requestId = requestId;\n }\n}\n\n/** Thrown when fetch() itself fails — DNS, network, timeout, abort. */\nexport class CelestoNetworkError extends CelestoError {\n readonly cause?: Error;\n\n constructor(message: string, cause?: Error) {\n super(message);\n this.name = \"CelestoNetworkError\";\n this.cause = cause;\n }\n}\n","import { CelestoApiError, CelestoNetworkError } from \"./errors\";\nimport { RequestContext, RequestOptions } from \"./config\";\n\nconst joinUrl = (baseUrl: string, path: string): string => {\n const trimmedBase = baseUrl.endsWith(\"/\") ? baseUrl.slice(0, -1) : baseUrl;\n const normalizedPath = path.startsWith(\"/\") ? path : `/${path}`;\n return `${trimmedBase}${normalizedPath}`;\n};\n\nconst buildQuery = (\n query?: RequestOptions[\"query\"],\n): string => {\n if (!query) {\n return \"\";\n }\n\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) {\n continue;\n }\n if (Array.isArray(value)) {\n for (const item of value) {\n params.append(key, String(item));\n }\n continue;\n }\n params.set(key, String(value));\n }\n\n const serialized = params.toString();\n return serialized ? `?${serialized}` : \"\";\n};\n\nconst parseResponseBody = async (response: Response): Promise<unknown> => {\n if (response.status === 204) {\n return undefined;\n }\n\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (contentType.includes(\"application/json\")) {\n return response.json();\n }\n\n return response.text();\n};\n\nconst extractErrorMessage = (data: unknown, status: number): string => {\n if (data && typeof data === \"object\") {\n const record = data as Record<string, unknown>;\n if (typeof record.detail === \"string\") {\n return record.detail;\n }\n if (typeof record.message === \"string\") {\n return record.message;\n }\n if (typeof record.error === \"string\") {\n return record.error;\n }\n }\n return `Request failed with status ${status}`;\n};\n\nexport const request = async <T>(ctx: RequestContext, options: RequestOptions): Promise<T> => {\n const url = `${joinUrl(ctx.baseUrl, options.path)}${buildQuery(options.query)}`;\n\n const headers: Record<string, string> = {\n ...(ctx.headers ?? {}),\n ...(options.headers ?? {}),\n };\n\n if (ctx.token) {\n headers.Authorization = `Bearer ${ctx.token}`;\n }\n\n if (ctx.organizationId) {\n headers[\"X-Current-Organization\"] = ctx.organizationId;\n }\n\n if (ctx.userAgent && !headers[\"User-Agent\"]) {\n headers[\"User-Agent\"] = ctx.userAgent;\n }\n\n const init: RequestInit = {\n method: options.method,\n headers,\n body: undefined,\n signal: options.signal,\n };\n\n if (options.body !== undefined) {\n headers[\"Content-Type\"] = headers[\"Content-Type\"] ?? \"application/json\";\n init.body = headers[\"Content-Type\"].includes(\"application/json\")\n ? JSON.stringify(options.body)\n : (options.body as BodyInit);\n }\n\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n let controller: AbortController | undefined;\n\n if (!options.signal && ctx.timeoutMs && ctx.timeoutMs > 0) {\n controller = new AbortController();\n timeoutId = setTimeout(() => controller?.abort(), ctx.timeoutMs);\n init.signal = controller.signal;\n }\n\n try {\n const response = await ctx.fetch(url, init);\n const data = await parseResponseBody(response);\n\n if (!response.ok) {\n const message = extractErrorMessage(data, response.status);\n throw new CelestoApiError(message, response.status, data, response.headers.get(\"x-request-id\") ?? undefined);\n }\n\n return data as T;\n } catch (err) {\n if (err instanceof CelestoApiError) {\n throw err;\n }\n const error = err instanceof Error ? err : new Error(String(err));\n throw new CelestoNetworkError(error.message, error);\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n};\n","import { buildRequestContext, ClientConfig, RequestOverrides } from \"../core/config\";\nimport { request } from \"../core/http\";\nimport {\n GatekeeperAccessRules,\n GatekeeperAccessRulesParams,\n GatekeeperConnectRequest,\n GatekeeperConnectResponse,\n GatekeeperConnection,\n GatekeeperDriveFile,\n GatekeeperDriveListParams,\n GatekeeperDriveListResponse,\n GatekeeperListConnectionsParams,\n GatekeeperListConnectionsResponse,\n GatekeeperRevokeParams,\n GatekeeperRevokeResponse,\n} from \"./types\";\n\ninterface GatekeeperConnectRequestWire {\n subject: string;\n provider: string;\n project_name: string;\n redirect_uri?: string;\n}\n\ninterface GatekeeperConnectResponseWire {\n status: string;\n oauth_url?: string | null;\n connection_id?: string | null;\n}\n\ninterface GatekeeperConnectionWire {\n id: string;\n subject: string;\n provider: string;\n project_id: string;\n account_email?: string | null;\n scopes?: string[];\n status: string;\n created_at: string;\n updated_at: string;\n last_used_at?: string | null;\n access_rules?: {\n allowed_folders?: string[];\n allowed_files?: string[];\n version?: string;\n } | null;\n}\n\ninterface GatekeeperListConnectionsResponseWire {\n data: GatekeeperConnectionWire[];\n total: number;\n}\n\ninterface GatekeeperDriveFileWire {\n id: string;\n name?: string | null;\n mime_type?: string | null;\n size?: number | null;\n modified_time?: string | null;\n created_time?: string | null;\n web_view_link?: string | null;\n icon_link?: string | null;\n thumbnail_link?: string | null;\n parents?: string[] | null;\n drive_id?: string | null;\n shared?: boolean | null;\n owned_by_me?: boolean | null;\n}\n\ninterface GatekeeperDriveListResponseWire {\n files: GatekeeperDriveFileWire[];\n next_page_token?: string | null;\n}\n\ninterface GatekeeperAccessRulesResponseWire {\n version: string;\n allowed_folders: string[];\n allowed_files: string[];\n unrestricted: boolean;\n}\n\nconst toConnectRequest = (payload: GatekeeperConnectRequest): GatekeeperConnectRequestWire => ({\n subject: payload.subject,\n provider: payload.provider ?? \"google_drive\",\n project_name: payload.projectName,\n redirect_uri: payload.redirectUri,\n});\n\nconst toConnectResponse = (payload: GatekeeperConnectResponseWire): GatekeeperConnectResponse => ({\n status: payload.status,\n oauthUrl: payload.oauth_url ?? undefined,\n connectionId: payload.connection_id ?? undefined,\n});\n\nconst toConnection = (payload: GatekeeperConnectionWire): GatekeeperConnection => ({\n id: payload.id,\n subject: payload.subject,\n provider: payload.provider,\n projectId: payload.project_id,\n accountEmail: payload.account_email ?? null,\n scopes: payload.scopes ?? [],\n status: payload.status,\n createdAt: payload.created_at,\n updatedAt: payload.updated_at,\n lastUsedAt: payload.last_used_at ?? null,\n accessRules: payload.access_rules\n ? {\n version: payload.access_rules.version ?? \"1\",\n allowedFolders: payload.access_rules.allowed_folders ?? [],\n allowedFiles: payload.access_rules.allowed_files ?? [],\n unrestricted: false,\n }\n : null,\n});\n\nconst toAccessRules = (payload: GatekeeperAccessRulesResponseWire): GatekeeperAccessRules => ({\n version: payload.version,\n allowedFolders: payload.allowed_folders ?? [],\n allowedFiles: payload.allowed_files ?? [],\n unrestricted: payload.unrestricted,\n});\n\nconst toDriveFile = (payload: GatekeeperDriveFileWire): GatekeeperDriveFile => ({\n id: payload.id,\n name: payload.name ?? null,\n mimeType: payload.mime_type ?? null,\n size: payload.size ?? null,\n modifiedTime: payload.modified_time ?? null,\n createdTime: payload.created_time ?? null,\n webViewLink: payload.web_view_link ?? null,\n iconLink: payload.icon_link ?? null,\n thumbnailLink: payload.thumbnail_link ?? null,\n parents: payload.parents ?? null,\n driveId: payload.drive_id ?? null,\n shared: payload.shared ?? null,\n ownedByMe: payload.owned_by_me ?? null,\n});\n\nconst gatekeeperPath = (path: string): string => `/v1/gatekeeper${path}`;\n\nconst pickOverrides = (options?: RequestOverrides): RequestOverrides => ({\n headers: options?.headers,\n signal: options?.signal,\n});\n\nexport class GatekeeperClient {\n private readonly config: ClientConfig;\n\n constructor(config: ClientConfig) {\n this.config = config;\n }\n\n async connect(payload: GatekeeperConnectRequest, options?: RequestOverrides): Promise<GatekeeperConnectResponse> {\n const ctx = buildRequestContext(this.config);\n const data = await request<GatekeeperConnectResponseWire>(ctx, {\n method: \"POST\",\n path: gatekeeperPath(\"/connect\"),\n body: toConnectRequest(payload),\n ...pickOverrides(options),\n });\n return toConnectResponse(data);\n }\n\n async listConnections(params: GatekeeperListConnectionsParams, options?: RequestOverrides): Promise<GatekeeperListConnectionsResponse> {\n const ctx = buildRequestContext(this.config);\n const data = await request<GatekeeperListConnectionsResponseWire>(ctx, {\n method: \"GET\",\n path: gatekeeperPath(\"/connections\"),\n query: {\n project_name: params.projectName,\n status_filter: params.statusFilter,\n },\n ...pickOverrides(options),\n });\n\n return {\n total: data.total,\n data: data.data.map(toConnection),\n };\n }\n\n async getConnection(connectionId: string, options?: RequestOverrides): Promise<GatekeeperConnection> {\n const ctx = buildRequestContext(this.config);\n const data = await request<GatekeeperConnectionWire>(ctx, {\n method: \"GET\",\n path: gatekeeperPath(`/connections/${connectionId}`),\n ...pickOverrides(options),\n });\n return toConnection(data);\n }\n\n async revokeConnection(params: GatekeeperRevokeParams, options?: RequestOverrides): Promise<GatekeeperRevokeResponse> {\n const ctx = buildRequestContext(this.config);\n return request<GatekeeperRevokeResponse>(ctx, {\n method: \"DELETE\",\n path: gatekeeperPath(\"/connections\"),\n query: {\n subject: params.subject,\n project_name: params.projectName,\n provider: params.provider,\n },\n ...pickOverrides(options),\n });\n }\n\n async listDriveFiles(params: GatekeeperDriveListParams, options?: RequestOverrides): Promise<GatekeeperDriveListResponse> {\n const ctx = buildRequestContext(this.config);\n const data = await request<GatekeeperDriveListResponseWire>(ctx, {\n method: \"GET\",\n path: gatekeeperPath(\"/connectors/drive/files\"),\n query: {\n project_name: params.projectName,\n subject: params.subject,\n page_size: params.pageSize,\n page_token: params.pageToken,\n folder_id: params.folderId,\n query: params.query,\n include_folders: params.includeFolders,\n order_by: params.orderBy,\n },\n ...pickOverrides(options),\n });\n\n return {\n files: data.files.map(toDriveFile),\n nextPageToken: data.next_page_token ?? null,\n };\n }\n\n async getAccessRules(connectionId: string, options?: RequestOverrides): Promise<GatekeeperAccessRules> {\n const ctx = buildRequestContext(this.config);\n const data = await request<GatekeeperAccessRulesResponseWire>(ctx, {\n method: \"GET\",\n path: gatekeeperPath(`/connections/${connectionId}/access-rules`),\n ...pickOverrides(options),\n });\n return toAccessRules(data);\n }\n\n async updateAccessRules(params: GatekeeperAccessRulesParams, options?: RequestOverrides): Promise<GatekeeperAccessRules> {\n const ctx = buildRequestContext(this.config);\n const data = await request<GatekeeperAccessRulesResponseWire>(ctx, {\n method: \"PUT\",\n path: gatekeeperPath(\"/connections/access-rules\"),\n query: {\n subject: params.subject,\n project_name: params.projectName,\n provider: params.provider,\n },\n body: {\n allowed_folders: params.accessRules.allowedFolders ?? [],\n allowed_files: params.accessRules.allowedFiles ?? [],\n },\n ...pickOverrides(options),\n });\n return toAccessRules(data);\n }\n\n async clearAccessRules(connectionId: string, options?: RequestOverrides): Promise<GatekeeperAccessRules> {\n const ctx = buildRequestContext(this.config);\n const data = await request<GatekeeperAccessRulesResponseWire>(ctx, {\n method: \"DELETE\",\n path: gatekeeperPath(`/connections/${connect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AAqC,SAA4D;AACvH,UAAM,MAAM,oBAAoB,KAAK,MAAM;AAC3C,UAAM,OAAO,MAAM,QAA2C,KAAK;AAAA,MACjE,QAAQ;AAAA,MACR,MAAM,eAAe,2BAA2B;AAAA,MAChD,OAAO;AAAA,QACL,SAAS,OAAO;AAAA,QAChB,cAAc,OAAO;AAAA,QACrB,UAAU,OAAO;AAAA,MACnB;AAAA,MACA,MAAM;AAAA,QACJ,iBAAiB,OAAO,YAAY,kBAAkB,CAAC;AAAA,QACvD,eAAe,OAAO,YAAY,gBAAgB,CAAC;AAAA,MACrD;AAAA,MACA,GAAG,cAAc,OAAO;AAAA,IAC1B,CAAC;AACD,WAAO,cAAc,IAAI;AAAA,EAC3B;AAAA,EAEA,MAAM,iBAAiB,cAAsB,SAA4D;AACvG,UAAM,MAAM,oBAAoB,KAAK,MAAM;AAC3C,UAAM,OAAO,MAAM,QAA2C,KAAK;AAAA,MACjE,QAAQ;AAAA,MACR,MAAM,eAAe,gBAAgB,YAAY,eAAe;AAAA,MAChE,GAAG,cAAc,OAAO;AAAA,IAC1B,CAAC;AACD,WAAO,cAAc,IAAI;AAAA,EAC3B;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/gatekeeper/index.ts","../../src/core/config.ts","../../src/core/errors.ts","../../src/core/http.ts","../../src/gatekeeper/client.ts"],"sourcesContent":["export { GatekeeperClient } from \"./client\";\nexport type {\n GatekeeperAccessRules,\n GatekeeperAccessRulesParams,\n GatekeeperAccessRulesUpdate,\n GatekeeperConnectRequest,\n GatekeeperConnectResponse,\n GatekeeperConnection,\n GatekeeperDriveFile,\n GatekeeperDriveListParams,\n GatekeeperDriveListResponse,\n GatekeeperListConnectionsParams,\n GatekeeperListConnectionsResponse,\n GatekeeperRevokeParams,\n GatekeeperRevokeResponse,\n} from \"./types\";\nexport type { RequestOverrides } from \"../core/config\";\n","export type FetchLike = typeof fetch;\n\nexport interface ClientConfig {\n /** Base API URL, e.g. https://api.celesto.ai */\n baseUrl?: string;\n /** Bearer token (API key or JWT). */\n token?: string;\n /** Alias for token. */\n apiKey?: string;\n /** Organization ID to send as X-Current-Organization. */\n organizationId?: string;\n /** Optional user agent for server-side requests. */\n userAgent?: string;\n /** Default request timeout in milliseconds. */\n timeoutMs?: number;\n /** Override fetch implementation (useful for testing). */\n fetch?: FetchLike;\n /** Default headers to include in every request. */\n headers?: Record<string, string>;\n}\n\nexport interface RequestOptions {\n method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n path: string;\n query?: Record<string, string | number | boolean | undefined | null | (string | number | boolean)[]>;\n body?: unknown;\n headers?: Record<string, string>;\n signal?: AbortSignal;\n}\n\nexport interface RequestOverrides {\n headers?: Record<string, string>;\n signal?: AbortSignal;\n}\n\nexport interface RequestContext {\n fetch: FetchLike;\n baseUrl: string;\n token?: string;\n organizationId?: string;\n userAgent?: string;\n timeoutMs?: number;\n headers?: Record<string, string>;\n}\n\nexport const DEFAULT_BASE_URL = \"https://api.celesto.ai\";\n\nexport const buildRequestContext = (config: ClientConfig): RequestContext => ({\n fetch: config.fetch ?? fetch,\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n token: config.token ?? config.apiKey,\n organizationId: config.organizationId,\n userAgent: config.userAgent,\n timeoutMs: config.timeoutMs,\n headers: config.headers,\n});\n","/** Base error for all Celesto SDK errors. */\nexport class CelestoError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"CelestoError\";\n }\n}\n\n/** Thrown when an API request returns a non-2xx HTTP status. */\nexport class CelestoApiError extends CelestoError {\n readonly status: number;\n readonly data: unknown;\n readonly requestId?: string;\n\n constructor(message: string, status: number, data: unknown, requestId?: string) {\n super(message);\n this.name = \"CelestoApiError\";\n this.status = status;\n this.data = data;\n this.requestId = requestId;\n }\n}\n\n/** Thrown when fetch() itself fails — DNS, network, timeout, abort. */\nexport class CelestoNetworkError extends CelestoError {\n readonly cause?: Error;\n\n constructor(message: string, cause?: Error) {\n super(message);\n this.name = \"CelestoNetworkError\";\n this.cause = cause;\n }\n}\n","import { CelestoApiError, CelestoNetworkError } from \"./errors\";\nimport { RequestContext, RequestOptions } from \"./config\";\n\nconst joinUrl = (baseUrl: string, path: string): string => {\n const trimmedBase = baseUrl.endsWith(\"/\") ? baseUrl.slice(0, -1) : baseUrl;\n const normalizedPath = path.startsWith(\"/\") ? path : `/${path}`;\n return `${trimmedBase}${normalizedPath}`;\n};\n\nconst buildQuery = (\n query?: RequestOptions[\"query\"],\n): string => {\n if (!query) {\n return \"\";\n }\n\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) {\n continue;\n }\n if (Array.isArray(value)) {\n for (const item of value) {\n params.append(key, String(item));\n }\n continue;\n }\n params.set(key, String(value));\n }\n\n const serialized = params.toString();\n return serialized ? `?${serialized}` : \"\";\n};\n\nconst parseResponseBody = async (response: Response): Promise<unknown> => {\n if (response.status === 204) {\n return undefined;\n }\n\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (contentType.includes(\"application/json\")) {\n return response.json();\n }\n\n return response.text();\n};\n\nconst extractErrorMessage = (data: unknown, status: number): string => {\n if (data && typeof data === \"object\") {\n const record = data as Record<string, unknown>;\n if (typeof record.detail === \"string\") {\n return record.detail;\n }\n if (typeof record.message === \"string\") {\n return record.message;\n }\n if (typeof record.error === \"string\") {\n return record.error;\n }\n }\n return `Request failed with status ${status}`;\n};\n\nconst buildRequestInit = (\n ctx: RequestContext,\n options: RequestOptions,\n): { url: string; init: RequestInit } => {\n const url = `${joinUrl(ctx.baseUrl, options.path)}${buildQuery(options.query)}`;\n const headers: Record<string, string> = {\n ...(ctx.headers ?? {}),\n ...(options.headers ?? {}),\n };\n\n if (ctx.token) {\n headers.Authorization = `Bearer ${ctx.token}`;\n }\n if (ctx.organizationId) {\n headers[\"X-Current-Organization\"] = ctx.organizationId;\n }\n if (ctx.userAgent && !headers[\"User-Agent\"]) {\n headers[\"User-Agent\"] = ctx.userAgent;\n }\n\n const init: RequestInit = {\n method: options.method,\n headers,\n signal: options.signal,\n };\n if (options.body !== undefined) {\n headers[\"Content-Type\"] = headers[\"Content-Type\"] ?? \"application/json\";\n init.body = headers[\"Content-Type\"].includes(\"application/json\")\n ? JSON.stringify(options.body)\n : (options.body as BodyInit);\n }\n return { url, init };\n};\n\nexport const request = async <T>(ctx: RequestContext, options: RequestOptions): Promise<T> => {\n const { url, init } = buildRequestInit(ctx, options);\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n let controller: AbortController | undefined;\n\n if (!options.signal && ctx.timeoutMs && ctx.timeoutMs > 0) {\n controller = new AbortController();\n timeoutId = setTimeout(() => controller?.abort(), ctx.timeoutMs);\n init.signal = controller.signal;\n }\n\n try {\n const response = await ctx.fetch(url, init);\n const data = await parseResponseBody(response);\n\n if (!response.ok) {\n const message = extractErrorMessage(data, response.status);\n throw new CelestoApiError(message, response.status, data, response.headers.get(\"x-request-id\") ?? undefined);\n }\n\n return data as T;\n } catch (err) {\n if (err instanceof CelestoApiError) {\n throw err;\n }\n const error = err instanceof Error ? err : new Error(String(err));\n throw new CelestoNetworkError(error.message, error);\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n};\n\n/** Make an authenticated request without consuming its response body. */\nexport const requestStream = async (\n ctx: RequestContext,\n options: RequestOptions,\n): Promise<Response> => {\n const { url, init } = buildRequestInit(ctx, options);\n try {\n const response = await ctx.fetch(url, init);\n if (!response.ok) {\n const data = await parseResponseBody(response);\n const message = extractErrorMessage(data, response.status);\n throw new CelestoApiError(\n message,\n response.status,\n data,\n response.headers.get(\"x-request-id\") ?? undefined,\n );\n }\n return response;\n } catch (err) {\n if (err instanceof CelestoApiError) {\n throw err;\n }\n const error = err instanceof Error ? err : new Error(String(err));\n throw new CelestoNetworkError(error.message, error);\n }\n};\n","import { buildRequestContext, ClientConfig, RequestOverrides } from \"../core/config\";\nimport { request } from \"../core/http\";\nimport {\n GatekeeperAccessRules,\n GatekeeperAccessRulesParams,\n GatekeeperConnectRequest,\n GatekeeperConnectResponse,\n GatekeeperConnection,\n GatekeeperDriveFile,\n GatekeeperDriveListParams,\n GatekeeperDriveListResponse,\n GatekeeperListConnectionsParams,\n GatekeeperListConnectionsResponse,\n GatekeeperRevokeParams,\n GatekeeperRevokeResponse,\n} from \"./types\";\n\ninterface GatekeeperConnectRequestWire {\n subject: string;\n provider: string;\n project_name: string;\n redirect_uri?: string;\n}\n\ninterface GatekeeperConnectResponseWire {\n status: string;\n oauth_url?: string | null;\n connection_id?: string | null;\n}\n\ninterface GatekeeperConnectionWire {\n id: string;\n subject: string;\n provider: string;\n project_id: string;\n account_email?: string | null;\n scopes?: string[];\n status: string;\n created_at: string;\n updated_at: string;\n last_used_at?: string | null;\n access_rules?: {\n allowed_folders?: string[];\n allowed_files?: string[];\n version?: string;\n } | null;\n}\n\ninterface GatekeeperListConnectionsResponseWire {\n data: GatekeeperConnectionWire[];\n total: number;\n}\n\ninterface GatekeeperDriveFileWire {\n id: string;\n name?: string | null;\n mime_type?: string | null;\n size?: number | null;\n modified_time?: string | null;\n created_time?: string | null;\n web_view_link?: string | null;\n icon_link?: string | null;\n thumbnail_link?: string | null;\n parents?: string[] | null;\n drive_id?: string | null;\n shared?: boolean | null;\n owned_by_me?: boolean | null;\n}\n\ninterface GatekeeperDriveListResponseWire {\n files: GatekeeperDriveFileWire[];\n next_page_token?: string | null;\n}\n\ninterface GatekeeperAccessRulesResponseWire {\n version: string;\n allowed_folders: string[];\n allowed_files: string[];\n unrestricted: boolean;\n}\n\nconst toConnectRequest = (payload: GatekeeperConnectRequest): GatekeeperConnectRequestWire => ({\n subject: payload.subject,\n provider: payload.provider ?? \"google_drive\",\n project_name: payload.projectName,\n redirect_uri: payload.redirectUri,\n});\n\nconst toConnectResponse = (payload: GatekeeperConnectResponseWire): GatekeeperConnectResponse => ({\n status: payload.status,\n oauthUrl: payload.oauth_url ?? undefined,\n connectionId: payload.connection_id ?? undefined,\n});\n\nconst toConnection = (payload: GatekeeperConnectionWire): GatekeeperConnection => ({\n id: payload.id,\n subject: payload.subject,\n provider: payload.provider,\n projectId: payload.project_id,\n accountEmail: payload.account_email ?? null,\n scopes: payload.scopes ?? [],\n status: payload.status,\n createdAt: payload.created_at,\n updatedAt: payload.updated_at,\n lastUsedAt: payload.last_used_at ?? null,\n accessRules: payload.access_rules\n ? {\n version: payload.access_rules.version ?? \"1\",\n allowedFolders: payload.access_rules.allowed_folders ?? [],\n allowedFiles: payload.access_rules.allowed_files ?? [],\n unrestricted: false,\n }\n : null,\n});\n\nconst toAccessRules = (payload: GatekeeperAccessRulesResponseWire): GatekeeperAccessRules => ({\n version: payload.version,\n allowedFolders: payload.allowed_folders ?? [],\n allowedFiles: payload.allowed_files ?? [],\n unrestricted: payload.unrestricted,\n});\n\nconst toDriveFile = (payload: GatekeeperDriveFileWire): GatekeeperDriveFile => ({\n id: payload.id,\n name: payload.name ?? null,\n mimeType: payload.mime_type ?? null,\n size: payload.size ?? null,\n modifiedTime: payload.modified_time ?? null,\n createdTime: payload.created_time ?? null,\n webViewLink: payload.web_view_link ?? null,\n iconLink: payload.icon_link ?? null,\n thumbnailLink: payload.thumbnail_link ?? null,\n parents: payload.parents ?? null,\n driveId: payload.drive_id ?? null,\n shared: payload.shared ?? null,\n ownedByMe: payload.owned_by_me ?? null,\n});\n\nconst gatekeeperPath = (path: string): string => `/v1/gatekeeper${path}`;\n\nconst pickOverrides = (options?: RequestOverrides): RequestOverrides => ({\n headers: options?.headers,\n signal: options?.signal,\n});\n\nexport class GatekeeperClient {\n private readonly config: ClientConfig;\n\n constructor(config: ClientConfig) {\n this.config = config;\n }\n\n async connect(payload: GatekeeperConnectRequest, options?: RequestOverrides): Promise<GatekeeperConnectResponse> {\n const ctx = buildRequestContext(this.config);\n const data = await request<GatekeeperConnectResponseWire>(ctx, {\n method: \"POST\",\n path: gatekeeperPath(\"/connect\"),\n body: toConnectRequest(payload),\n ...pickOverrides(options),\n });\n return toConnectResponse(data);\n }\n\n async listConnections(params: GatekeeperListConnectionsParams, options?: RequestOverrides): Promise<GatekeeperListConnectionsResponse> {\n const ctx = buildRequestContext(this.config);\n const data = await request<GatekeeperListConnectionsResponseWire>(ctx, {\n method: \"GET\",\n path: gatekeeperPath(\"/connections\"),\n query: {\n project_name: params.projectName,\n status_filter: params.statusFilter,\n },\n ...pickOverrides(options),\n });\n\n return {\n total: data.total,\n data: data.data.map(toConnection),\n };\n }\n\n async getConnection(connectionId: string, options?: RequestOverrides): Promise<GatekeeperConnection> {\n const ctx = buildRequestContext(this.config);\n const data = await request<GatekeeperConnectionWire>(ctx, {\n method: \"GET\",\n path: gatekeeperPath(`/connections/${connectionId}`),\n ...pickOverrides(options),\n });\n return toConnection(data);\n }\n\n async revokeConnection(params: GatekeeperRevokeParams, options?: RequestOverrides): Promise<GatekeeperRevokeResponse> {\n const ctx = buildRequestContext(this.config);\n return request<GatekeeperRevokeResponse>(ctx, {\n method: \"DELETE\",\n path: gatekeeperPath(\"/connections\"),\n query: {\n subject: params.subject,\n project_name: params.projectName,\n provider: params.provider,\n },\n ...pickOverrides(options),\n });\n }\n\n async listDriveFiles(params: GatekeeperDriveListParams, options?: RequestOverrides): Promise<GatekeeperDriveListResponse> {\n const ctx = buildRequestContext(this.config);\n const data = await request<GatekeeperDriveListResponseWire>(ctx, {\n method: \"GET\",\n path: gatekeeperPath(\"/connectors/drive/files\"),\n query: {\n project_name: params.projectName,\n subject: params.subject,\n page_size: params.pageSize,\n page_token: params.pageToken,\n folder_id: params.folderId,\n query: params.query,\n include_folders: params.includeFolders,\n order_by: params.orderBy,\n },\n ...pickOverrides(options),\n });\n\n return {\n files: data.files.map(toDriveFile),\n nextPageToken: data.next_page_token ?? null,\n };\n }\n\n async getAccessRules(connectionId: string, options?: RequestOverrides): Promise<GatekeeperAccessRules> {\n const ctx = buildRequestContext(this.config);\n const data = await request<GatekeeperAccessRulesResponseWire>(ctx, {\n method: \"GET\",\n path: gatekeeperPath(`/connections/${connectionId}/access-rules`),\n ...pickOverrides(options),\n });\n return toAccessRules(data);\n }\n\n async updateAccessRules(params: GatekeeperAccessRulesParams, options?: RequestOverrides): Promise<GatekeeperAccessRules> {\n const ctx = buildRequestContext(this.config);\n const data = await request<GatekeeperAccessRulesResponseWire>(ctx, {\n method: \"PUT\",\n path: gatekeeperPath(\"/connections/access-rules\"),\n query: {\n subject: params.subject,\n project_name: params.projectName,\n provider: params.provider,\n },\n body: {\n allowed_folders: params.accessRules.allowedFolders ?? [],\n allowed_files: params.accessRules.allowedFiles ?? [],\n },\n ...pickOverrides(options),\n });\n return toAccessRules(data);\n }\n\n async clearAccessRules(connectionId: string, options?: RequestOverrides): Promise<GatekeeperAccessRules> {\n const ctx = buildRequestContext(this.config);\n const data = await request<GatekeeperAccessRulesResponseWire>(ctx, {\n method: \"DELETE\",\n path: gatekeeperPath(`/connections/${connectionId}/access-rules`),\n ...pickOverrides(options),\n });\n return toAccessRules(data);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6CO,IAAM,mBAAmB;AAEzB,IAAM,sBAAsB,CAAC,YAA0C;AAAA,EAC5E,OAAO,OAAO,SAAS;AAAA,EACvB,SAAS,OAAO,WAAW;AAAA,EAC3B,OAAO,OAAO,SAAS,OAAO;AAAA,EAC9B,gBAAgB,OAAO;AAAA,EACvB,WAAW,OAAO;AAAA,EAClB,WAAW,OAAO;AAAA,EAClB,SAAS,OAAO;AAClB;;;ACtDO,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAGO,IAAM,kBAAN,cAA8B,aAAa;AAAA,EAKhD,YAAY,SAAiB,QAAgB,MAAe,WAAoB;AAC9E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SAAK,YAAY;AAAA,EACnB;AACF;AAGO,IAAM,sBAAN,cAAkC,aAAa;A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