arcadible 1.0.43 → 1.0.45
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/function/logs.js +7 -5
- package/dist/action/function/tool.js +3 -3
- package/dist/action/game.js +19 -15
- package/dist/action/key/tool.js +4 -4
- package/dist/action/play/tool.js +5 -5
- 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/config/code.js +0 -1
- package/dist/phrase/function.js +4 -0
- package/dist/runner/entry.js +6 -19
- package/dist/util/schema.js +4 -2
- package/dist/wires/room.js +0 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
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
|
});
|
|
@@ -11,7 +11,7 @@ import { ArcError, codeOf } from "../../util/error.js";
|
|
|
11
11
|
import { HttpError } from "../../util/http.js";
|
|
12
12
|
import { sleep } from "../../util/delay.js";
|
|
13
13
|
import { isTable } from "../../util/objs.js";
|
|
14
|
-
import { channelOf, gameOf, headersOf,
|
|
14
|
+
import { channelOf, gameOf, headersOf, isRefused, REFUSED } from "../game.js";
|
|
15
15
|
import { answerUnread, functionLogsFull, functionLogsRefused, functionLogsSinceInvalid, functionLogsVersionInvalid, gameNotOwned, unableToReach, } from "../../phrase/index.js";
|
|
16
16
|
// [declare]
|
|
17
17
|
// the protocol a follow speaks, offered with the token beside it, and the
|
|
@@ -136,7 +136,7 @@ async function tokenOf(id, headers) {
|
|
|
136
136
|
return await postGameFunctionLogsToken(id, null, headers);
|
|
137
137
|
}
|
|
138
138
|
catch (err) {
|
|
139
|
-
if (
|
|
139
|
+
if (isRefused(err, REFUSED.NOT_FOUND)) {
|
|
140
140
|
throw new ArcError(GAME_NOT_FOUND, gameNotOwned(id), { cause: err });
|
|
141
141
|
}
|
|
142
142
|
throw err;
|
|
@@ -165,7 +165,7 @@ async function pageOf(token, query, last) {
|
|
|
165
165
|
}, () => null);
|
|
166
166
|
if (!res.ok) {
|
|
167
167
|
const told = toldIn(body);
|
|
168
|
-
if (
|
|
168
|
+
if (told.code === "expired") {
|
|
169
169
|
if (last)
|
|
170
170
|
throw tokenRefused(told);
|
|
171
171
|
return null;
|
|
@@ -286,13 +286,15 @@ export async function follow(current, { channel, ...conf }, shown) {
|
|
|
286
286
|
for (let failed = 0;;) {
|
|
287
287
|
const closed = await followOnce(await tokenOf(id, headers), query, once);
|
|
288
288
|
const { code, status } = closed;
|
|
289
|
-
|
|
289
|
+
// read by the Worker's code alone, as a page is (`pageOf`): a bare 401
|
|
290
|
+
// is refused as any other 4xx, and a bare 507 tried again as a 5xx
|
|
291
|
+
if (code === "full") {
|
|
290
292
|
throw new ArcError(FUNCTION_LOGS_FOLLOWS_FULL, functionLogsFull(), {
|
|
291
293
|
cause: httpErrorOf(status ?? 507, closed),
|
|
292
294
|
status: status ?? 507,
|
|
293
295
|
});
|
|
294
296
|
}
|
|
295
|
-
const expired =
|
|
297
|
+
const expired = code === "expired";
|
|
296
298
|
if (status && status < 500 && !expired) {
|
|
297
299
|
throw refused(status, closed);
|
|
298
300
|
}
|
|
@@ -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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// command names, the session's headers, and telling the API's refusals
|
|
4
4
|
// apart.
|
|
5
5
|
import { auth, gameWireUsages } from "../api.js";
|
|
6
|
-
import {
|
|
6
|
+
import { ARGUMENT_INVALID, GAME_ID_MISSING, GAME_NOT_FOUND, NOT_LOGGED_IN, } from "../config/code.js";
|
|
7
7
|
import { ArcError } from "../util/error.js";
|
|
8
8
|
import { given } from "../parser/given.js";
|
|
9
9
|
import { HttpError } from "../util/http.js";
|
|
@@ -67,19 +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
|
-
if (!(err instanceof HttpError))
|
|
81
|
-
return false;
|
|
82
|
-
if (err.code === code)
|
|
83
|
-
return true;
|
|
84
|
-
return (err.status === status && (err.code === undefined || !ALL.has(err.code)));
|
|
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;
|
|
85
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;
|
|
@@ -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/config/code.js
CHANGED
|
@@ -108,7 +108,6 @@ export const ISSUE = {
|
|
|
108
108
|
MARKDOWN_INVALID: "markdown_invalid",
|
|
109
109
|
MEDIA_INVALID: "media_invalid",
|
|
110
110
|
OPTION_INVALID: "option_invalid",
|
|
111
|
-
OUT_OF_RANGE: "out_of_range",
|
|
112
111
|
PATH_INVALID: "path_invalid",
|
|
113
112
|
REQUIRED: "required",
|
|
114
113
|
SCREENSHOT_NUMBER_DUPLICATE: "screenshot_number_duplicate",
|
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/schema.js
CHANGED
|
@@ -45,14 +45,16 @@ export function issueCodeOf(issue) {
|
|
|
45
45
|
return typeRefused(issue) ? ISSUE.TYPE_INVALID : ISSUE.INVALID;
|
|
46
46
|
case "invalid_value":
|
|
47
47
|
return ISSUE.OPTION_INVALID;
|
|
48
|
+
// a number's range: no field has one, so it has no code of its own
|
|
49
|
+
// until one does
|
|
48
50
|
case "too_big":
|
|
49
51
|
if (NUMBERS.has(issue.origin)) {
|
|
50
|
-
return ISSUE.
|
|
52
|
+
return ISSUE.INVALID;
|
|
51
53
|
}
|
|
52
54
|
return issue.origin === "string" ? ISSUE.TOO_LONG : ISSUE.TOO_MANY;
|
|
53
55
|
case "too_small":
|
|
54
56
|
if (NUMBERS.has(issue.origin)) {
|
|
55
|
-
return ISSUE.
|
|
57
|
+
return ISSUE.INVALID;
|
|
56
58
|
}
|
|
57
59
|
return issue.minimum > 1 ? ISSUE.TOO_SHORT : ISSUE.EMPTY;
|
|
58
60
|
default:
|
package/dist/wires/room.js
CHANGED
package/npm-shrinkwrap.json
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"license": "Apache-2.0",
|
|
44
44
|
"name": "arcadible",
|
|
45
|
-
"version": "1.0.
|
|
45
|
+
"version": "1.0.45"
|
|
46
46
|
},
|
|
47
47
|
"node_modules/@cacheable/memory": {
|
|
48
48
|
"dependencies": {
|
|
@@ -2433,5 +2433,5 @@
|
|
|
2433
2433
|
}
|
|
2434
2434
|
},
|
|
2435
2435
|
"requires": true,
|
|
2436
|
-
"version": "1.0.
|
|
2436
|
+
"version": "1.0.45"
|
|
2437
2437
|
}
|
package/package.json
CHANGED