@sealant/api-contracts-next 0.40.0-next.756 → 0.40.0-next.758
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/core-api/control-plane.d.ts +1016 -1016
- package/dist/core-api/workspace-forward.d.ts +80 -0
- package/dist/core-api/workspace-forward.js +83 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace forward's v2 wire contract: `GET /v1/workspaces/:workspaceId/forward/v2` with the
|
|
3
|
+
* subprotocol {@link FORWARD_V2_SUBPROTOCOL}. A WHATWG `WebSocket` cannot read the status of a
|
|
4
|
+
* refused upgrade, so v2 accepts the upgrade first and answers with one text frame: `ready`, after
|
|
5
|
+
* which binary frames carry payload both ways, or `refused`, after which the server closes with
|
|
6
|
+
* {@link FORWARD_REFUSED_CLOSE_CODE}. A request without an upgrade gets 426 and is never dialled.
|
|
7
|
+
*/
|
|
8
|
+
import { Schema } from "effect";
|
|
9
|
+
export declare const FORWARD_V2_SUBPROTOCOL = "sealant.forward.v2";
|
|
10
|
+
/** The largest binary frame either side may send. */
|
|
11
|
+
export declare const FORWARD_V2_MAX_FRAME_BYTES: number;
|
|
12
|
+
/** Ends the socket after a `refused` frame. It says nothing about why: the frame's reason does. */
|
|
13
|
+
export declare const FORWARD_REFUSED_CLOSE_CODE = 4400;
|
|
14
|
+
export declare const forwardRefusalReasonSchema: Schema.Literals<readonly ["workspace-not-ready", "runtime-unreachable", "runtime-untargetable", "connection-refused", "name-unresolved", "network-unreachable", "dial-timeout", "dial-failed", "not-found", "unauthorized", "forbidden", "budget-exceeded", "invalid-target", "owner-required", "internal", "owner-exited", "peer-mismatch", "binding-unverifiable", "binding-unsupported"]>;
|
|
15
|
+
export type ForwardRefusalReason = typeof forwardRefusalReasonSchema.Type;
|
|
16
|
+
/** The HTTP status each refusal would have had before the upgrade. Callers branch on the reason. */
|
|
17
|
+
export declare const FORWARD_REFUSAL_STATUS: {
|
|
18
|
+
readonly "workspace-not-ready": 409;
|
|
19
|
+
readonly "runtime-unreachable": 503;
|
|
20
|
+
readonly "runtime-untargetable": 503;
|
|
21
|
+
readonly "connection-refused": 502;
|
|
22
|
+
readonly "name-unresolved": 502;
|
|
23
|
+
readonly "network-unreachable": 502;
|
|
24
|
+
readonly "dial-timeout": 504;
|
|
25
|
+
readonly "dial-failed": 502;
|
|
26
|
+
readonly "not-found": 404;
|
|
27
|
+
readonly unauthorized: 401;
|
|
28
|
+
readonly forbidden: 403;
|
|
29
|
+
readonly "budget-exceeded": 429;
|
|
30
|
+
readonly "invalid-target": 400;
|
|
31
|
+
readonly "owner-required": 400;
|
|
32
|
+
readonly internal: 500;
|
|
33
|
+
readonly "owner-exited": 409;
|
|
34
|
+
readonly "peer-mismatch": 409;
|
|
35
|
+
readonly "binding-unverifiable": 409;
|
|
36
|
+
readonly "binding-unsupported": 409;
|
|
37
|
+
};
|
|
38
|
+
export declare const forwardBindingSchema: Schema.Struct<{
|
|
39
|
+
readonly kind: Schema.Literal<"port">;
|
|
40
|
+
}>;
|
|
41
|
+
export type ForwardBinding = typeof forwardBindingSchema.Type;
|
|
42
|
+
export declare const forwardReadyFrameSchema: Schema.Struct<{
|
|
43
|
+
readonly t: Schema.Literal<"ready">;
|
|
44
|
+
readonly version: Schema.Literal<2>;
|
|
45
|
+
readonly binding: Schema.Struct<{
|
|
46
|
+
readonly kind: Schema.Literal<"port">;
|
|
47
|
+
}>;
|
|
48
|
+
}>;
|
|
49
|
+
export type ForwardReadyFrame = typeof forwardReadyFrameSchema.Type;
|
|
50
|
+
/**
|
|
51
|
+
* Decoded with any `reason`, so a client keeps a refusal from a Core newer than itself, with the
|
|
52
|
+
* status and message that Core sent.
|
|
53
|
+
*/
|
|
54
|
+
export declare const forwardRefusedFrameSchema: Schema.Struct<{
|
|
55
|
+
readonly t: Schema.Literal<"refused">;
|
|
56
|
+
readonly reason: Schema.String;
|
|
57
|
+
readonly message: Schema.String;
|
|
58
|
+
readonly status: Schema.Int;
|
|
59
|
+
}>;
|
|
60
|
+
export type ForwardRefusedFrame = typeof forwardRefusedFrameSchema.Type;
|
|
61
|
+
export declare const forwardRefusedFrame: (reason: "binding-unsupported" | "binding-unverifiable" | "budget-exceeded" | "connection-refused" | "dial-failed" | "dial-timeout" | "forbidden" | "internal" | "invalid-target" | "name-unresolved" | "network-unreachable" | "not-found" | "owner-exited" | "owner-required" | "peer-mismatch" | "runtime-unreachable" | "runtime-untargetable" | "unauthorized" | "workspace-not-ready", message: string) => {
|
|
62
|
+
readonly t: "refused";
|
|
63
|
+
readonly reason: string;
|
|
64
|
+
readonly message: string;
|
|
65
|
+
readonly status: number;
|
|
66
|
+
};
|
|
67
|
+
/** The first frame the server sends on a v2 forward, as JSON text. */
|
|
68
|
+
export declare const forwardOpenFrameSchema: Schema.Union<readonly [Schema.Struct<{
|
|
69
|
+
readonly t: Schema.Literal<"ready">;
|
|
70
|
+
readonly version: Schema.Literal<2>;
|
|
71
|
+
readonly binding: Schema.Struct<{
|
|
72
|
+
readonly kind: Schema.Literal<"port">;
|
|
73
|
+
}>;
|
|
74
|
+
}>, Schema.Struct<{
|
|
75
|
+
readonly t: Schema.Literal<"refused">;
|
|
76
|
+
readonly reason: Schema.String;
|
|
77
|
+
readonly message: Schema.String;
|
|
78
|
+
readonly status: Schema.Int;
|
|
79
|
+
}>]>;
|
|
80
|
+
export type ForwardOpenFrame = typeof forwardOpenFrameSchema.Type;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace forward's v2 wire contract: `GET /v1/workspaces/:workspaceId/forward/v2` with the
|
|
3
|
+
* subprotocol {@link FORWARD_V2_SUBPROTOCOL}. A WHATWG `WebSocket` cannot read the status of a
|
|
4
|
+
* refused upgrade, so v2 accepts the upgrade first and answers with one text frame: `ready`, after
|
|
5
|
+
* which binary frames carry payload both ways, or `refused`, after which the server closes with
|
|
6
|
+
* {@link FORWARD_REFUSED_CLOSE_CODE}. A request without an upgrade gets 426 and is never dialled.
|
|
7
|
+
*/
|
|
8
|
+
import { Schema } from "effect";
|
|
9
|
+
export const FORWARD_V2_SUBPROTOCOL = "sealant.forward.v2";
|
|
10
|
+
/** The largest binary frame either side may send. */
|
|
11
|
+
export const FORWARD_V2_MAX_FRAME_BYTES = 64 * 1024;
|
|
12
|
+
/** Ends the socket after a `refused` frame. It says nothing about why: the frame's reason does. */
|
|
13
|
+
export const FORWARD_REFUSED_CLOSE_CODE = 4400;
|
|
14
|
+
export const forwardRefusalReasonSchema = Schema.Literals([
|
|
15
|
+
"workspace-not-ready",
|
|
16
|
+
"runtime-unreachable",
|
|
17
|
+
"runtime-untargetable",
|
|
18
|
+
"connection-refused",
|
|
19
|
+
"name-unresolved",
|
|
20
|
+
"network-unreachable",
|
|
21
|
+
"dial-timeout",
|
|
22
|
+
"dial-failed",
|
|
23
|
+
"not-found",
|
|
24
|
+
"unauthorized",
|
|
25
|
+
"forbidden",
|
|
26
|
+
"budget-exceeded",
|
|
27
|
+
"invalid-target",
|
|
28
|
+
"owner-required",
|
|
29
|
+
"internal",
|
|
30
|
+
"owner-exited",
|
|
31
|
+
"peer-mismatch",
|
|
32
|
+
"binding-unverifiable",
|
|
33
|
+
"binding-unsupported",
|
|
34
|
+
]);
|
|
35
|
+
/** The HTTP status each refusal would have had before the upgrade. Callers branch on the reason. */
|
|
36
|
+
export const FORWARD_REFUSAL_STATUS = {
|
|
37
|
+
"workspace-not-ready": 409,
|
|
38
|
+
"runtime-unreachable": 503,
|
|
39
|
+
"runtime-untargetable": 503,
|
|
40
|
+
"connection-refused": 502,
|
|
41
|
+
"name-unresolved": 502,
|
|
42
|
+
"network-unreachable": 502,
|
|
43
|
+
"dial-timeout": 504,
|
|
44
|
+
"dial-failed": 502,
|
|
45
|
+
"not-found": 404,
|
|
46
|
+
unauthorized: 401,
|
|
47
|
+
forbidden: 403,
|
|
48
|
+
"budget-exceeded": 429,
|
|
49
|
+
"invalid-target": 400,
|
|
50
|
+
"owner-required": 400,
|
|
51
|
+
internal: 500,
|
|
52
|
+
"owner-exited": 409,
|
|
53
|
+
"peer-mismatch": 409,
|
|
54
|
+
"binding-unverifiable": 409,
|
|
55
|
+
"binding-unsupported": 409,
|
|
56
|
+
};
|
|
57
|
+
export const forwardBindingSchema = Schema.Struct({ kind: Schema.Literal("port") });
|
|
58
|
+
export const forwardReadyFrameSchema = Schema.Struct({
|
|
59
|
+
t: Schema.Literal("ready"),
|
|
60
|
+
version: Schema.Literal(2),
|
|
61
|
+
binding: forwardBindingSchema,
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Decoded with any `reason`, so a client keeps a refusal from a Core newer than itself, with the
|
|
65
|
+
* status and message that Core sent.
|
|
66
|
+
*/
|
|
67
|
+
export const forwardRefusedFrameSchema = Schema.Struct({
|
|
68
|
+
t: Schema.Literal("refused"),
|
|
69
|
+
reason: Schema.String,
|
|
70
|
+
message: Schema.String,
|
|
71
|
+
status: Schema.Int,
|
|
72
|
+
});
|
|
73
|
+
export const forwardRefusedFrame = (reason, message) => ({
|
|
74
|
+
t: "refused",
|
|
75
|
+
reason,
|
|
76
|
+
message,
|
|
77
|
+
status: FORWARD_REFUSAL_STATUS[reason],
|
|
78
|
+
});
|
|
79
|
+
/** The first frame the server sends on a v2 forward, as JSON text. */
|
|
80
|
+
export const forwardOpenFrameSchema = Schema.Union([
|
|
81
|
+
forwardReadyFrameSchema,
|
|
82
|
+
forwardRefusedFrameSchema,
|
|
83
|
+
]);
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./core-api/request-refusal.js";
|
|
|
13
13
|
export * from "./core-api/sessions.js";
|
|
14
14
|
export * from "./core-api/access-tokens.js";
|
|
15
15
|
export * from "./core-api/workspaces.js";
|
|
16
|
+
export * from "./core-api/workspace-forward.js";
|
|
16
17
|
export * from "./core-api/ssh-keys.js";
|
|
17
18
|
export * from "./core-api/system.js";
|
|
18
19
|
export * from "./core-api/users.js";
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./core-api/request-refusal.js";
|
|
|
13
13
|
export * from "./core-api/sessions.js";
|
|
14
14
|
export * from "./core-api/access-tokens.js";
|
|
15
15
|
export * from "./core-api/workspaces.js";
|
|
16
|
+
export * from "./core-api/workspace-forward.js";
|
|
16
17
|
export * from "./core-api/ssh-keys.js";
|
|
17
18
|
export * from "./core-api/system.js";
|
|
18
19
|
export * from "./core-api/users.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealant/api-contracts-next",
|
|
3
|
-
"version": "0.40.0-next.
|
|
3
|
+
"version": "0.40.0-next.758",
|
|
4
4
|
"description": "Contract-first HTTP API definitions for Sealant services",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"effect": "^4.0.5"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "cad5836dece75c30a8aa91978d233cd1c1f7064d",
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
}
|