arcadible 1.0.35 → 1.0.37
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/README.md +1 -1
- package/dist/action/function/logs.js +238 -0
- package/dist/action/function/tool.js +40 -16
- package/dist/action/pack/limits.js +28 -4
- package/dist/action/pack/tool.js +2 -1
- package/dist/action/value/tool.js +2 -2
- package/dist/action/wire/tool.js +1 -1
- package/dist/api.js +30 -5
- package/dist/cli/command.js +12 -2
- package/dist/command/function/index.js +7 -7
- package/dist/command/function/logs.js +154 -0
- package/dist/command/function/pause.js +1 -1
- package/dist/command/function/resume.js +1 -1
- package/dist/command/function/run.js +1 -1
- package/dist/command/function/secret/index.js +1 -1
- package/dist/command/function/secret/remove.js +2 -2
- package/dist/command/function/secret/run.js +1 -1
- package/dist/command/function/secret/set.js +1 -1
- package/dist/command/function/status.js +26 -9
- package/dist/command/{delete.js → game/delete.js} +14 -13
- package/dist/command/game/index.js +12 -0
- package/dist/command/server/index.js +3 -4
- package/dist/command/server/key/create.js +1 -1
- package/dist/command/server/key/index.js +1 -1
- package/dist/command/server/key/revoke.js +1 -1
- package/dist/command/server/key/run.js +1 -1
- package/dist/command/unstable/index.js +23 -0
- package/dist/command/value/get.js +1 -1
- package/dist/command/value/index.js +6 -6
- package/dist/command/value/list.js +1 -1
- package/dist/command/value/remove.js +2 -2
- package/dist/command/value/set.js +1 -1
- package/dist/command/value/usage.js +16 -6
- package/dist/command/wire/index.js +4 -5
- package/dist/commands.js +3 -29
- package/dist/config/code.js +7 -3
- package/dist/config/limit.js +4 -0
- package/dist/phrase/deploy.js +1 -1
- package/dist/phrase/function.js +71 -17
- package/dist/phrase/game.js +1 -1
- package/dist/phrase/index.js +1 -0
- package/dist/phrase/pack.js +9 -0
- package/dist/phrase/server.js +4 -4
- package/dist/phrase/unstable.js +6 -0
- package/dist/phrase/value.js +4 -4
- package/dist/runner/entry.js +59 -3
- package/dist/schema/check/workflow.js +0 -21
- package/dist/schema/workflow.js +6 -28
- package/dist/serve/runner.js +9 -2
- package/dist/util/zip.js +5 -0
- package/npm-shrinkwrap.json +33 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,10 +50,10 @@ Your repository is the store page: `arcadible.toml` holds the game's settings, `
|
|
|
50
50
|
| `arc deploy` | Validates, builds, packages, and publishes, directly or through GitHub Actions |
|
|
51
51
|
| `arc play` | Plays a deployed game from any channel or version |
|
|
52
52
|
| `arc open` | Opens a game's store page |
|
|
53
|
-
| `arc delete` | Deletes the project's game from Arcadible, for good, asking first |
|
|
54
53
|
| `arc login` | Logs in to Arcadible with a device code |
|
|
55
54
|
| `arc logout` | Logs out |
|
|
56
55
|
| `arc whoami` | Shows the account you're logged in to |
|
|
56
|
+
| `arc unstable` | Commands for what isn't released yet, which may change or go in any release |
|
|
57
57
|
|
|
58
58
|
Run `arc <command> --help` for its options, or see the [CLI reference](https://developer.arcadible.com/references/arcadible-cli).
|
|
59
59
|
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
// a game's function's logs (plan/FUNCTION-LOGS.md, Reading them): kept by
|
|
2
|
+
// Arcadible's logs Worker, not the API, which the game's owner reads with a
|
|
3
|
+
// token the API makes for them, good for 10 minutes: the newest page, or
|
|
4
|
+
// that page and then each entry as it comes, followed over a WebSocket,
|
|
5
|
+
// opened again with a new token whenever a follow closes.
|
|
6
|
+
// [import]
|
|
7
|
+
import { WebSocket } from "ws";
|
|
8
|
+
import { postGameFunctionLogsToken } from "../../api.js";
|
|
9
|
+
import { API_REFUSED, API_UNREACHABLE, ARGUMENT_INVALID, GAME_UNAVAILABLE, INTERNAL, } from "../../config/code.js";
|
|
10
|
+
import { ArcError } from "../../util/error.js";
|
|
11
|
+
import { sleep } from "../../util/delay.js";
|
|
12
|
+
import { isTable } from "../../util/objs.js";
|
|
13
|
+
import { channelOf, gameOf, headersOf, isStatus } from "../game.js";
|
|
14
|
+
import { answerUnread, functionLogsBusy, functionLogsRefused, functionLogsSinceInvalid, functionLogsVersionInvalid, gameNotOwned, unableToReach, } from "../../phrase/index.js";
|
|
15
|
+
// [declare]
|
|
16
|
+
// the protocol a follow speaks, offered with the token beside it, and the
|
|
17
|
+
// code it's closed with at its hour (the logs Worker's src/logs.js and
|
|
18
|
+
// src/game.js).
|
|
19
|
+
const PROTOCOL = "arcadible-logs";
|
|
20
|
+
// how often a follow says it's there, so no proxy takes it for idle; the
|
|
21
|
+
// game's object answers `pong`.
|
|
22
|
+
const PING = 30 * 1000;
|
|
23
|
+
// how many follows in a row may fail to open before the command does, and
|
|
24
|
+
// the longest wait between them.
|
|
25
|
+
const TRIES = 5;
|
|
26
|
+
const WAIT = 30 * 1000;
|
|
27
|
+
// a version as the Worker takes it, and a span back from now.
|
|
28
|
+
const VERSION = /^[0-9A-Za-z.+-]{1,64}$/u;
|
|
29
|
+
const SPAN = /^([1-9][0-9]{0,4})([mhd])$/u;
|
|
30
|
+
const UNIT = {
|
|
31
|
+
d: 24 * 60 * 60 * 1000,
|
|
32
|
+
h: 60 * 60 * 1000,
|
|
33
|
+
m: 60 * 1000,
|
|
34
|
+
};
|
|
35
|
+
// [function]
|
|
36
|
+
// `--since` as an ISO time: a span back from `now` (`10m`, `2h`, `1d`), or
|
|
37
|
+
// a time or a day as ISO writes it (`2026-11-19T14:00:00Z`,
|
|
38
|
+
// `2026-11-19`, UTC's midnight). Anything else is argument_invalid.
|
|
39
|
+
export function sinceOf(text, now = Date.now()) {
|
|
40
|
+
const span = SPAN.exec(text.trim());
|
|
41
|
+
if (span) {
|
|
42
|
+
return new Date(now - Number(span[1]) * (UNIT[span[2] ?? "m"] ?? 0)).toISOString();
|
|
43
|
+
}
|
|
44
|
+
const at = Date.parse(text);
|
|
45
|
+
if (/^\d{4}-\d{2}-\d{2}/u.test(text) && Number.isFinite(at)) {
|
|
46
|
+
return new Date(at).toISOString();
|
|
47
|
+
}
|
|
48
|
+
throw new ArcError(ARGUMENT_INVALID, functionLogsSinceInvalid(text));
|
|
49
|
+
}
|
|
50
|
+
// [function]
|
|
51
|
+
// the query a page or a follow asks with.
|
|
52
|
+
function queryOf({ errors, since, version }, channel) {
|
|
53
|
+
const query = new URLSearchParams();
|
|
54
|
+
if (channel)
|
|
55
|
+
query.set("channel", channel);
|
|
56
|
+
if (version) {
|
|
57
|
+
if (!VERSION.test(version)) {
|
|
58
|
+
throw new ArcError(ARGUMENT_INVALID, functionLogsVersionInvalid(version));
|
|
59
|
+
}
|
|
60
|
+
query.set("version", version);
|
|
61
|
+
}
|
|
62
|
+
if (since)
|
|
63
|
+
query.set("since", sinceOf(since));
|
|
64
|
+
if (errors)
|
|
65
|
+
query.set("outcome", "error");
|
|
66
|
+
return query;
|
|
67
|
+
}
|
|
68
|
+
// [function]
|
|
69
|
+
// whether an answer is a page as the Worker answers it.
|
|
70
|
+
function isPage(value) {
|
|
71
|
+
return (isTable(value) &&
|
|
72
|
+
Array.isArray(value["data"]) &&
|
|
73
|
+
value["data"].every((each) => isEntry(each)));
|
|
74
|
+
}
|
|
75
|
+
// [function]
|
|
76
|
+
function isEntry(value) {
|
|
77
|
+
return (isTable(value) &&
|
|
78
|
+
typeof value["id"] === "number" &&
|
|
79
|
+
typeof value["at"] === "number");
|
|
80
|
+
}
|
|
81
|
+
// [function]
|
|
82
|
+
// the Worker's refusal as the CLI's failure: Arcadible's side (a 5xx) is
|
|
83
|
+
// internal, and anything else api_refused, never a 401 that would end the
|
|
84
|
+
// session, since the token isn't the session's.
|
|
85
|
+
function refused(status, code) {
|
|
86
|
+
return new ArcError(status >= 500 ? INTERNAL : API_REFUSED, functionLogsRefused({ code, status }));
|
|
87
|
+
}
|
|
88
|
+
// [function]
|
|
89
|
+
// a token for the game's logs: the game is the caller's, or
|
|
90
|
+
// game_unavailable, as for the rest of `arc unstable function`.
|
|
91
|
+
async function tokenOf(id, headers) {
|
|
92
|
+
try {
|
|
93
|
+
return await postGameFunctionLogsToken(id, null, headers);
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
if (isStatus(err, 404)) {
|
|
97
|
+
throw new ArcError(GAME_UNAVAILABLE, gameNotOwned(id), { cause: err });
|
|
98
|
+
}
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// [function]
|
|
103
|
+
// the newest page, newest first, or null when the token had expired.
|
|
104
|
+
async function pageOf(token, query) {
|
|
105
|
+
let res;
|
|
106
|
+
try {
|
|
107
|
+
res = await fetch(query.size ? `${token.url}?${query.toString()}` : token.url, {
|
|
108
|
+
headers: { authorization: `Bearer ${token.token}` },
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
catch (ex) {
|
|
112
|
+
throw new ArcError(API_UNREACHABLE, unableToReach(), { cause: ex });
|
|
113
|
+
}
|
|
114
|
+
const body = await res.text().then((text) => {
|
|
115
|
+
try {
|
|
116
|
+
return JSON.parse(text);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}, () => null);
|
|
122
|
+
if (!res.ok) {
|
|
123
|
+
const code = isTable(body) && typeof body["code"] === "string" ? body["code"] : null;
|
|
124
|
+
if (res.status === 401 && code === "expired")
|
|
125
|
+
return null;
|
|
126
|
+
throw refused(res.status, code);
|
|
127
|
+
}
|
|
128
|
+
if (!isPage(body)) {
|
|
129
|
+
throw new ArcError(INTERNAL, answerUnread("a function's logs"));
|
|
130
|
+
}
|
|
131
|
+
return body.data;
|
|
132
|
+
}
|
|
133
|
+
// [function]
|
|
134
|
+
// the game's newest entries that match, at most 100, newest first. A token
|
|
135
|
+
// that ended on its way is asked for again, once.
|
|
136
|
+
export async function logs(current, { channel, ...conf }) {
|
|
137
|
+
const where = channelOf(channel);
|
|
138
|
+
const query = queryOf(conf, where);
|
|
139
|
+
const id = await gameOf(conf);
|
|
140
|
+
const headers = headersOf(current);
|
|
141
|
+
for (let tries = 0;; tries += 1) {
|
|
142
|
+
const page = await pageOf(await tokenOf(id, headers), query);
|
|
143
|
+
if (page)
|
|
144
|
+
return page;
|
|
145
|
+
if (tries)
|
|
146
|
+
throw refused(401, "expired");
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// [function]
|
|
150
|
+
// a follow, open until it closes: each entry it sends goes to `shown`, and
|
|
151
|
+
// it resolves with how it ended.
|
|
152
|
+
function followOnce(token, query, shown) {
|
|
153
|
+
const url = new URL(token.url);
|
|
154
|
+
url.protocol = url.protocol === "http:" ? "ws:" : "wss:";
|
|
155
|
+
url.search = new URLSearchParams([["follow", ""], ...query]).toString();
|
|
156
|
+
return new Promise((resolve) => {
|
|
157
|
+
let opened = false;
|
|
158
|
+
let done = false;
|
|
159
|
+
let pinging = null;
|
|
160
|
+
const end = (status) => {
|
|
161
|
+
if (done)
|
|
162
|
+
return;
|
|
163
|
+
done = true;
|
|
164
|
+
if (pinging)
|
|
165
|
+
clearInterval(pinging);
|
|
166
|
+
resolve({ opened, status });
|
|
167
|
+
};
|
|
168
|
+
const socket = new WebSocket(url.href, [PROTOCOL, token.token]);
|
|
169
|
+
socket.on("unexpected-response", (req, res) => {
|
|
170
|
+
req.destroy();
|
|
171
|
+
res.resume();
|
|
172
|
+
end(res.statusCode ?? 500);
|
|
173
|
+
});
|
|
174
|
+
socket.on("open", () => {
|
|
175
|
+
opened = true;
|
|
176
|
+
pinging = setInterval(() => {
|
|
177
|
+
socket.send("ping");
|
|
178
|
+
}, PING);
|
|
179
|
+
});
|
|
180
|
+
socket.on("message", (data) => {
|
|
181
|
+
let entry = null;
|
|
182
|
+
try {
|
|
183
|
+
entry = JSON.parse(String(data));
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// `pong`, or anything else that isn't an entry
|
|
187
|
+
}
|
|
188
|
+
if (isEntry(entry))
|
|
189
|
+
shown(entry);
|
|
190
|
+
});
|
|
191
|
+
socket.on("error", () => {
|
|
192
|
+
// its close follows
|
|
193
|
+
});
|
|
194
|
+
socket.on("close", () => {
|
|
195
|
+
end(null);
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
// [function]
|
|
200
|
+
// the game's newest entries that match, then each new one as it comes,
|
|
201
|
+
// until the command is stopped: `shown` is given each once, oldest first.
|
|
202
|
+
// A follow closes at its hour, or when the connection drops, and is opened
|
|
203
|
+
// again with a new token; one the Worker refuses ends the command, and so
|
|
204
|
+
// does one that can't be opened five times in a row.
|
|
205
|
+
export async function follow(current, { channel, ...conf }, shown) {
|
|
206
|
+
const where = channelOf(channel);
|
|
207
|
+
const query = queryOf(conf, where);
|
|
208
|
+
const id = await gameOf(conf);
|
|
209
|
+
const headers = headersOf(current);
|
|
210
|
+
let last = 0;
|
|
211
|
+
const once = (entry) => {
|
|
212
|
+
// a follow sends its newest few as it opens: those shown already aren't
|
|
213
|
+
// shown again
|
|
214
|
+
if (entry.id <= last)
|
|
215
|
+
return;
|
|
216
|
+
last = entry.id;
|
|
217
|
+
shown(entry);
|
|
218
|
+
};
|
|
219
|
+
const first = await logs(current, { channel, ...conf });
|
|
220
|
+
for (const entry of first.reverse())
|
|
221
|
+
once(entry);
|
|
222
|
+
// a follow takes no `since`: it sends what's newest
|
|
223
|
+
query.delete("since");
|
|
224
|
+
for (let failed = 0;;) {
|
|
225
|
+
const closed = await followOnce(await tokenOf(id, headers), query, once);
|
|
226
|
+
if (closed.status === 429)
|
|
227
|
+
throw new ArcError(API_REFUSED, functionLogsBusy());
|
|
228
|
+
if (closed.status && closed.status < 500 && closed.status !== 401) {
|
|
229
|
+
throw refused(closed.status, null);
|
|
230
|
+
}
|
|
231
|
+
failed = closed.opened ? 0 : failed + 1;
|
|
232
|
+
if (failed >= TRIES) {
|
|
233
|
+
throw new ArcError(API_UNREACHABLE, unableToReach());
|
|
234
|
+
}
|
|
235
|
+
if (failed)
|
|
236
|
+
await sleep(Math.min(WAIT, 1000 * 2 ** failed));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -21,6 +21,11 @@ function pausedOf(pauses, channel) {
|
|
|
21
21
|
return REASONS.find((reason) => reasons.includes(reason)) ?? null;
|
|
22
22
|
}
|
|
23
23
|
// [function]
|
|
24
|
+
// when a channel's pause for a limit ends by itself, or null for none.
|
|
25
|
+
function resumesOf(pauses, channel) {
|
|
26
|
+
return ((pauses ?? []).find((pause) => pause.channel === channel && pause.reason === "limit")?.resumes_at ?? null);
|
|
27
|
+
}
|
|
28
|
+
// [function]
|
|
24
29
|
// whether a channel's live build has a function: true, false, or null when
|
|
25
30
|
// that can't be read, which never stands in a pause's way.
|
|
26
31
|
async function hasFunction(id, channel) {
|
|
@@ -68,7 +73,7 @@ export async function pause(current, { channel, ...conf }) {
|
|
|
68
73
|
// resumes the game's function on a channel: lifts its owner's pause, and
|
|
69
74
|
// resolves with `{ channel, lifted, paused }`, `paused` the reason it's
|
|
70
75
|
// still paused for, or null. One that isn't paused stays as it was, as `pause` leaves one
|
|
71
|
-
// that's paused already. A pause of Arcadible's, or
|
|
76
|
+
// that's paused already. A pause of Arcadible's, or a limit's, isn't
|
|
72
77
|
// its owner's to lift: function_pause_reserved, saying who lifts it.
|
|
73
78
|
export async function resume(current, { channel, ...conf }) {
|
|
74
79
|
const where = needOf(channel);
|
|
@@ -94,10 +99,10 @@ export async function resume(current, { channel, ...conf }) {
|
|
|
94
99
|
// the game's function on each channel, or on one: `{ channel, function,
|
|
95
100
|
// paused, requests }`, `function` whether the channel's live build has one
|
|
96
101
|
// (a pause and a usage are the channel's, so neither says), `paused` the
|
|
97
|
-
// reason it's paused for, or null for none,
|
|
98
|
-
// this month. With them,
|
|
99
|
-
//
|
|
100
|
-
//
|
|
102
|
+
// reason it's paused for, or null for none, `requests` what it answered
|
|
103
|
+
// this month, and `cpu_ms` its CPU time. With them, what holds it, whichever channels were asked for:
|
|
104
|
+
// the game's day against its own limit, its month, and its account's pool
|
|
105
|
+
// against its plan's, each as the API states it.
|
|
101
106
|
export async function status(current, { channel, ...conf }) {
|
|
102
107
|
const where = channelOf(channel);
|
|
103
108
|
const id = await gameOf(conf);
|
|
@@ -112,17 +117,36 @@ export async function status(current, { channel, ...conf }) {
|
|
|
112
117
|
const has = await Promise.all(shown.map((each) => hasFunction(id, each)));
|
|
113
118
|
const rows = usages ?? [];
|
|
114
119
|
const [first] = rows;
|
|
115
|
-
const sum = (of) => of.reduce((total, each) => total + Number(each
|
|
120
|
+
const sum = (of, field) => of.reduce((total, each) => total + Number(each[field] ?? 0), 0);
|
|
121
|
+
// null is no limit, and stays null
|
|
122
|
+
const limit = (value) => value === null ? null : Number(value);
|
|
116
123
|
return {
|
|
117
|
-
channels: shown.map((each, i) =>
|
|
118
|
-
channel
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
channels: shown.map((each, i) => {
|
|
125
|
+
const own = rows.filter((row) => row.channel === each);
|
|
126
|
+
return {
|
|
127
|
+
channel: each,
|
|
128
|
+
cpu_ms: sum(own, "cpu_ms"),
|
|
129
|
+
function: has[i] ?? null,
|
|
130
|
+
paused: pausedOf(pauses, each),
|
|
131
|
+
requests: sum(own, "requests"),
|
|
132
|
+
resumes_at: resumesOf(pauses, each),
|
|
133
|
+
};
|
|
134
|
+
}),
|
|
135
|
+
day: first
|
|
136
|
+
? { allowance: limit(first.allowance), requests: Number(first.used) }
|
|
137
|
+
: null,
|
|
138
|
+
month: first
|
|
139
|
+
? {
|
|
140
|
+
cpu_ms: Number(first.month_cpu_ms ?? 0),
|
|
141
|
+
requests: Number(first.month_used),
|
|
142
|
+
}
|
|
143
|
+
: null,
|
|
144
|
+
pool: first
|
|
145
|
+
? {
|
|
146
|
+
allowance: limit(first.pool_allowance),
|
|
147
|
+
cpu_ms: Number(first.pool_cpu_ms ?? 0),
|
|
148
|
+
requests: Number(first.pool_used),
|
|
149
|
+
}
|
|
150
|
+
: null,
|
|
127
151
|
};
|
|
128
152
|
}
|
|
@@ -2,19 +2,43 @@
|
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
// [import]
|
|
5
|
-
import { PACKAGE_FILE_TOO_LARGE, PACKAGE_TOO_MANY_FILES, PACKAGE_UNCOMPRESSED_TOO_LARGE, } from "../../config/code.js";
|
|
5
|
+
import { PACKAGE_FILE_TOO_LARGE, PACKAGE_PATH_INVALID, PACKAGE_TOO_MANY_FILES, PACKAGE_UNCOMPRESSED_TOO_LARGE, } from "../../config/code.js";
|
|
6
6
|
import { ArcError } from "../../util/error.js";
|
|
7
|
-
import { packageFileTooLarge, packageTooManyFiles, packageUncompressedTooLarge, } from "../../phrase/index.js";
|
|
8
|
-
import { FILE_SIZE, FILES, TOTAL_SIZE } from "../../config/limit.js";
|
|
7
|
+
import { packageFileTooLarge, packagePathInvalid, packageTooManyEntries, packageTooManyFiles, packageUncompressedTooLarge, } from "../../phrase/index.js";
|
|
8
|
+
import { ENTRIES, FILE_SIZE, FILES, TOTAL_SIZE } from "../../config/limit.js";
|
|
9
9
|
import { toMb } from "../../util/size.js";
|
|
10
10
|
// [declare]
|
|
11
11
|
export const MAX_FILES = FILES;
|
|
12
|
+
export const MAX_ENTRIES = ENTRIES;
|
|
12
13
|
export const MAX_FILE_SIZE = FILE_SIZE;
|
|
13
14
|
export const MAX_TOTAL_SIZE = TOTAL_SIZE;
|
|
14
15
|
// [function]
|
|
16
|
+
// whether a name is one the router serves as it is: no `.` or `..` part, no
|
|
17
|
+
// backslash, and no escape that decodes to `.`, `/`, or `\\` (`%2e`, `%2f`,
|
|
18
|
+
// `%5c`, in any case), each of which a URL reads as another path. The
|
|
19
|
+
// pipeline refuses the same, with the same code (its `isPlain`, zip.mts).
|
|
20
|
+
export function isPlain(name) {
|
|
21
|
+
return (!name.includes("\\") &&
|
|
22
|
+
!/%(?:2e|2f|5c)/iu.test(name) &&
|
|
23
|
+
!name.split("/").some((part) => part === "." || part === ".."));
|
|
24
|
+
}
|
|
25
|
+
// [function]
|
|
26
|
+
// throws for more entries than the pipeline reads, files and folders
|
|
27
|
+
// together.
|
|
28
|
+
export function checkEntries(count) {
|
|
29
|
+
if (count > MAX_ENTRIES) {
|
|
30
|
+
throw new ArcError(PACKAGE_TOO_MANY_FILES, packageTooManyEntries(MAX_ENTRIES));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// [function]
|
|
15
34
|
// checks a zip's files against the limits, and throws for the first one it
|
|
16
|
-
// breaks: a file over 64 MB, more than 10,000 files,
|
|
35
|
+
// breaks: a name that isn't plain, a file over 64 MB, more than 10,000 files,
|
|
36
|
+
// or over 256 MB in all.
|
|
17
37
|
export function check(entries) {
|
|
38
|
+
const unplain = entries.find((entry) => !isPlain(entry.name));
|
|
39
|
+
if (unplain) {
|
|
40
|
+
throw new ArcError(PACKAGE_PATH_INVALID, packagePathInvalid(unplain.name));
|
|
41
|
+
}
|
|
18
42
|
const large = entries.find((entry) => entry.size > MAX_FILE_SIZE);
|
|
19
43
|
if (large) {
|
|
20
44
|
throw new ArcError(PACKAGE_FILE_TOO_LARGE, packageFileTooLarge(large.name, toMb(MAX_FILE_SIZE)));
|
package/dist/action/pack/tool.js
CHANGED
|
@@ -9,7 +9,7 @@ import { ArcError } from "../../util/error.js";
|
|
|
9
9
|
import { MEDIA, PACKAGED } from "../../config/file.js";
|
|
10
10
|
import { deployDirMissing, packageIndexMissing, packagePathReserved, packageTooLarge, runnerNotBuilt, unableToFind, } from "../../phrase/index.js";
|
|
11
11
|
import { ZIP_SIZE } from "../../config/limit.js";
|
|
12
|
-
import { check, measure } from "./limits.js";
|
|
12
|
+
import { check, checkEntries, measure } from "./limits.js";
|
|
13
13
|
import { favicon } from "../../util/favicon.js";
|
|
14
14
|
import { handle, tool } from "../../config/product.js";
|
|
15
15
|
import { toMb } from "../../util/size.js";
|
|
@@ -85,6 +85,7 @@ function verifyPartial(zip) {
|
|
|
85
85
|
// [function]
|
|
86
86
|
function verifyTotal(zip) {
|
|
87
87
|
check(zip.entries());
|
|
88
|
+
checkEntries(zip.count());
|
|
88
89
|
return zip;
|
|
89
90
|
}
|
|
90
91
|
// [function]
|
|
@@ -202,8 +202,8 @@ export async function remove(current, { channel, key, ...conf }) {
|
|
|
202
202
|
// [function]
|
|
203
203
|
// what each scope of the game's values holds on a channel, against what it
|
|
204
204
|
// may: the developer's, the game's, its players', and its server's. And the
|
|
205
|
-
// calls the game's clients made today on that channel, with the game's
|
|
206
|
-
//
|
|
205
|
+
// calls the game's clients made today on that channel, with the game's
|
|
206
|
+
// day, its month, and its account's pool, as the API states them; null when they
|
|
207
207
|
// can't be had, which fails nothing.
|
|
208
208
|
export async function usage(current, { channel, ...conf }) {
|
|
209
209
|
const where = needOf(channel);
|
package/dist/action/wire/tool.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// arc wire: a game's wires (plan/SDKWIRES.md), live messages between its
|
|
1
|
+
// arc unstable wire: a game's wires (plan/SDKWIRES.md), live messages between its
|
|
2
2
|
// players. What its owner sees of them is their usage: wires keep nothing,
|
|
3
3
|
// and nothing about one is set from here.
|
|
4
4
|
import { gameWireUsages } from "../../api.js";
|
package/dist/api.js
CHANGED
|
@@ -88,23 +88,35 @@ const isValueListed = shaped({
|
|
|
88
88
|
const isValueRemoved = shaped({ removed: num });
|
|
89
89
|
const isValueUsage = shaped({
|
|
90
90
|
bytes: num,
|
|
91
|
-
bytes_limit: num,
|
|
91
|
+
bytes_limit: nul(num),
|
|
92
92
|
bytes_most: num,
|
|
93
93
|
channel: str,
|
|
94
94
|
keys: num,
|
|
95
|
-
keys_limit: num,
|
|
95
|
+
keys_limit: nul(num),
|
|
96
96
|
keys_most: num,
|
|
97
97
|
owners: num,
|
|
98
98
|
scope: str,
|
|
99
99
|
});
|
|
100
100
|
const isValueCalls = shaped({
|
|
101
|
-
allowance: num,
|
|
101
|
+
allowance: nul(num),
|
|
102
102
|
channel: str,
|
|
103
|
+
month_used: num,
|
|
104
|
+
pool_allowance: nul(num),
|
|
105
|
+
pool_used: num,
|
|
103
106
|
reads: num,
|
|
104
107
|
used: num,
|
|
105
108
|
writes: num,
|
|
106
109
|
});
|
|
107
|
-
const
|
|
110
|
+
const isLogsToken = shaped({
|
|
111
|
+
expires_at: str,
|
|
112
|
+
token: str,
|
|
113
|
+
url: str,
|
|
114
|
+
});
|
|
115
|
+
const isPause = shaped({
|
|
116
|
+
channel: str,
|
|
117
|
+
reason: str,
|
|
118
|
+
resumes_at: opt(nul(str)),
|
|
119
|
+
});
|
|
108
120
|
const isWireUsage = shaped({
|
|
109
121
|
channel: str,
|
|
110
122
|
connections: opt(nul(either(num, str))),
|
|
@@ -112,9 +124,16 @@ const isWireUsage = shaped({
|
|
|
112
124
|
messages: opt(nul(either(num, str))),
|
|
113
125
|
});
|
|
114
126
|
const isUsage = shaped({
|
|
115
|
-
allowance: either(num, str),
|
|
127
|
+
allowance: nul(either(num, str)),
|
|
116
128
|
channel: str,
|
|
129
|
+
cpu_ms: opt(nul(either(num, str))),
|
|
130
|
+
month_cpu_ms: opt(nul(either(num, str))),
|
|
131
|
+
month_used: either(num, str),
|
|
132
|
+
pool_allowance: nul(either(num, str)),
|
|
133
|
+
pool_cpu_ms: opt(nul(either(num, str))),
|
|
134
|
+
pool_used: either(num, str),
|
|
117
135
|
requests: opt(nul(either(num, str))),
|
|
136
|
+
used: either(num, str),
|
|
118
137
|
});
|
|
119
138
|
// [function]
|
|
120
139
|
// the API's answer, checked as it arrives: `is` says whether it has the
|
|
@@ -306,6 +325,12 @@ export function gameFunctionUsages(id, params, headers) {
|
|
|
306
325
|
return answer(listed(isUsage), "a function's usage", get(endpoint(pathOf `/games/${id}/function_usages`, params), headers));
|
|
307
326
|
}
|
|
308
327
|
// [function]
|
|
328
|
+
// a token to read the caller's own game's function's logs, good for 10
|
|
329
|
+
// minutes.
|
|
330
|
+
export function postGameFunctionLogsToken(id, params, headers) {
|
|
331
|
+
return answer(isLogsToken, "a token for a function's logs", post(endpoint(pathOf `/games/${id}/function_logs/token`, params), null, headers));
|
|
332
|
+
}
|
|
333
|
+
// [function]
|
|
309
334
|
// the usage of the caller's own game's wires this month: a row a channel
|
|
310
335
|
// and a day.
|
|
311
336
|
export function gameWireUsages(id, params, headers) {
|
package/dist/cli/command.js
CHANGED
|
@@ -127,6 +127,17 @@ function parser(command, args, conf, matched) {
|
|
|
127
127
|
return (takesJson(command) ? built.fail(fail(args)) : built).strict();
|
|
128
128
|
}
|
|
129
129
|
// [function]
|
|
130
|
+
// the section of `.arcrc` a command's options are read from: the top-level
|
|
131
|
+
// command's, for a family's commands too, or in a namespace, the name of
|
|
132
|
+
// the command under it that the arguments give.
|
|
133
|
+
function section(command, args) {
|
|
134
|
+
if (!isFamily(command) || !command.namespace) {
|
|
135
|
+
return command.name;
|
|
136
|
+
}
|
|
137
|
+
const names = new Set(command.commands.map((each) => each.name));
|
|
138
|
+
return args.find((arg) => names.has(arg)) ?? command.name;
|
|
139
|
+
}
|
|
140
|
+
// [function]
|
|
130
141
|
// runs the command's flow, and ends as it says: with its exit code, or by
|
|
131
142
|
// the one error path.
|
|
132
143
|
async function run({ command, heading, parsed }) {
|
|
@@ -148,8 +159,7 @@ async function run({ command, heading, parsed }) {
|
|
|
148
159
|
// runs a top-level command with `args`, the arguments after its name.
|
|
149
160
|
// `--help`, `--version`, and an argument error end inside the parser.
|
|
150
161
|
export async function execute(command, args) {
|
|
151
|
-
|
|
152
|
-
const conf = await findRc(TOOL, command.name, args);
|
|
162
|
+
const conf = await findRc(TOOL, section(command, args), args);
|
|
153
163
|
const matches = [];
|
|
154
164
|
const parsed = await parser(command, args, conf, (match) => {
|
|
155
165
|
matches.push(match);
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
// arc function: a game's function, the server code Arcadible runs
|
|
2
|
-
// paused and resumed on a channel by the game's owner, with no
|
|
3
|
-
// its secrets (./secret/index.ts).
|
|
4
|
-
// until functions ship, with the docs.
|
|
1
|
+
// arc unstable function: a game's function, the server code Arcadible runs
|
|
2
|
+
// for it: paused and resumed on a channel by the game's owner, with no
|
|
3
|
+
// release, its logs, and its secrets (./secret/index.ts). Under
|
|
4
|
+
// `arc unstable` until functions ship, with the docs.
|
|
5
5
|
// [import]
|
|
6
6
|
import { defineCommand } from "../../cli/command.js";
|
|
7
7
|
import secret from "./secret/index.js";
|
|
8
8
|
import pause from "./pause.js";
|
|
9
9
|
import resume from "./resume.js";
|
|
10
10
|
import status from "./status.js";
|
|
11
|
+
import logs from "./logs.js";
|
|
11
12
|
// [export]
|
|
12
13
|
export default defineCommand({
|
|
13
|
-
commands: [pause, resume, status, secret],
|
|
14
|
-
hidden: true,
|
|
14
|
+
commands: [pause, resume, status, logs, secret],
|
|
15
15
|
name: "function",
|
|
16
|
-
summary: "Pause, resume, and show the game's function, and its secrets",
|
|
16
|
+
summary: "Pause, resume, and show the game's function, its logs, and its secrets",
|
|
17
17
|
});
|