@gitterm/sdk 0.0.1 → 0.0.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/src/index.d.ts DELETED
@@ -1,213 +0,0 @@
1
- /**
2
- * Hand-maintained public type surface for @gitterm/sdk.
3
- *
4
- * External npm consumers resolve these types instead of the TypeScript
5
- * sources, because the sources derive types from the private @gitterm/api
6
- * router. Keep this file in sync with src/types.ts and src/client.ts.
7
- *
8
- * TODO: replace with generated declarations once the AppRouter types can be
9
- * bundled into a standalone .d.ts.
10
- */
11
-
12
- export const DEFAULT_GITTERM_SERVER_URL: string;
13
-
14
- export type CliConfig = {
15
- serverUrl: string;
16
- token: string;
17
- createdAt: number;
18
- };
19
-
20
- export type GittermErrorCode =
21
- | "NOT_LOGGED_IN"
22
- | "UNAUTHORIZED"
23
- | "NOT_FOUND"
24
- | "FORBIDDEN"
25
- | "BAD_REQUEST"
26
- | "SERVER_ERROR"
27
- | "NETWORK";
28
-
29
- export class GittermError extends Error {
30
- readonly code: GittermErrorCode;
31
- readonly cause?: unknown;
32
- constructor(code: GittermErrorCode, message: string, options?: { cause?: unknown });
33
- }
34
-
35
- export type GittermClientOptions = {
36
- serverUrl?: string;
37
- token?: string;
38
- configPath?: string;
39
- fetch?: typeof fetch;
40
- };
41
-
42
- export type AuthStatus = {
43
- loggedIn: true;
44
- userId: string;
45
- email: string;
46
- name: string;
47
- plan: string;
48
- authMethod: "session" | "apiToken";
49
- };
50
-
51
- export type WorkspaceStatus = "pending" | "running" | "paused" | "terminated";
52
- export type WorkspaceHostingType = "cloud" | "local";
53
-
54
- export type Workspace = {
55
- id: string;
56
- name: string | null;
57
- status: WorkspaceStatus;
58
- repositoryUrl: string | null;
59
- repositoryBranch: string | null;
60
- baseCommit: string | null;
61
- checkoutRef: string | null;
62
- domain: string;
63
- subdomain: string | null;
64
- persistent: boolean;
65
- hostingType: WorkspaceHostingType;
66
- serverOnly: boolean;
67
- workspaceProfile: string;
68
- cloudProviderId: string;
69
- agentType: { id: string; name: string; description: string | null } | null;
70
- image: { id: string; name: string; imageId: string } | null;
71
- startedAt: string | null;
72
- stoppedAt: string | null;
73
- terminatedAt: string | null;
74
- lastActiveAt: string | null;
75
- updatedAt: string | null;
76
- };
77
-
78
- export type WorkspaceRuntimeAccess = {
79
- workspaceId: string;
80
- status: WorkspaceStatus;
81
- url: string | null;
82
- headers?: Record<string, string>;
83
- password?: string;
84
- directory: string;
85
- repo: string | null;
86
- branch: string | null;
87
- baseCommit: string | null;
88
- checkoutRef: string | null;
89
- persistent: boolean;
90
- recoverable: boolean;
91
- providerKey: string | null;
92
- };
93
-
94
- export type WorkspaceCreateResult = {
95
- workspace: Workspace;
96
- runtime: WorkspaceRuntimeAccess;
97
- };
98
-
99
- export type WorkspaceListOptions = {
100
- limit?: number;
101
- offset?: number;
102
- status?: "all" | "active" | "terminated";
103
- };
104
-
105
- export type WorkspaceListResult = {
106
- workspaces: Workspace[];
107
- pagination: {
108
- total: number;
109
- limit: number;
110
- offset: number;
111
- hasMore: boolean;
112
- };
113
- };
114
-
115
- export type WorkspaceCreateInput = {
116
- name?: string;
117
- repo?: string;
118
- branch?: string;
119
- baseCommit?: string;
120
- checkoutRef?: string;
121
- subdomain?: string;
122
- agentTypeId: string;
123
- cloudProviderId: string;
124
- regionId?: string;
125
- gitIntegrationId?: string;
126
- persistent: boolean;
127
- workspaceProfile?: "standard" | "ssh-enabled";
128
- };
129
-
130
- export type WorkspaceStopResult = { durationMinutes: number };
131
- export type WorkspacePauseResult = WorkspaceStopResult;
132
- export type WorkspaceRestartResult = { status: WorkspaceStatus };
133
- export type WorkspaceTerminateResult = {
134
- workspace: Workspace | null;
135
- cleanupInBackground: boolean;
136
- };
137
- export type WorkspaceEnsureRunningResult = {
138
- workspace: Workspace;
139
- runtime: WorkspaceRuntimeAccess;
140
- };
141
-
142
- export type AgentType = {
143
- id: string;
144
- name: string;
145
- description: string | null;
146
- serverOnly: boolean;
147
- isEnabled: boolean;
148
- createdAt: Date | string;
149
- updatedAt: Date | string;
150
- };
151
-
152
- export type CloudProvider = Record<string, unknown> & {
153
- id: string;
154
- name: string;
155
- providerKey: string;
156
- regions?: Array<Record<string, unknown>>;
157
- };
158
-
159
- export type GittermClient = {
160
- serverUrl: string;
161
- auth: {
162
- status(): Promise<AuthStatus>;
163
- };
164
- workspaces: {
165
- list(input?: WorkspaceListOptions): Promise<WorkspaceListResult>;
166
- get(workspaceId: string): Promise<Workspace>;
167
- getRuntimeAccess(workspaceId: string): Promise<WorkspaceRuntimeAccess>;
168
- ensureRunning(
169
- workspaceId: string,
170
- options?: { timeoutMs?: number; pollIntervalMs?: number },
171
- ): Promise<WorkspaceEnsureRunningResult>;
172
- pause(workspaceId: string): Promise<WorkspacePauseResult>;
173
- restart(workspaceId: string): Promise<WorkspaceRestartResult>;
174
- terminate(workspaceId: string): Promise<WorkspaceTerminateResult>;
175
- create(input: WorkspaceCreateInput): Promise<WorkspaceCreateResult>;
176
- createSandbox(input: WorkspaceCreateInput): Promise<WorkspaceCreateResult>;
177
- };
178
- catalog: {
179
- agentTypes(input?: { serverOnly?: boolean }): Promise<AgentType[]>;
180
- cloudProviders(input?: {
181
- localOnly?: boolean;
182
- cloudOnly?: boolean;
183
- sandboxOnly?: boolean;
184
- nonSandboxOnly?: boolean;
185
- }): Promise<CloudProvider[]>;
186
- };
187
- };
188
-
189
- export function createGittermClient(options?: GittermClientOptions): GittermClient;
190
- export function getConfigPath(configPath?: string): string;
191
- export function loadConfig(configPath?: string): Promise<CliConfig | null>;
192
- export function loadConfigSync(configPath?: string): CliConfig | null;
193
- export function saveConfig(config: CliConfig, configPath?: string): Promise<void>;
194
- export function deleteConfig(configPath?: string): Promise<void>;
195
-
196
- export type DeviceCodeInfo = {
197
- deviceCode: string;
198
- userCode: string;
199
- verificationUri: string;
200
- intervalSeconds: number;
201
- expiresInSeconds: number;
202
- };
203
-
204
- export type LoginWithDeviceCodeOptions = {
205
- clientName?: string;
206
- fetch?: typeof fetch;
207
- onCode?: (code: Omit<DeviceCodeInfo, "deviceCode">) => void | Promise<void>;
208
- };
209
-
210
- export function loginWithDeviceCode(
211
- serverUrl: string,
212
- options?: LoginWithDeviceCodeOptions,
213
- ): Promise<{ token: string }>;