@gitterm/sdk 0.9.0 → 0.10.0
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/dist/direct/index.js +3 -3
- package/dist/errors.d.ts +4 -1
- package/dist/index.js +14 -15
- package/dist/types.d.ts +2 -1
- package/package.json +1 -1
package/dist/direct/index.js
CHANGED
|
@@ -2177,12 +2177,12 @@ var WORKSPACE_LIFECYCLE_ERROR_CODES = [
|
|
|
2177
2177
|
|
|
2178
2178
|
class GittermError extends Error {
|
|
2179
2179
|
code;
|
|
2180
|
-
|
|
2180
|
+
status;
|
|
2181
2181
|
constructor(code, message, options = {}) {
|
|
2182
|
-
super(message);
|
|
2182
|
+
super(message, "cause" in options ? { cause: options.cause } : undefined);
|
|
2183
2183
|
this.name = "GittermError";
|
|
2184
2184
|
this.code = code;
|
|
2185
|
-
this.
|
|
2185
|
+
this.status = options.status;
|
|
2186
2186
|
}
|
|
2187
2187
|
}
|
|
2188
2188
|
|
package/dist/errors.d.ts
CHANGED
|
@@ -5,15 +5,18 @@ export type WorkspaceLifecycleErrorCode = "WORKSPACE_NOT_RUNNING" | "WORKSPACE_T
|
|
|
5
5
|
export declare const WORKSPACE_LIFECYCLE_ERROR_CODES: readonly WorkspaceLifecycleErrorCode[];
|
|
6
6
|
export declare class GittermError extends Error {
|
|
7
7
|
readonly code: GittermErrorCode;
|
|
8
|
-
|
|
8
|
+
/** HTTP status of the API response; undefined when the server never answered. */
|
|
9
|
+
readonly status: number | undefined;
|
|
9
10
|
constructor(code: GittermErrorCode, message: string, options?: {
|
|
10
11
|
cause?: unknown;
|
|
12
|
+
status?: number;
|
|
11
13
|
});
|
|
12
14
|
}
|
|
13
15
|
export declare class WorkspaceLifecycleError extends GittermError {
|
|
14
16
|
readonly code: WorkspaceLifecycleErrorCode;
|
|
15
17
|
constructor(code: WorkspaceLifecycleErrorCode, message: string, options?: {
|
|
16
18
|
cause?: unknown;
|
|
19
|
+
status?: number;
|
|
17
20
|
});
|
|
18
21
|
}
|
|
19
22
|
/** result() could not produce a successful result. The run remains inspectable. */
|
package/dist/index.js
CHANGED
|
@@ -68,12 +68,12 @@ var WORKSPACE_LIFECYCLE_ERROR_CODES = [
|
|
|
68
68
|
|
|
69
69
|
class GittermError extends Error {
|
|
70
70
|
code;
|
|
71
|
-
|
|
71
|
+
status;
|
|
72
72
|
constructor(code, message, options = {}) {
|
|
73
|
-
super(message);
|
|
73
|
+
super(message, "cause" in options ? { cause: options.cause } : undefined);
|
|
74
74
|
this.name = "GittermError";
|
|
75
75
|
this.code = code;
|
|
76
|
-
this.
|
|
76
|
+
this.status = options.status;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -426,27 +426,26 @@ function toGittermError(serverUrl, error) {
|
|
|
426
426
|
return error;
|
|
427
427
|
if (error instanceof TRPCClientError) {
|
|
428
428
|
const data = error.data;
|
|
429
|
-
|
|
430
|
-
if (!error.data) {
|
|
429
|
+
if (!data) {
|
|
431
430
|
return new GittermError("NETWORK", `Could not reach the GitTerm server at ${serverUrl}`, {
|
|
432
|
-
cause: error
|
|
431
|
+
cause: error.cause ?? error
|
|
433
432
|
});
|
|
434
433
|
}
|
|
435
|
-
const
|
|
436
|
-
const structuredLifecycleCode = WORKSPACE_LIFECYCLE_ERROR_CODES.find((candidate) => candidate === data
|
|
434
|
+
const status = { status: data.httpStatus };
|
|
435
|
+
const structuredLifecycleCode = WORKSPACE_LIFECYCLE_ERROR_CODES.find((candidate) => candidate === data.workspaceLifecycleCode);
|
|
437
436
|
if (structuredLifecycleCode) {
|
|
438
|
-
return new WorkspaceLifecycleError(structuredLifecycleCode, error.message,
|
|
437
|
+
return new WorkspaceLifecycleError(structuredLifecycleCode, error.message, status);
|
|
439
438
|
}
|
|
440
439
|
if (error.message.startsWith("INPUT_NOT_PENDING:"))
|
|
441
|
-
return new GittermError("INPUT_NOT_PENDING", error.message,
|
|
440
|
+
return new GittermError("INPUT_NOT_PENDING", error.message, status);
|
|
442
441
|
const credentialCode = credentialErrorCode(error.message);
|
|
443
442
|
if (credentialCode)
|
|
444
|
-
return new GittermError(credentialCode, error.message,
|
|
443
|
+
return new GittermError(credentialCode, error.message, status);
|
|
445
444
|
const lifecycleCode = WORKSPACE_LIFECYCLE_ERROR_CODES.find((candidate) => error.message.startsWith(`${candidate}:`));
|
|
446
|
-
if (lifecycleCode)
|
|
447
|
-
return new WorkspaceLifecycleError(lifecycleCode, error.message,
|
|
448
|
-
|
|
449
|
-
return new GittermError(code, code === "UNAUTHORIZED" ?
|
|
445
|
+
if (lifecycleCode)
|
|
446
|
+
return new WorkspaceLifecycleError(lifecycleCode, error.message, status);
|
|
447
|
+
const code = mapTrpcCode(data.code);
|
|
448
|
+
return new GittermError(code, code === "UNAUTHORIZED" ? `${error.message}. Check your GitTerm API token, or create a new one in the dashboard.` : error.message, status);
|
|
450
449
|
}
|
|
451
450
|
return new GittermError("NETWORK", error instanceof Error ? error.message : "Network request failed", { cause: error });
|
|
452
451
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export type RunRef = {
|
|
|
62
62
|
id: string;
|
|
63
63
|
};
|
|
64
64
|
export type WaitOptions = {
|
|
65
|
+
/** For `ensureRunning` the server maximum is 240000 (4 minutes). */
|
|
65
66
|
timeoutMs?: number;
|
|
66
67
|
pollIntervalMs?: number;
|
|
67
68
|
/** Abort the wait early; the promise rejects with code `ABORTED`. */
|
|
@@ -262,7 +263,7 @@ export type McpConnectionDetails = {
|
|
|
262
263
|
revision?: number;
|
|
263
264
|
integration: "mcp" | "executor";
|
|
264
265
|
url: string;
|
|
265
|
-
authType: "none" | "headers";
|
|
266
|
+
authType: "none" | "bearer" | "headers";
|
|
266
267
|
codemode: boolean;
|
|
267
268
|
toolCount: number | null;
|
|
268
269
|
serverInfo: {
|