@solarisdk/core 0.2.1 → 0.3.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/errors.d.ts +14 -4
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +30 -8
- package/dist/errors.js.map +1 -1
- package/package.json +1 -1
package/dist/errors.d.ts
CHANGED
|
@@ -14,15 +14,25 @@ export declare class GatewayError extends SolariError {
|
|
|
14
14
|
export declare class AuthError extends GatewayError {
|
|
15
15
|
constructor(message?: string, body?: GatewayErrorBody);
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* The plan doesn't allow this: `402` (`FeatureRequiresPlan`, `InsufficientCredit`) or `403 {code:"NotEntitled"}` (the plan
|
|
19
|
+
* does not include sandboxes/desktops). `status` is the status the gateway really sent.
|
|
20
|
+
*/
|
|
18
21
|
export declare class PlanError extends GatewayError {
|
|
19
|
-
constructor(message?: string, body?: GatewayErrorBody);
|
|
22
|
+
constructor(message?: string, body?: GatewayErrorBody, status?: number);
|
|
20
23
|
}
|
|
21
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* `429 {code:"ConcurrencyLimitExceeded"}` — the org is at its cap of live sessions. Other 429s (for example
|
|
26
|
+
* `TooManyExecutions`, a per-sandbox limit that can be retried) are plain {@link GatewayError}s with the gateway's `code`.
|
|
27
|
+
*/
|
|
22
28
|
export declare class ConcurrencyLimitError extends GatewayError {
|
|
23
29
|
constructor(message?: string, body?: GatewayErrorBody);
|
|
24
30
|
}
|
|
25
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* `503 {code:"NoCapacity"|"StartTimeout"}` (or a `503` with no code) — no desktop host currently available to serve the
|
|
33
|
+
* request. Other 503s (`SandboxUnavailable`, `StoreUnavailable`, `AdmissionUnavailable`, `DependencyUnavailable`) are plain
|
|
34
|
+
* {@link GatewayError}s: the sandbox, store or admission service is unavailable, which is not a capacity problem.
|
|
35
|
+
*/
|
|
26
36
|
export declare class NoCapacityError extends GatewayError {
|
|
27
37
|
constructor(message?: string, body?: GatewayErrorBody);
|
|
28
38
|
}
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,oDAAoD;AACpD,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B;AAED,8EAA8E;AAC9E,qBAAa,YAAa,SAAQ,WAAW;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;gBAErB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB;CAMrE;AAED,+DAA+D;AAC/D,qBAAa,SAAU,SAAQ,YAAY;gBAC7B,OAAO,SAA+B,EAAE,IAAI,CAAC,EAAE,gBAAgB;CAG5E;AAED
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,oDAAoD;AACpD,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B;AAED,8EAA8E;AAC9E,qBAAa,YAAa,SAAQ,WAAW;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;gBAErB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB;CA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gCd"}
|
package/dist/errors.js
CHANGED
|
@@ -25,19 +25,29 @@ export class AuthError extends GatewayError {
|
|
|
25
25
|
super(401, message, body);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* The plan doesn't allow this: `402` (`FeatureRequiresPlan`, `InsufficientCredit`) or `403 {code:"NotEntitled"}` (the plan
|
|
30
|
+
* does not include sandboxes/desktops). `status` is the status the gateway really sent.
|
|
31
|
+
*/
|
|
29
32
|
export class PlanError extends GatewayError {
|
|
30
|
-
constructor(message = "This feature requires a different plan", body) {
|
|
31
|
-
super(
|
|
33
|
+
constructor(message = "This feature requires a different plan", body, status = 402) {
|
|
34
|
+
super(status, message, body);
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* `429 {code:"ConcurrencyLimitExceeded"}` — the org is at its cap of live sessions. Other 429s (for example
|
|
39
|
+
* `TooManyExecutions`, a per-sandbox limit that can be retried) are plain {@link GatewayError}s with the gateway's `code`.
|
|
40
|
+
*/
|
|
35
41
|
export class ConcurrencyLimitError extends GatewayError {
|
|
36
42
|
constructor(message = "Concurrency limit exceeded", body) {
|
|
37
43
|
super(429, message, body);
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* `503 {code:"NoCapacity"|"StartTimeout"}` (or a `503` with no code) — no desktop host currently available to serve the
|
|
48
|
+
* request. Other 503s (`SandboxUnavailable`, `StoreUnavailable`, `AdmissionUnavailable`, `DependencyUnavailable`) are plain
|
|
49
|
+
* {@link GatewayError}s: the sandbox, store or admission service is unavailable, which is not a capacity problem.
|
|
50
|
+
*/
|
|
41
51
|
export class NoCapacityError extends GatewayError {
|
|
42
52
|
constructor(message = "No desktop host available", body) {
|
|
43
53
|
super(503, message, body);
|
|
@@ -92,20 +102,32 @@ export class ConnectionError extends SolariError {
|
|
|
92
102
|
*/
|
|
93
103
|
export function mapGatewayError(status, body) {
|
|
94
104
|
const msg = body?.message ?? body?.error ?? body?.code;
|
|
105
|
+
// `code` is the discriminator (sdk/PROTOCOL.md section 4); the status alone is not enough because one status carries
|
|
106
|
+
// several meanings. A response with no code keeps the type its status has always had.
|
|
107
|
+
const code = body?.code;
|
|
95
108
|
switch (status) {
|
|
96
109
|
case 401:
|
|
97
110
|
return new AuthError(msg, body);
|
|
98
111
|
case 402:
|
|
99
112
|
return new PlanError(msg, body);
|
|
113
|
+
case 403:
|
|
114
|
+
// The gateway's only JSON 403 is NotEntitled (the plan does not include sandboxes/desktops).
|
|
115
|
+
if (code === "NotEntitled")
|
|
116
|
+
return new PlanError(msg, body, 403);
|
|
117
|
+
return new GatewayError(403, msg ?? "Forbidden", body);
|
|
100
118
|
case 429:
|
|
101
|
-
|
|
119
|
+
if (code === undefined || code === "ConcurrencyLimitExceeded")
|
|
120
|
+
return new ConcurrencyLimitError(msg, body);
|
|
121
|
+
return new GatewayError(429, msg ?? "Too many requests", body);
|
|
102
122
|
case 409:
|
|
103
|
-
if (
|
|
123
|
+
if (code === "NotStopped" || code === "StartInProgress") {
|
|
104
124
|
return new SandboxNotStoppedError(msg, body);
|
|
105
125
|
}
|
|
106
126
|
return new GatewayError(409, msg ?? "Conflict", body);
|
|
107
127
|
case 503:
|
|
108
|
-
|
|
128
|
+
if (code === undefined || code === "NoCapacity" || code === "StartTimeout")
|
|
129
|
+
return new NoCapacityError(msg, body);
|
|
130
|
+
return new GatewayError(503, msg ?? "Service unavailable", body);
|
|
109
131
|
default:
|
|
110
132
|
return new GatewayError(status, msg ?? `Gateway request failed with status ${status}`, body);
|
|
111
133
|
}
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,6EAA6E;AAI7E,oDAAoD;AACpD,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YA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AqB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC3G,OAAO,IAAI,YAAY,CAAC,GAAG,EAAE,GAAG,IAAI,mBAAmB,EAAE,IAAI,CAAC,CAAC;QACjE,KAAK,GAAG;YACN,IAAI,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,iBAAiB,EAAE,CAAC;gBACxD,OAAO,IAAI,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC/C,CAAC;YACD,OAAO,IAAI,YAAY,CAAC,GAAG,EAAE,GAAG,IAAI,UAAU,EAAE,IAAI,CAAC,CAAC;QACxD,KAAK,GAAG;YACN,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,cAAc;gBAAE,OAAO,IAAI,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAClH,OAAO,IAAI,YAAY,CAAC,GAAG,EAAE,GAAG,IAAI,qBAAqB,EAAE,IAAI,CAAC,CAAC;QACnE;YACE,OAAO,IAAI,YAAY,CACrB,MAAM,EACN,GAAG,IAAI,sCAAsC,MAAM,EAAE,EACrD,IAAI,CACL,CAAC;IACN,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solarisdk/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Shared runtime for the Solari SDK \u2014 transport, session handles, images, templates, and types used by @solarisdk/desktop and @solarisdk/sandbox.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|