arcadible 1.0.44 → 1.0.46
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/account.js +29 -21
- package/dist/action/delete/tool.js +2 -2
- package/dist/action/deploy/tool.js +2 -2
- package/dist/action/deploy/wait.js +12 -2
- package/dist/action/function/logs.js +12 -8
- package/dist/action/function/tool.js +3 -3
- package/dist/action/game.js +18 -16
- package/dist/action/key/tool.js +4 -4
- package/dist/action/play/tool.js +5 -5
- package/dist/action/predeploy/ac.js +5 -3
- package/dist/action/predeploy/tool-git.js +5 -4
- package/dist/action/secret/tool.js +6 -6
- package/dist/action/value/tool.js +4 -4
- package/dist/api.js +1 -0
- package/dist/command/deploy/report.js +2 -0
- package/dist/phrase/function.js +4 -0
- package/dist/runner/entry.js +6 -19
- package/dist/util/output.js +13 -9
- package/dist/util/request.js +4 -3
- package/dist/wires/room.js +0 -1
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
package/dist/account.js
CHANGED
|
@@ -15,8 +15,11 @@ const DIR_MODE = 0o700;
|
|
|
15
15
|
const FILE = "account.json";
|
|
16
16
|
const FILE_MODE = 0o600;
|
|
17
17
|
// [declare]
|
|
18
|
-
// the
|
|
19
|
-
|
|
18
|
+
// the API's codes for a session's token it refused: one whose time ran out,
|
|
19
|
+
// which a refresh mends, and one that's no account's (a deleted account's),
|
|
20
|
+
// which ends the session, as a refresh token Supabase doesn't take does.
|
|
21
|
+
const EXPIRED = "expired";
|
|
22
|
+
const UNAUTHORIZED = "unauthorized";
|
|
20
23
|
// [declare]
|
|
21
24
|
const TOKEN_USER = { display_name: `${title} Token`, id: null };
|
|
22
25
|
// [define]
|
|
@@ -74,7 +77,7 @@ function refresh({ session, ...current }) {
|
|
|
74
77
|
const form = new FormData();
|
|
75
78
|
form.append("refresh_token", String(session.refresh_token));
|
|
76
79
|
return postAuthRefresh(form).then((data) => save({ ...current, session: data }), (ex) => {
|
|
77
|
-
if (ex instanceof HttpError &&
|
|
80
|
+
if (ex instanceof HttpError && ex.code === UNAUTHORIZED) {
|
|
78
81
|
return expire(ex);
|
|
79
82
|
}
|
|
80
83
|
throw ex;
|
|
@@ -134,19 +137,23 @@ export function get(onRefresh) {
|
|
|
134
137
|
}
|
|
135
138
|
// [function]
|
|
136
139
|
// a failed request's handler for commands that send the saved session's
|
|
137
|
-
// token
|
|
138
|
-
// account,
|
|
139
|
-
//
|
|
140
|
-
//
|
|
141
|
-
// session is
|
|
142
|
-
//
|
|
143
|
-
// logging in doesn't change
|
|
140
|
+
// token, by the API's code: `unauthorized`, a token that's no account's (a
|
|
141
|
+
// deleted account's), ends the session, so it's removed and the error says
|
|
142
|
+
// to log in (session_expired); `expired`, a token that ran out by the
|
|
143
|
+
// server's clock though not by this one's, is refreshed: refused, the
|
|
144
|
+
// session is over, as above; renewed, the session is kept, and the
|
|
145
|
+
// request's own error stands, so running the command again works. An
|
|
146
|
+
// ARCADIBLE_TOKEN's refusal stays as it is, since logging in doesn't change
|
|
147
|
+
// the token.
|
|
144
148
|
export function ended(current) {
|
|
145
149
|
return (ex) => {
|
|
146
|
-
if (!current?.session ||
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
if (!current?.session || current.token || !(ex instanceof HttpError)) {
|
|
151
|
+
throw ex;
|
|
152
|
+
}
|
|
153
|
+
if (ex.code === UNAUTHORIZED) {
|
|
154
|
+
return expire(ex);
|
|
155
|
+
}
|
|
156
|
+
if (ex.code !== EXPIRED) {
|
|
150
157
|
throw ex;
|
|
151
158
|
}
|
|
152
159
|
return refresh(current).then(() => {
|
|
@@ -172,12 +179,13 @@ async function renew(current) {
|
|
|
172
179
|
return refresh(base);
|
|
173
180
|
}
|
|
174
181
|
// [function]
|
|
175
|
-
// sends `call` with the account's access token, and when the API
|
|
176
|
-
// (
|
|
177
|
-
// token can expire during a long command (a deploy's build,
|
|
178
|
-
// wait), where `get` renews it only at the start. Renewed,
|
|
179
|
-
// the new session, so the calls after it send that. An
|
|
180
|
-
// refusal stands, as does a second
|
|
182
|
+
// sends `call` with the account's access token, and when the API says it
|
|
183
|
+
// ran out (`expired`) for the saved session, renews the session and sends it
|
|
184
|
+
// once more. A token can expire during a long command (a deploy's build,
|
|
185
|
+
// upload, and wait), where `get` renews it only at the start. Renewed,
|
|
186
|
+
// `current` holds the new session, so the calls after it send that. An
|
|
187
|
+
// ARCADIBLE_TOKEN's refusal stands, as does any other, and a second, which
|
|
188
|
+
// `ended` then reads.
|
|
181
189
|
export async function authed(current, call) {
|
|
182
190
|
try {
|
|
183
191
|
return await call(auth(current?.session.access_token));
|
|
@@ -186,7 +194,7 @@ export async function authed(current, call) {
|
|
|
186
194
|
if (!current?.session ||
|
|
187
195
|
current.token ||
|
|
188
196
|
!(ex instanceof HttpError) ||
|
|
189
|
-
ex.
|
|
197
|
+
ex.code !== EXPIRED) {
|
|
190
198
|
throw ex;
|
|
191
199
|
}
|
|
192
200
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { deleteGame } from "../../api.js";
|
|
5
5
|
import { GAME_ID_MISSING, GAME_NOT_FOUND } from "../../config/code.js";
|
|
6
6
|
import { ArcError } from "../../util/error.js";
|
|
7
|
-
import { headersOf,
|
|
7
|
+
import { headersOf, isRefused, REFUSED } from "../game.js";
|
|
8
8
|
import { given } from "../../parser/given.js";
|
|
9
9
|
import { gameIdMissing, gameNotOwned } from "../../phrase/index.js";
|
|
10
10
|
import { textOf } from "../../util/objs.js";
|
|
@@ -37,7 +37,7 @@ export async function deleteTool(current, { id }) {
|
|
|
37
37
|
return { game: id };
|
|
38
38
|
}
|
|
39
39
|
catch (err) {
|
|
40
|
-
if (
|
|
40
|
+
if (isRefused(err, REFUSED.NOT_FOUND)) {
|
|
41
41
|
throw new ArcError(GAME_NOT_FOUND, gameNotOwned(id), {
|
|
42
42
|
cause: err,
|
|
43
43
|
});
|
|
@@ -22,12 +22,12 @@ function uploadBuild(current, artifact, { id, version }, onProgress) {
|
|
|
22
22
|
// the API refuses a game that was deleted or is another account's
|
|
23
23
|
// (404), and the same version deployed again within 5 minutes (429),
|
|
24
24
|
// each by its code.
|
|
25
|
-
if (isRefused(err, GAME_NOT_FOUND
|
|
25
|
+
if (isRefused(err, GAME_NOT_FOUND)) {
|
|
26
26
|
throw new ArcError(GAME_NOT_FOUND, gameDeletedOrNotOwned(id), {
|
|
27
27
|
cause: err,
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
if (isRefused(err, DEPLOY_RATE_LIMITED
|
|
30
|
+
if (isRefused(err, DEPLOY_RATE_LIMITED)) {
|
|
31
31
|
throw new ArcError(DEPLOY_RATE_LIMITED, deployRateLimited(version), {
|
|
32
32
|
cause: err,
|
|
33
33
|
});
|
|
@@ -4,21 +4,31 @@ import { discoverGameReleases, release as apiRelease, } from "../../api.js";
|
|
|
4
4
|
import { sleep } from "../../util/delay.js";
|
|
5
5
|
import { git } from "../predeploy/git.js";
|
|
6
6
|
import { HttpError } from "../../util/http.js";
|
|
7
|
+
import { isRetry } from "../../config/retry.js";
|
|
7
8
|
import { studioUrl } from "../../util/links.js";
|
|
8
9
|
import { m, s } from "../../util/time.js";
|
|
9
10
|
// [declare]
|
|
10
11
|
// how often a release is checked.
|
|
11
12
|
const INTERVAL = s(2);
|
|
12
13
|
const FINAL = new Set(["failed", "published"]);
|
|
14
|
+
// `reason` brings its `retry` with it: the API answers one beside each
|
|
15
|
+
// (its app/release.py).
|
|
13
16
|
const SELECT = "id,game,status,reason,message,build,source,version,channel,created_at";
|
|
14
17
|
// a git release is found by version among the newest few; one from before
|
|
15
18
|
// this deploy (a tag deleted and pushed again) is left out, allowing for
|
|
16
19
|
// the machine's clock being off.
|
|
17
20
|
const SKEW = m(10);
|
|
18
21
|
// [function]
|
|
19
|
-
// a failure worth
|
|
22
|
+
// a failure worth waiting through: the network, or a refusal Arcadible says
|
|
23
|
+
// to try again after a moment, by its retry (`yes`: `unavailable`,
|
|
24
|
+
// `internal`, `busy`), whatever its status; an answer that says none isn't
|
|
25
|
+
// Arcadible's own (a front end's page), and is waited through for a 5xx
|
|
26
|
+
// (ERRORS.md, Passing a code on). Anything else ends the wait.
|
|
20
27
|
function transient(err) {
|
|
21
|
-
|
|
28
|
+
if (!(err instanceof HttpError)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return isRetry(err.retry) ? err.retry === "yes" : err.status >= 500;
|
|
22
32
|
}
|
|
23
33
|
// [function]
|
|
24
34
|
// the repository's GitHub Actions page, from origin's URL, or null when
|
|
@@ -9,9 +9,10 @@ import { postGameFunctionLogsToken } from "../../api.js";
|
|
|
9
9
|
import { API_UNREACHABLE, ARGUMENT_INVALID, FUNCTION_LOGS_FOLLOWS_FULL, GAME_NOT_FOUND, UNAVAILABLE, UNEXPECTED, } from "../../config/code.js";
|
|
10
10
|
import { ArcError, codeOf } from "../../util/error.js";
|
|
11
11
|
import { HttpError } from "../../util/http.js";
|
|
12
|
+
import { isRetry } from "../../config/retry.js";
|
|
12
13
|
import { sleep } from "../../util/delay.js";
|
|
13
14
|
import { isTable } from "../../util/objs.js";
|
|
14
|
-
import { channelOf, gameOf, headersOf,
|
|
15
|
+
import { channelOf, gameOf, headersOf, isRefused, REFUSED } from "../game.js";
|
|
15
16
|
import { answerUnread, functionLogsFull, functionLogsRefused, functionLogsSinceInvalid, functionLogsVersionInvalid, gameNotOwned, unableToReach, } from "../../phrase/index.js";
|
|
16
17
|
// [declare]
|
|
17
18
|
// the protocol a follow speaks, offered with the token beside it, and the
|
|
@@ -136,7 +137,7 @@ async function tokenOf(id, headers) {
|
|
|
136
137
|
return await postGameFunctionLogsToken(id, null, headers);
|
|
137
138
|
}
|
|
138
139
|
catch (err) {
|
|
139
|
-
if (
|
|
140
|
+
if (isRefused(err, REFUSED.NOT_FOUND)) {
|
|
140
141
|
throw new ArcError(GAME_NOT_FOUND, gameNotOwned(id), { cause: err });
|
|
141
142
|
}
|
|
142
143
|
throw err;
|
|
@@ -165,7 +166,7 @@ async function pageOf(token, query, last) {
|
|
|
165
166
|
}, () => null);
|
|
166
167
|
if (!res.ok) {
|
|
167
168
|
const told = toldIn(body);
|
|
168
|
-
if (
|
|
169
|
+
if (told.code === "expired") {
|
|
169
170
|
if (last)
|
|
170
171
|
throw tokenRefused(told);
|
|
171
172
|
return null;
|
|
@@ -285,17 +286,20 @@ export async function follow(current, { channel, ...conf }, shown) {
|
|
|
285
286
|
query.delete("since");
|
|
286
287
|
for (let failed = 0;;) {
|
|
287
288
|
const closed = await followOnce(await tokenOf(id, headers), query, once);
|
|
288
|
-
const { code, status } = closed;
|
|
289
|
-
// read by the Worker's code
|
|
290
|
-
//
|
|
289
|
+
const { code, retry, status } = closed;
|
|
290
|
+
// read by the Worker's code and its retry, as a page is (`pageOf`) and
|
|
291
|
+
// as Studio's follow is (ui's `isFinal`): a sixth follow has its own
|
|
292
|
+
// code, and any other refusal ends the follow only when its retry is
|
|
293
|
+
// No. One that says no retry isn't the Worker's own (a front end's): it
|
|
294
|
+
// ends the follow for a 4xx, and is tried again for a 5xx
|
|
291
295
|
if (code === "full") {
|
|
292
296
|
throw new ArcError(FUNCTION_LOGS_FOLLOWS_FULL, functionLogsFull(), {
|
|
293
297
|
cause: httpErrorOf(status ?? 507, closed),
|
|
294
298
|
status: status ?? 507,
|
|
295
299
|
});
|
|
296
300
|
}
|
|
297
|
-
const expired =
|
|
298
|
-
if (status && status < 500
|
|
301
|
+
const expired = code === "expired";
|
|
302
|
+
if (status && (isRetry(retry) ? retry === "no" : status < 500)) {
|
|
299
303
|
throw refused(status, closed);
|
|
300
304
|
}
|
|
301
305
|
failed = closed.opened ? 0 : failed + 1;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { deleteGameFunctionPause, discoverGameBuilds, gameFunctionPauses, gameFunctionUsages, putGameFunctionPause, } from "../../api.js";
|
|
6
6
|
import { FUNCTION_PAUSE_NOT_OWNED, GAME_NOT_FOUND } from "../../config/code.js";
|
|
7
7
|
import { ArcError } from "../../util/error.js";
|
|
8
|
-
import { channelOf, CHANNELS, gameOf, headersOf,
|
|
8
|
+
import { channelOf, CHANNELS, gameOf, headersOf, isRefused, REFUSED, needOf, ownedOf, } from "../game.js";
|
|
9
9
|
import { functionPauseNotOwned, gameNotOwned } from "../../phrase/index.js";
|
|
10
10
|
// [declare]
|
|
11
11
|
// the reasons a function is paused for, the one that holds longest first:
|
|
@@ -61,7 +61,7 @@ export async function pause(current, { channel, ...conf }) {
|
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
catch (err) {
|
|
64
|
-
if (
|
|
64
|
+
if (isRefused(err, REFUSED.NOT_FOUND)) {
|
|
65
65
|
throw new ArcError(GAME_NOT_FOUND, gameNotOwned(id), {
|
|
66
66
|
cause: err,
|
|
67
67
|
});
|
|
@@ -85,7 +85,7 @@ export async function resume(current, { channel, ...conf }) {
|
|
|
85
85
|
await deleteGameFunctionPause(id, where, null, headers);
|
|
86
86
|
}
|
|
87
87
|
catch (err) {
|
|
88
|
-
if (!
|
|
88
|
+
if (!isRefused(err, REFUSED.NOT_FOUND)) {
|
|
89
89
|
throw err;
|
|
90
90
|
}
|
|
91
91
|
lifted = false;
|
package/dist/action/game.js
CHANGED
|
@@ -67,21 +67,23 @@ export async function ownedOf(id, headers) {
|
|
|
67
67
|
throw new ArcError(GAME_NOT_FOUND, gameNotOwned(id));
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
+
// [declare]
|
|
71
|
+
// the API's own words for a refusal the CLI reads (ERRORS.md, The
|
|
72
|
+
// vocabulary), each said by a command in one of its own codes.
|
|
73
|
+
export const REFUSED = {
|
|
74
|
+
FULL: "full",
|
|
75
|
+
INVALID: "invalid",
|
|
76
|
+
NOT_FOUND: "not_found",
|
|
77
|
+
TOO_LARGE: "too_large",
|
|
78
|
+
};
|
|
70
79
|
// [function]
|
|
71
|
-
// whether a failure is the API's refusal with this
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// upload is never `deploy_rate_limited`.
|
|
81
|
-
export function isRefused(err, code, status) {
|
|
82
|
-
if (!(err instanceof HttpError))
|
|
83
|
-
return false;
|
|
84
|
-
if (err.code !== undefined)
|
|
85
|
-
return err.code === code;
|
|
86
|
-
return err.status === status;
|
|
80
|
+
// whether a failure is the API's refusal with this code: its own
|
|
81
|
+
// (`game_not_found`) or its class's word (`not_found`). An answer with no
|
|
82
|
+
// code at all (a proxy's page, which names nothing) is none of them: it goes
|
|
83
|
+
// on to the catch-all (`codeOf`), `unavailable` for a 5xx and `api_refused`
|
|
84
|
+
// otherwise, never guessed from its status. Another code with the same
|
|
85
|
+
// status is another refusal: a 429 `busy` on an upload is never
|
|
86
|
+
// `deploy_rate_limited`.
|
|
87
|
+
export function isRefused(err, code) {
|
|
88
|
+
return err instanceof HttpError && err.code === code;
|
|
87
89
|
}
|
package/dist/action/key/tool.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { deleteKey, gameKeys, postGameKey, } from "../../api.js";
|
|
5
5
|
import { ARGUMENT_INVALID, GAME_NOT_FOUND, KEY_QUOTA_FULL, KEY_NOT_FOUND, } from "../../config/code.js";
|
|
6
6
|
import { ArcError } from "../../util/error.js";
|
|
7
|
-
import { channelOf, gameOf, headersOf, isRefused,
|
|
7
|
+
import { channelOf, gameOf, headersOf, isRefused, REFUSED, needOf, ownedOf, } from "../game.js";
|
|
8
8
|
import { gameNotOwned, keyQuotaFull, keyNameInvalid, keyNotFound, } from "../../phrase/index.js";
|
|
9
9
|
// [declare]
|
|
10
10
|
const NAME_MAX = 64;
|
|
@@ -35,12 +35,12 @@ export async function create(current, { channel, name, ...conf }) {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
catch (err) {
|
|
38
|
-
if (
|
|
38
|
+
if (isRefused(err, REFUSED.NOT_FOUND)) {
|
|
39
39
|
throw new ArcError(GAME_NOT_FOUND, gameNotOwned(id), {
|
|
40
40
|
cause: err,
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
if (isRefused(err, KEY_QUOTA_FULL
|
|
43
|
+
if (isRefused(err, KEY_QUOTA_FULL)) {
|
|
44
44
|
throw new ArcError(KEY_QUOTA_FULL, keyQuotaFull(where), {
|
|
45
45
|
cause: err,
|
|
46
46
|
});
|
|
@@ -87,7 +87,7 @@ export async function revoke(current, { id, ...conf }) {
|
|
|
87
87
|
return { id: gone.id };
|
|
88
88
|
}
|
|
89
89
|
catch (err) {
|
|
90
|
-
if (
|
|
90
|
+
if (isRefused(err, REFUSED.NOT_FOUND) || isRefused(err, REFUSED.INVALID)) {
|
|
91
91
|
throw new ArcError(KEY_NOT_FOUND, keyNotFound(id), {
|
|
92
92
|
cause: err,
|
|
93
93
|
});
|
package/dist/action/play/tool.js
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
import { discoverGame, discoverGameBuilds } from "../../api.js";
|
|
3
3
|
import { GAME_NOT_FOUND } from "../../config/code.js";
|
|
4
4
|
import { ArcError } from "../../util/error.js";
|
|
5
|
-
import { HttpError } from "../../util/http.js";
|
|
6
5
|
import { gameNotFound } from "../../phrase/index.js";
|
|
7
6
|
import { playUrl, PRODUCTION, STAGING } from "../../util/links.js";
|
|
8
7
|
import { textOf } from "../../util/objs.js";
|
|
9
8
|
import { self } from "../../parser/self.js";
|
|
9
|
+
import { isRefused, REFUSED } from "../game.js";
|
|
10
10
|
// [function]
|
|
11
|
-
// the game, `select`ed, or null when the API can't be reached
|
|
12
|
-
//
|
|
13
|
-
// doesn't exist has none.
|
|
11
|
+
// the game, `select`ed, or null when the API can't be reached, or answers
|
|
12
|
+
// with no code (a proxy's page). It rejects when the game isn't on
|
|
13
|
+
// Arcadible: its builds can't say, since a game that doesn't exist has none.
|
|
14
14
|
function findGame(id, select) {
|
|
15
15
|
return discoverGame(id, { select }).catch((err) => {
|
|
16
|
-
if (err
|
|
16
|
+
if (isRefused(err, REFUSED.NOT_FOUND)) {
|
|
17
17
|
throw new ArcError(GAME_NOT_FOUND, gameNotFound(id));
|
|
18
18
|
}
|
|
19
19
|
return null;
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
import { auth, discoverGame, gameBuild, gameHandle } from "../../api.js";
|
|
3
3
|
import { GAME_HANDLE_TAKEN, GAME_NOT_FOUND, WARNING, } from "../../config/code.js";
|
|
4
4
|
import { ArcError } from "../../util/error.js";
|
|
5
|
-
import {
|
|
5
|
+
import { isRefused, REFUSED } from "../game.js";
|
|
6
6
|
import { gameHandleLapsed, gameHandleLimit, gameHandleTaken, gameDeletedOrNotOwned, } from "../../phrase/index.js";
|
|
7
7
|
import { channel } from "../../util/links.js";
|
|
8
8
|
import { refuse } from "./published.js";
|
|
9
9
|
// [function]
|
|
10
|
-
// a lookup's failure, passed over when
|
|
10
|
+
// a lookup's failure, passed over when the API says there's nothing there
|
|
11
|
+
// (`not_found`, by its code): nothing to refuse. An answer that names no
|
|
12
|
+
// code isn't the API's, and stands as the failure it is.
|
|
11
13
|
function ignoreMissing(err) {
|
|
12
|
-
if (!(err
|
|
14
|
+
if (!isRefused(err, REFUSED.NOT_FOUND)) {
|
|
13
15
|
throw err;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
@@ -4,16 +4,17 @@ import { GAME_HANDLE_CHANGED, GAME_NOT_DEPLOYED, REPO_NOT_CONNECTED, WARNING, }
|
|
|
4
4
|
import { ArcError } from "../../util/error.js";
|
|
5
5
|
import { releasing } from "./game.js";
|
|
6
6
|
import { ensureClean, ensureRemote, ensureRepo, ensureRoot, ensureTagFree, ensureWorkflow, originRepo, } from "./git.js";
|
|
7
|
-
import { HttpError } from "../../util/http.js";
|
|
8
7
|
import { gameHandleChanged, gameNotDeployed, repoNotConnected, versionUnchecked, } from "../../phrase/index.js";
|
|
9
8
|
import { studioUrl } from "../../util/links.js";
|
|
9
|
+
import { isRefused, REFUSED } from "../game.js";
|
|
10
10
|
import { ensureLockFile } from "./pm.js";
|
|
11
11
|
import { refuse } from "./published.js";
|
|
12
12
|
// [function]
|
|
13
|
-
// a public lookup's answer: found (200, with its data), missing (
|
|
14
|
-
// null for any other answer, such as when the API can't be
|
|
13
|
+
// a public lookup's answer: found (200, with its data), missing (the API's
|
|
14
|
+
// `not_found`), or null for any other answer, such as when the API can't be
|
|
15
|
+
// reached, or a proxy's page with no code.
|
|
15
16
|
function answerOf(request) {
|
|
16
|
-
return request.then((data) => ({ data, status: 200 }), (err) => err
|
|
17
|
+
return request.then((data) => ({ data, status: 200 }), (err) => isRefused(err, REFUSED.NOT_FOUND) ? { status: 404 } : null);
|
|
17
18
|
}
|
|
18
19
|
// [function]
|
|
19
20
|
// what Arcadible would refuse in the release, refused before the tag is pushed: a
|
|
@@ -6,8 +6,8 @@ import { deleteGameFunctionSecret, gameFunctionSecrets, putGameFunctionSecret, }
|
|
|
6
6
|
import { ARGUMENT_INVALID, GAME_NOT_FOUND, SECRET_QUOTA_FULL, SECRET_NOT_FOUND, SECRET_TOO_LARGE, } from "../../config/code.js";
|
|
7
7
|
import { SECRET_NAME } from "../../config/limit.js";
|
|
8
8
|
import { ArcError } from "../../util/error.js";
|
|
9
|
-
import { channelOf, gameOf, headersOf, isRefused,
|
|
10
|
-
import { gameNotOwned, secretQuotaFull, secretNameInvalid, secretNotFound, secretValueInvalid, } from "../../phrase/index.js";
|
|
9
|
+
import { channelOf, gameOf, headersOf, isRefused, REFUSED, needOf, ownedOf, } from "../game.js";
|
|
10
|
+
import { gameNotOwned, secretQuotaFull, secretNameInvalid, secretNotFound, secretTooLarge, secretValueInvalid, } from "../../phrase/index.js";
|
|
11
11
|
// [declare]
|
|
12
12
|
const VALUE_MAX = 4096;
|
|
13
13
|
// [function]
|
|
@@ -31,7 +31,7 @@ export async function set(current, { channel, name, value, ...conf }) {
|
|
|
31
31
|
throw new ArcError(ARGUMENT_INVALID, secretValueInvalid());
|
|
32
32
|
}
|
|
33
33
|
if (Buffer.byteLength(secret) > VALUE_MAX) {
|
|
34
|
-
throw new ArcError(SECRET_TOO_LARGE,
|
|
34
|
+
throw new ArcError(SECRET_TOO_LARGE, secretTooLarge());
|
|
35
35
|
}
|
|
36
36
|
const form = new FormData();
|
|
37
37
|
form.append("value", secret);
|
|
@@ -40,12 +40,12 @@ export async function set(current, { channel, name, value, ...conf }) {
|
|
|
40
40
|
return { channel: kept.channel, name: kept.name };
|
|
41
41
|
}
|
|
42
42
|
catch (err) {
|
|
43
|
-
if (
|
|
43
|
+
if (isRefused(err, REFUSED.NOT_FOUND)) {
|
|
44
44
|
throw new ArcError(GAME_NOT_FOUND, gameNotOwned(id), {
|
|
45
45
|
cause: err,
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
if (isRefused(err, SECRET_QUOTA_FULL
|
|
48
|
+
if (isRefused(err, SECRET_QUOTA_FULL)) {
|
|
49
49
|
throw new ArcError(SECRET_QUOTA_FULL, secretQuotaFull(where), {
|
|
50
50
|
cause: err,
|
|
51
51
|
});
|
|
@@ -83,7 +83,7 @@ export async function remove(current, { channel, name, ...conf }) {
|
|
|
83
83
|
return { channel: gone.channel, name: gone.name };
|
|
84
84
|
}
|
|
85
85
|
catch (err) {
|
|
86
|
-
if (
|
|
86
|
+
if (isRefused(err, REFUSED.NOT_FOUND)) {
|
|
87
87
|
throw new ArcError(SECRET_NOT_FOUND, secretNotFound({ channel: where, name: named }), { cause: err });
|
|
88
88
|
}
|
|
89
89
|
throw err;
|
|
@@ -9,7 +9,7 @@ import { gameValuesList, gameValuesRead, gameValuesRemove, gameValuesWrite, game
|
|
|
9
9
|
import { ARGUMENT_INVALID, GAME_NOT_FOUND, LIMIT_REACHED, PARSE_FAILED, PATH_NOT_FOUND, VALUE_NOT_FOUND, VALUE_STORAGE_QUOTA_FULL, VALUE_TOO_LARGE, } from "../../config/code.js";
|
|
10
10
|
import { ArcError } from "../../util/error.js";
|
|
11
11
|
import { HttpError } from "../../util/http.js";
|
|
12
|
-
import { gameOf, headersOf,
|
|
12
|
+
import { gameOf, headersOf, isRefused, needOf, REFUSED } from "../game.js";
|
|
13
13
|
import { gameNotOwned, valueCallsSpent, valueDirEmpty, valueFileUnread, valueFull, valueHolds, valueKeyInvalid, valueNotFound, valueNotJson, valueSetWhat, valueTooLarge, } from "../../phrase/index.js";
|
|
14
14
|
// [declare]
|
|
15
15
|
// a key, as Arcadible takes one (db/function/game_value.sql, value_keys).
|
|
@@ -111,12 +111,12 @@ async function holds(id, channel, headers) {
|
|
|
111
111
|
// says `limit_reached`, never a minute's).
|
|
112
112
|
function refused(id, channel, headers) {
|
|
113
113
|
return async (err) => {
|
|
114
|
-
if (
|
|
114
|
+
if (isRefused(err, REFUSED.NOT_FOUND)) {
|
|
115
115
|
throw new ArcError(GAME_NOT_FOUND, gameNotOwned(id), {
|
|
116
116
|
cause: err,
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
if (
|
|
119
|
+
if (isRefused(err, REFUSED.FULL)) {
|
|
120
120
|
throw new ArcError(VALUE_STORAGE_QUOTA_FULL, valueFull(channel, await holds(id, channel, headers)), { cause: err });
|
|
121
121
|
}
|
|
122
122
|
if (err instanceof HttpError && err.code === LIMIT_REACHED) {
|
|
@@ -150,7 +150,7 @@ export async function set(current, { channel, dir, file, input, key, ...conf })
|
|
|
150
150
|
];
|
|
151
151
|
for (const batch of batches(items)) {
|
|
152
152
|
await gameValuesWrite(id, where, batch, headers).catch((err) => {
|
|
153
|
-
if (
|
|
153
|
+
if (isRefused(err, REFUSED.TOO_LARGE)) {
|
|
154
154
|
// a batch is under what a call holds, so it's one value's own size
|
|
155
155
|
const [largest] = [...batch].sort((a, b) => JSON.stringify(b.value).length - JSON.stringify(a.value).length);
|
|
156
156
|
throw new ArcError(VALUE_TOO_LARGE, valueTooLarge(largest?.key ?? ""), {
|
package/dist/api.js
CHANGED
|
@@ -120,6 +120,8 @@ export async function waitAndReport(current, deployed, result, { git, json, quie
|
|
|
120
120
|
code: release.reason ?? INTERNAL,
|
|
121
121
|
data,
|
|
122
122
|
json,
|
|
123
|
+
// the API's own retry for the reason, said beside it
|
|
124
|
+
retry: release.reason ? release.retry : null,
|
|
123
125
|
sw,
|
|
124
126
|
});
|
|
125
127
|
return;
|
package/dist/phrase/function.js
CHANGED
|
@@ -139,6 +139,10 @@ export function secretNameInvalid() {
|
|
|
139
139
|
].join("\n");
|
|
140
140
|
}
|
|
141
141
|
// [function]
|
|
142
|
+
export function secretTooLarge() {
|
|
143
|
+
return blocks("A secret's value is up to 4096 bytes.", "Keep a larger one where the function can fetch it, and set the secret to what it needs to get there, such as a key.");
|
|
144
|
+
}
|
|
145
|
+
// [function]
|
|
142
146
|
export function secretValueInvalid() {
|
|
143
147
|
return blocks("A secret's value is 1 to 4096 bytes, on standard input.", 'Such as: printf %s "$EXAMPLE_KEY" | arc unstable function secret set EXAMPLE_KEY');
|
|
144
148
|
}
|
package/dist/runner/entry.js
CHANGED
|
@@ -20,11 +20,10 @@ export const FUNCTION_MODULE = "function.js";
|
|
|
20
20
|
// with none; it resolves with the answer, and never throws (Arcadible
|
|
21
21
|
// unreached is a 503). `version` is raised whenever the transport gains
|
|
22
22
|
// something, and never goes down: every Function SDK published reads it.
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
// and are added to what the code is given, `env`. Neither header reaches
|
|
23
|
+
// It's the one thing the entry sets where the code can see it: no mark, and
|
|
24
|
+
// no `process.env`. A function's secrets arrive as a header too
|
|
25
|
+
// (x-arcadible-secrets, opened by the dispatcher), and are added to what
|
|
26
|
+
// the code is given, `env`. Neither header reaches
|
|
28
27
|
// the developer's code. Under arc serve they're the script's own bindings,
|
|
29
28
|
// named by ARCADIBLE_SECRETS, which the code isn't given, nor ARCADIBLE_SERVE,
|
|
30
29
|
// as on Arcadible. Whatever the code logs has the secrets' values it was
|
|
@@ -183,24 +182,12 @@ globalThis[Symbol.for("arcadible.function.api")] = {
|
|
|
183
182
|
}
|
|
184
183
|
},
|
|
185
184
|
};
|
|
186
|
-
// the old mark, which says the code is running as a function
|
|
187
|
-
globalThis[Symbol.for("arcadible.function")] = true;
|
|
188
185
|
export default {
|
|
189
186
|
async fetch(request, env, ctx) {
|
|
190
|
-
|
|
191
|
-
const set = (process.env ??= {});
|
|
192
|
-
if (env.ARCADIBLE_SERVE) {
|
|
193
|
-
serve = env.ARCADIBLE_SERVE;
|
|
194
|
-
set.ARCADIBLE_SERVE = env.ARCADIBLE_SERVE;
|
|
195
|
-
}
|
|
187
|
+
if (env.ARCADIBLE_SERVE) serve = env.ARCADIBLE_SERVE;
|
|
196
188
|
const claim = request.headers.get(CLAIM);
|
|
197
189
|
const secrets = request.headers.get(SECRETS);
|
|
198
|
-
if (claim)
|
|
199
|
-
claimed = claim;
|
|
200
|
-
set.ARCADIBLE_CLAIM = claim;
|
|
201
|
-
} else {
|
|
202
|
-
delete set.ARCADIBLE_CLAIM;
|
|
203
|
-
}
|
|
190
|
+
if (claim) claimed = claim;
|
|
204
191
|
// what the code is given: the script's bindings, but the entry's own
|
|
205
192
|
// two under arc serve, which Arcadible's env doesn't have
|
|
206
193
|
let given = env;
|
package/dist/util/output.js
CHANGED
|
@@ -72,9 +72,11 @@ export function exit(code) {
|
|
|
72
72
|
// only where the code is a catch-all's (`api_refused`, `unavailable`,
|
|
73
73
|
// `internal`) and what it caught was another code does that go with it as
|
|
74
74
|
// `cause`, the code and the retry it was told, so the condition isn't lost
|
|
75
|
-
// (ERRORS.md, Passing a code on). `code` is a failed release's reason,
|
|
76
|
-
//
|
|
77
|
-
|
|
75
|
+
// (ERRORS.md, Passing a code on). `code` is a failed release's reason, and
|
|
76
|
+
// `retry` what the API said beside it, which is passed on as it came, so a
|
|
77
|
+
// reason added since this CLI was built still says its own next step; a
|
|
78
|
+
// release read without one says the reason's own (config/retry.ts).
|
|
79
|
+
export function errorOf(ex, code, retry) {
|
|
78
80
|
const shown = code ?? codeOf(ex);
|
|
79
81
|
const told = toldOf(ex);
|
|
80
82
|
const cause = !code &&
|
|
@@ -83,9 +85,11 @@ export function errorOf(ex, code) {
|
|
|
83
85
|
told.code !== shown
|
|
84
86
|
? told
|
|
85
87
|
: null;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
let said = retry;
|
|
89
|
+
if (!code) {
|
|
90
|
+
said =
|
|
91
|
+
told?.code === shown || shown === API_REFUSED ? told?.retry : undefined;
|
|
92
|
+
}
|
|
89
93
|
return {
|
|
90
94
|
...(cause
|
|
91
95
|
? {
|
|
@@ -110,11 +114,11 @@ export function errorOf(ex, code) {
|
|
|
110
114
|
// release that failed. `nl` puts a blank line before the heading, after
|
|
111
115
|
// output the command has already printed, such as arc login's link.
|
|
112
116
|
// `code` is a failed release's reason, which the API may add to, so it isn't
|
|
113
|
-
// checked.
|
|
114
|
-
export function abort(heading, ex, { code, data, json = false, nl = false, pb, sw } = {}) {
|
|
117
|
+
// checked, and `retry` the API's own word beside it.
|
|
118
|
+
export function abort(heading, ex, { code, data, json = false, nl = false, pb, retry, sw } = {}) {
|
|
115
119
|
const shown = code ?? codeOf(ex);
|
|
116
120
|
if (json) {
|
|
117
|
-
print({ ...ex.data, ...data, error: errorOf(ex, code) });
|
|
121
|
+
print({ ...ex.data, ...data, error: errorOf(ex, code, retry) });
|
|
118
122
|
}
|
|
119
123
|
else {
|
|
120
124
|
if (pb) {
|
package/dist/util/request.js
CHANGED
|
@@ -28,9 +28,10 @@ function dataOf(body) {
|
|
|
28
28
|
return (isTable(body) ? body["data"] : null) ?? null;
|
|
29
29
|
}
|
|
30
30
|
// [function]
|
|
31
|
-
// an error's code, title, and message, from the response's status
|
|
32
|
-
// the API's own `{ code,
|
|
33
|
-
// there.
|
|
31
|
+
// an error's code, retry, title, and message, from the response's status
|
|
32
|
+
// text and the API's own `{ code, message, retry, title }`, which takes
|
|
33
|
+
// precedence when it's there. Each is a string, or left out: an answer that
|
|
34
|
+
// isn't the API's own (a proxy's page) has none.
|
|
34
35
|
function errorOf(statusText, data) {
|
|
35
36
|
const all = {
|
|
36
37
|
title: statusText,
|
package/dist/wires/room.js
CHANGED
package/npm-shrinkwrap.json
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@eslint/js": "10.0.1",
|
|
35
|
-
"@types/node": "25.9.
|
|
35
|
+
"@types/node": "25.9.12",
|
|
36
36
|
"eslint": "10.15.0",
|
|
37
37
|
"typescript": "5.9.3",
|
|
38
38
|
"typescript-eslint": "8.74.0"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"license": "Apache-2.0",
|
|
44
44
|
"name": "arcadible",
|
|
45
|
-
"version": "1.0.
|
|
45
|
+
"version": "1.0.46"
|
|
46
46
|
},
|
|
47
47
|
"node_modules/@cacheable/memory": {
|
|
48
48
|
"dependencies": {
|
|
@@ -735,10 +735,10 @@
|
|
|
735
735
|
"undici-types": ">=7.24.0 <7.24.7"
|
|
736
736
|
},
|
|
737
737
|
"dev": true,
|
|
738
|
-
"integrity": "sha512-
|
|
738
|
+
"integrity": "sha512-49uWGmIcvfuuEnFIm83Pn7MGcDvdY8UQ3v3DF4O0ouWbElWTaT/HudacSntQwFrnLAgiMoKtXEVV5dFC+DZ2cQ==",
|
|
739
739
|
"license": "MIT",
|
|
740
|
-
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.9.
|
|
741
|
-
"version": "25.9.
|
|
740
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.9.12.tgz",
|
|
741
|
+
"version": "25.9.12"
|
|
742
742
|
},
|
|
743
743
|
"node_modules/@typescript-eslint/eslint-plugin": {
|
|
744
744
|
"dependencies": {
|
|
@@ -2433,5 +2433,5 @@
|
|
|
2433
2433
|
}
|
|
2434
2434
|
},
|
|
2435
2435
|
"requires": true,
|
|
2436
|
-
"version": "1.0.
|
|
2436
|
+
"version": "1.0.46"
|
|
2437
2437
|
}
|
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"description": "Create, validate, package, and publish games on Arcadible.",
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@eslint/js": "10.0.1",
|
|
33
|
-
"@types/node": "25.9.
|
|
33
|
+
"@types/node": "25.9.12",
|
|
34
34
|
"eslint": "10.15.0",
|
|
35
35
|
"typescript": "5.9.3",
|
|
36
36
|
"typescript-eslint": "8.74.0"
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"test": "tsc && npm run lint && node --test \"test/**/*.test.js\" \"test/**/*.test.mjs\""
|
|
67
67
|
},
|
|
68
68
|
"type": "module",
|
|
69
|
-
"version": "1.0.
|
|
69
|
+
"version": "1.0.46"
|
|
70
70
|
}
|