arcadible 1.0.49 → 1.0.50
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 +5 -1
- package/dist/action/deploy/result.js +3 -3
- package/dist/action/deploy/tool-git.js +1 -1
- package/dist/action/deploy/tool.js +1 -1
- package/dist/action/deploy/wait.js +1 -1
- package/dist/action/function/logs.js +4 -4
- package/dist/action/function/tool.js +11 -10
- package/dist/action/key/tool.js +10 -4
- package/dist/action/secret/tool.js +2 -1
- package/dist/action/validate/unknown.js +1 -1
- package/dist/action/value/local.js +78 -0
- package/dist/action/value/tool.js +65 -27
- package/dist/action/wire/tool.js +1 -1
- package/dist/cli/command.js +13 -1
- package/dist/cli/options.js +7 -0
- package/dist/cli/prompt.js +1 -1
- package/dist/command/deploy/report.js +5 -5
- package/dist/command/function/index.js +2 -3
- package/dist/command/function/logs.js +4 -4
- 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/list.js +2 -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 +11 -11
- package/dist/command/game/delete.js +2 -2
- package/dist/command/game/index.js +2 -2
- package/dist/command/open.js +1 -1
- package/dist/command/play.js +1 -1
- package/dist/command/server/index.js +3 -3
- package/dist/command/server/key/create.js +4 -4
- package/dist/command/server/key/index.js +1 -1
- package/dist/command/server/key/list.js +3 -2
- package/dist/command/server/key/revoke.js +1 -1
- package/dist/command/server/key/run.js +1 -1
- package/dist/command/unstable/index.js +8 -13
- package/dist/command/value/get.js +12 -8
- package/dist/command/value/index.js +4 -4
- package/dist/command/value/list.js +14 -6
- package/dist/command/value/remove.js +22 -11
- package/dist/command/value/run.js +40 -0
- package/dist/command/value/set.js +27 -22
- package/dist/command/value/usage.js +34 -30
- package/dist/command/wire/index.js +1 -2
- package/dist/commands.js +28 -0
- package/dist/config/code.js +4 -2
- package/dist/config/limit.js +5 -5
- package/dist/config/retry.js +2 -0
- package/dist/parser/project.js +2 -1
- package/dist/phrase/common.js +12 -6
- package/dist/phrase/deploy.js +4 -3
- package/dist/phrase/function.js +27 -21
- package/dist/phrase/game.js +3 -3
- package/dist/phrase/pack.js +4 -1
- package/dist/phrase/serve.js +2 -2
- package/dist/phrase/server.js +10 -5
- package/dist/phrase/value.js +50 -16
- package/dist/schema/client.js +11 -6
- package/dist/serve/values.js +2 -2
- package/dist/util/output.js +11 -4
- package/dist/util/schema.js +5 -3
- package/dist/util/time.js +5 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -53,7 +53,11 @@ Your repository is the store page: `arcadible.toml` holds the game's settings, `
|
|
|
53
53
|
| `arc login` | Logs in to Arcadible with a device code |
|
|
54
54
|
| `arc logout` | Logs out |
|
|
55
55
|
| `arc whoami` | Shows the account you're logged in to |
|
|
56
|
-
| `arc
|
|
56
|
+
| `arc game` | Deletes the project's game on Arcadible |
|
|
57
|
+
| `arc function` | Pauses, resumes, and shows your game's function, its logs, and its secrets |
|
|
58
|
+
| `arc server` | Makes, lists, and revokes your server's keys |
|
|
59
|
+
| `arc value` | Sets, gets, lists, and removes the values you publish for your game |
|
|
60
|
+
| `arc wire` | Shows what your game's wires carried |
|
|
57
61
|
|
|
58
62
|
Run `arc <command> --help` for its options, or see the [CLI reference](https://developer.arcadible.com/references/arcadible-cli).
|
|
59
63
|
|
|
@@ -6,14 +6,14 @@ import { published } from "../../util/links.js";
|
|
|
6
6
|
// release, so the game's links are by id.
|
|
7
7
|
export function resultOf(deployed, { built, git, held, warnings, }) {
|
|
8
8
|
const { channel, store, url } = held
|
|
9
|
-
? published({ id: deployed.game, version: deployed.version
|
|
9
|
+
? published({ id: deployed.game, version: deployed.version })
|
|
10
10
|
: deployed;
|
|
11
11
|
return {
|
|
12
12
|
...(git ? {} : { built }),
|
|
13
13
|
channel,
|
|
14
|
-
|
|
14
|
+
play_url: url,
|
|
15
|
+
store_url: store,
|
|
15
16
|
...("tag" in deployed ? { tag: deployed.tag } : {}),
|
|
16
|
-
url,
|
|
17
17
|
version: deployed.version,
|
|
18
18
|
warnings,
|
|
19
19
|
};
|
|
@@ -101,7 +101,7 @@ function pollRelease(find, timeout, onRelease) {
|
|
|
101
101
|
export function wait(current, deployed, { git: isGit, root, since, timeout }, { onRelease } = {}) {
|
|
102
102
|
const game = deployed.game;
|
|
103
103
|
const find = isGit || !("release" in deployed)
|
|
104
|
-
? findGit({ game, since, version: deployed.version
|
|
104
|
+
? findGit({ game, since, version: deployed.version })
|
|
105
105
|
: findDirect(deployed.release, current);
|
|
106
106
|
return Promise.all([
|
|
107
107
|
pollRelease(find, timeout, onRelease),
|
|
@@ -54,7 +54,7 @@ export function sinceOf(text, now = Date.now()) {
|
|
|
54
54
|
}
|
|
55
55
|
// [function]
|
|
56
56
|
// the query a page or a follow asks with.
|
|
57
|
-
function queryOf({
|
|
57
|
+
function queryOf({ failed, since, version }, channel) {
|
|
58
58
|
const query = new URLSearchParams();
|
|
59
59
|
if (channel)
|
|
60
60
|
query.set("channel", channel);
|
|
@@ -66,7 +66,7 @@ function queryOf({ errors, since, version }, channel) {
|
|
|
66
66
|
}
|
|
67
67
|
if (since)
|
|
68
68
|
query.set("since", sinceOf(since));
|
|
69
|
-
if (
|
|
69
|
+
if (failed)
|
|
70
70
|
query.set("outcome", "error");
|
|
71
71
|
return query;
|
|
72
72
|
}
|
|
@@ -81,7 +81,7 @@ function isPage(value) {
|
|
|
81
81
|
function isEntry(value) {
|
|
82
82
|
return (isTable(value) &&
|
|
83
83
|
typeof value["id"] === "number" &&
|
|
84
|
-
typeof value["at"] === "
|
|
84
|
+
typeof value["at"] === "string");
|
|
85
85
|
}
|
|
86
86
|
// [function]
|
|
87
87
|
// the Worker's refusal as the CLI's failure, read as the API's is (codeOf):
|
|
@@ -132,7 +132,7 @@ function toldInText(text) {
|
|
|
132
132
|
}
|
|
133
133
|
// [function]
|
|
134
134
|
// a token for the game's logs: the game is the caller's, or
|
|
135
|
-
// game_not_found, as for the rest of `arc
|
|
135
|
+
// game_not_found, as for the rest of `arc function`.
|
|
136
136
|
async function tokenOf(id, headers) {
|
|
137
137
|
try {
|
|
138
138
|
return await postGameFunctionLogsToken(id, null, headers);
|
|
@@ -6,6 +6,7 @@ import { deleteGameFunctionPause, discoverGameBuilds, gameFunctionPauses, gameFu
|
|
|
6
6
|
import { FUNCTION_PAUSE_NOT_OWNED, GAME_NOT_FOUND } from "../../config/code.js";
|
|
7
7
|
import { ArcError } from "../../util/error.js";
|
|
8
8
|
import { channelOf, CHANNELS, gameOf, headersOf, isRefused, REFUSED, needOf, ownedRead, } from "../game.js";
|
|
9
|
+
import { iso } from "../../util/time.js";
|
|
9
10
|
import { functionPauseNotOwned, gameNotOwned } from "../../phrase/index.js";
|
|
10
11
|
// [declare]
|
|
11
12
|
// the reasons a function is paused for, the one that holds longest first:
|
|
@@ -23,7 +24,7 @@ function pausedOf(pauses, channel) {
|
|
|
23
24
|
// [function]
|
|
24
25
|
// when a channel's pause for a limit ends by itself, or null for none.
|
|
25
26
|
function resumesOf(pauses, channel) {
|
|
26
|
-
return ((pauses ?? []).find((pause) => pause.channel === channel && pause.reason === "limit")?.resumes_at
|
|
27
|
+
return iso((pauses ?? []).find((pause) => pause.channel === channel && pause.reason === "limit")?.resumes_at);
|
|
27
28
|
}
|
|
28
29
|
// [function]
|
|
29
30
|
// whether a channel's live build has a function: true, false, or null when
|
|
@@ -122,6 +123,13 @@ export async function status(current, { channel, ...conf }) {
|
|
|
122
123
|
// null is no limit, and stays null
|
|
123
124
|
const limit = (value) => value === null ? null : Number(value);
|
|
124
125
|
return {
|
|
126
|
+
account: first
|
|
127
|
+
? {
|
|
128
|
+
allowance: limit(first.pool_allowance),
|
|
129
|
+
cpu_ms: Number(first.pool_cpu_ms ?? 0),
|
|
130
|
+
requests: Number(first.pool_used),
|
|
131
|
+
}
|
|
132
|
+
: null,
|
|
125
133
|
channels: shown.map((each, i) => {
|
|
126
134
|
const own = rows.filter((row) => row.channel === each);
|
|
127
135
|
return {
|
|
@@ -133,21 +141,14 @@ export async function status(current, { channel, ...conf }) {
|
|
|
133
141
|
resumes_at: resumesOf(pauses, each),
|
|
134
142
|
};
|
|
135
143
|
}),
|
|
136
|
-
day: first
|
|
137
|
-
? { allowance: limit(first.allowance), requests: Number(first.used) }
|
|
138
|
-
: null,
|
|
139
144
|
month: first
|
|
140
145
|
? {
|
|
141
146
|
cpu_ms: Number(first.month_cpu_ms ?? 0),
|
|
142
147
|
requests: Number(first.month_used),
|
|
143
148
|
}
|
|
144
149
|
: null,
|
|
145
|
-
|
|
146
|
-
? {
|
|
147
|
-
allowance: limit(first.pool_allowance),
|
|
148
|
-
cpu_ms: Number(first.pool_cpu_ms ?? 0),
|
|
149
|
-
requests: Number(first.pool_used),
|
|
150
|
-
}
|
|
150
|
+
today: first
|
|
151
|
+
? { allowance: limit(first.allowance), requests: Number(first.used) }
|
|
151
152
|
: null,
|
|
152
153
|
};
|
|
153
154
|
}
|
package/dist/action/key/tool.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// is for one game and one channel, made by the game's owner, shown once, and
|
|
3
3
|
// revoked at once. Nothing here keeps one.
|
|
4
4
|
import { deleteKey, gameKeys, postGameKey, } from "../../api.js";
|
|
5
|
-
import { ARGUMENT_INVALID, GAME_NOT_FOUND, KEY_QUOTA_FULL, KEY_NOT_FOUND, } from "../../config/code.js";
|
|
5
|
+
import { ARGUMENT_INVALID, GAME_NOT_FOUND, KEY_CREATE_RATE_LIMITED, KEY_QUOTA_FULL, KEY_NOT_FOUND, } from "../../config/code.js";
|
|
6
6
|
import { ArcError } from "../../util/error.js";
|
|
7
7
|
import { channelOf, gameOf, headersOf, isRefused, REFUSED, needOf, ownedRead, } from "../game.js";
|
|
8
|
-
import {
|
|
8
|
+
import { iso } from "../../util/time.js";
|
|
9
|
+
import { gameNotOwned, keyCreateRateLimited, keyQuotaFull, keyNameInvalid, keyNotFound, } from "../../phrase/index.js";
|
|
9
10
|
// [declare]
|
|
10
11
|
const NAME_MAX = 64;
|
|
11
12
|
// the name a key gets when none is given.
|
|
@@ -45,6 +46,11 @@ export async function create(current, { channel, name, ...conf }) {
|
|
|
45
46
|
cause: err,
|
|
46
47
|
});
|
|
47
48
|
}
|
|
49
|
+
if (isRefused(err, KEY_CREATE_RATE_LIMITED)) {
|
|
50
|
+
throw new ArcError(KEY_CREATE_RATE_LIMITED, keyCreateRateLimited(), {
|
|
51
|
+
cause: err,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
48
54
|
throw err;
|
|
49
55
|
}
|
|
50
56
|
}
|
|
@@ -60,11 +66,11 @@ export async function list(current, { channel, ...conf }) {
|
|
|
60
66
|
.filter((key) => !where || key.channel === where)
|
|
61
67
|
.map((key) => ({
|
|
62
68
|
channel: key.channel,
|
|
63
|
-
created_at: key.created_at,
|
|
69
|
+
created_at: iso(key.created_at),
|
|
64
70
|
id: key.id,
|
|
65
71
|
name: key.name,
|
|
66
72
|
shown: key.shown,
|
|
67
|
-
used_at: key.used_at,
|
|
73
|
+
used_at: iso(key.used_at),
|
|
68
74
|
}));
|
|
69
75
|
}
|
|
70
76
|
// [function]
|
|
@@ -7,6 +7,7 @@ import { ARGUMENT_INVALID, GAME_NOT_FOUND, SECRET_QUOTA_FULL, SECRET_NOT_FOUND,
|
|
|
7
7
|
import { SECRET_NAME } from "../../config/limit.js";
|
|
8
8
|
import { ArcError } from "../../util/error.js";
|
|
9
9
|
import { channelOf, gameOf, headersOf, isRefused, REFUSED, needOf, ownedRead, } from "../game.js";
|
|
10
|
+
import { iso } from "../../util/time.js";
|
|
10
11
|
import { gameNotOwned, secretQuotaFull, secretNameInvalid, secretNotFound, secretTooLarge, secretValueInvalid, } from "../../phrase/index.js";
|
|
11
12
|
// [declare]
|
|
12
13
|
const VALUE_MAX = 4096;
|
|
@@ -66,7 +67,7 @@ export async function list(current, { channel, ...conf }) {
|
|
|
66
67
|
.map((secret) => ({
|
|
67
68
|
channel: secret.channel,
|
|
68
69
|
name: secret.name,
|
|
69
|
-
updated_at: secret.updated_at,
|
|
70
|
+
updated_at: iso(secret.updated_at),
|
|
70
71
|
}));
|
|
71
72
|
}
|
|
72
73
|
// [function]
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// the developer's values in the project's own folder, `.arcadible-data/values/`,
|
|
2
|
+
// a file a value, its path its key: the local channel `arc serve` reads,
|
|
3
|
+
// which `arc value` works on when it's given no channel (cli:13a). Nothing
|
|
4
|
+
// is asked of Arcadible, and no login is needed. `set` makes the folders
|
|
5
|
+
// it needs, as the command that first needs a folder makes it (DEVELOPING.md).
|
|
6
|
+
// [import]
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { VALUE_NOT_FOUND } from "../../config/code.js";
|
|
10
|
+
import { ArcError } from "../../util/error.js";
|
|
11
|
+
import { DEVELOPER_DIR, developerRows } from "../../serve/values.js";
|
|
12
|
+
import { valueNotFound } from "../../phrase/index.js";
|
|
13
|
+
import { keyOf } from "./tool.js";
|
|
14
|
+
// [declare]
|
|
15
|
+
// the channel the local values are, as `arc serve` names it.
|
|
16
|
+
export const LOCAL = "local";
|
|
17
|
+
// [function]
|
|
18
|
+
// the project's values folder.
|
|
19
|
+
function dirOf(root) {
|
|
20
|
+
return path.join(root, DEVELOPER_DIR);
|
|
21
|
+
}
|
|
22
|
+
// [function]
|
|
23
|
+
// a key's file in the folder: daily/2026-11-12 is daily/2026-11-12.json.
|
|
24
|
+
function fileOf(root, key) {
|
|
25
|
+
return path.join(dirOf(root), ...key.split("/")) + ".json";
|
|
26
|
+
}
|
|
27
|
+
// [function]
|
|
28
|
+
// a value, as `arc serve` reads it, or not found.
|
|
29
|
+
function rowOf(root, key) {
|
|
30
|
+
const row = developerRows(dirOf(root)).get(key);
|
|
31
|
+
if (!row) {
|
|
32
|
+
throw new ArcError(VALUE_NOT_FOUND, valueNotFound({ channel: LOCAL, key }));
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
key: row.key,
|
|
36
|
+
revision: row.revision,
|
|
37
|
+
updated_at: row.updated_at,
|
|
38
|
+
value: row.value,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// [function]
|
|
42
|
+
// writes a value to its file, making the folders it needs, as JSON a
|
|
43
|
+
// person reads, and resolves with its key.
|
|
44
|
+
export function setLocal(root, key, value) {
|
|
45
|
+
const named = keyOf(key);
|
|
46
|
+
const file = fileOf(root, named);
|
|
47
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
48
|
+
fs.writeFileSync(file, `${JSON.stringify(value, null, 2)}\n`);
|
|
49
|
+
return { channel: LOCAL, keys: [named] };
|
|
50
|
+
}
|
|
51
|
+
// [function]
|
|
52
|
+
// a value, with its revision (when its file was last written) and when.
|
|
53
|
+
export function getLocal(root, key) {
|
|
54
|
+
return { channel: LOCAL, ...rowOf(root, keyOf(key)) };
|
|
55
|
+
}
|
|
56
|
+
// [function]
|
|
57
|
+
// every key that starts with `prefix`, in order, with its size and when it
|
|
58
|
+
// was set, never its value.
|
|
59
|
+
export function listLocal(root, prefix = "") {
|
|
60
|
+
return [...developerRows(dirOf(root)).values()]
|
|
61
|
+
.filter((row) => row.key.startsWith(prefix))
|
|
62
|
+
.sort((a, b) => Buffer.compare(Buffer.from(a.key), Buffer.from(b.key)))
|
|
63
|
+
.map(({ key, revision, size, updated_at: updated }) => ({
|
|
64
|
+
key,
|
|
65
|
+
revision,
|
|
66
|
+
size,
|
|
67
|
+
updated_at: updated,
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
// [function]
|
|
71
|
+
// removes a value's file, and resolves with its key; one that isn't there
|
|
72
|
+
// is not found. A folder it leaves empty stays.
|
|
73
|
+
export function removeLocal(root, key) {
|
|
74
|
+
const named = keyOf(key);
|
|
75
|
+
rowOf(root, named);
|
|
76
|
+
fs.rmSync(fileOf(root, named));
|
|
77
|
+
return { channel: LOCAL, keys: [named] };
|
|
78
|
+
}
|
|
@@ -10,7 +10,9 @@ import { ARGUMENT_INVALID, GAME_NOT_FOUND, LIMIT_REACHED, PARSE_FAILED, PATH_NOT
|
|
|
10
10
|
import { ArcError } from "../../util/error.js";
|
|
11
11
|
import { HttpError } from "../../util/http.js";
|
|
12
12
|
import { gameOf, headersOf, isRefused, needOf, REFUSED } from "../game.js";
|
|
13
|
-
import {
|
|
13
|
+
import { DEVELOPER_DIR } from "../../serve/values.js";
|
|
14
|
+
import { iso } from "../../util/time.js";
|
|
15
|
+
import { gameNotOwned, valueCallsSpent, valueDirEmpty, valueFileUnread, valueFull, valueHolds, valueKeyInvalid, valueNotFound, valueNotJson, valueSetTwice, valueSetWhat, valueTooLarge, } from "../../phrase/index.js";
|
|
14
16
|
// [declare]
|
|
15
17
|
// a key, as Arcadible takes one (db/function/game_value.sql, value_keys).
|
|
16
18
|
export const KEY = /^[A-Za-z0-9_./-]{1,128}$/u;
|
|
@@ -23,7 +25,7 @@ const PAGE = 100;
|
|
|
23
25
|
const FILE = ".json";
|
|
24
26
|
// [function]
|
|
25
27
|
// a key as it was given, or a refusal before the API is asked.
|
|
26
|
-
function keyOf(key) {
|
|
28
|
+
export function keyOf(key) {
|
|
27
29
|
if (typeof key !== "string" || !KEY.test(key)) {
|
|
28
30
|
throw new ArcError(ARGUMENT_INVALID, valueKeyInvalid(String(key)));
|
|
29
31
|
}
|
|
@@ -31,7 +33,7 @@ function keyOf(key) {
|
|
|
31
33
|
}
|
|
32
34
|
// [function]
|
|
33
35
|
// a value from its JSON text; `source` names where the text is from.
|
|
34
|
-
function parsed(text, source) {
|
|
36
|
+
export function parsed(text, source) {
|
|
35
37
|
try {
|
|
36
38
|
return JSON.parse(text);
|
|
37
39
|
}
|
|
@@ -49,15 +51,17 @@ function fileOf(file) {
|
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
// [function]
|
|
52
|
-
//
|
|
53
|
-
// (daily/2026-11-12.json is daily/2026-11-12), in key order.
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
// the project's values: each .json file under its folder, its path its key
|
|
55
|
+
// (daily/2026-11-12.json is daily/2026-11-12), in key order. A folder
|
|
56
|
+
// that isn't there holds none.
|
|
57
|
+
function folderOf(root) {
|
|
58
|
+
const dir = path.join(root, DEVELOPER_DIR);
|
|
59
|
+
let names = [];
|
|
56
60
|
try {
|
|
57
61
|
names = fs.readdirSync(dir, { recursive: true });
|
|
58
62
|
}
|
|
59
|
-
catch
|
|
60
|
-
|
|
63
|
+
catch {
|
|
64
|
+
// none yet
|
|
61
65
|
}
|
|
62
66
|
const items = names
|
|
63
67
|
.filter((name) => name.endsWith(FILE))
|
|
@@ -69,7 +73,7 @@ function folderOf(dir) {
|
|
|
69
73
|
})
|
|
70
74
|
.sort((a, b) => (a.key < b.key ? -1 : 1));
|
|
71
75
|
if (items.length === 0) {
|
|
72
|
-
throw new ArcError(ARGUMENT_INVALID, valueDirEmpty(
|
|
76
|
+
throw new ArcError(ARGUMENT_INVALID, valueDirEmpty());
|
|
73
77
|
}
|
|
74
78
|
return items;
|
|
75
79
|
}
|
|
@@ -97,12 +101,24 @@ function batches(items) {
|
|
|
97
101
|
return all;
|
|
98
102
|
}
|
|
99
103
|
// [function]
|
|
104
|
+
// a scope as the API states it, as `usage` says it.
|
|
105
|
+
function scopeOf(row) {
|
|
106
|
+
return {
|
|
107
|
+
bytes: row.bytes,
|
|
108
|
+
keys: row.keys,
|
|
109
|
+
limit: { bytes: row.bytes_limit, keys: row.keys_limit },
|
|
110
|
+
owner_max: { bytes: row.bytes_most, keys: row.keys_most },
|
|
111
|
+
owners: row.owners,
|
|
112
|
+
scope: row.scope,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
// [function]
|
|
100
116
|
// what the developer's values on `channel` may hold, as the API states it
|
|
101
117
|
// for the account's plan, or null when it can't be had.
|
|
102
118
|
async function holds(id, channel, headers) {
|
|
103
119
|
const scopes = await gameValueUsages(id, channel, headers).catch(() => null);
|
|
104
120
|
const mine = scopes?.find((each) => each.scope === "developer" && each.channel === channel);
|
|
105
|
-
return mine ? valueHolds(mine) : null;
|
|
121
|
+
return mine ? valueHolds(scopeOf(mine).limit) : null;
|
|
106
122
|
}
|
|
107
123
|
// [function]
|
|
108
124
|
// the API's refusals, said for a developer's values: a game that isn't the
|
|
@@ -126,26 +142,38 @@ function refused(id, channel, headers) {
|
|
|
126
142
|
};
|
|
127
143
|
}
|
|
128
144
|
// [function]
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
145
|
+
// a value to set, from where it was given: the command line, a file, or
|
|
146
|
+
// standard input, one of them.
|
|
147
|
+
export async function valueOf(root, { file, input, value }) {
|
|
148
|
+
if (value !== undefined && file !== undefined) {
|
|
149
|
+
throw new ArcError(ARGUMENT_INVALID, valueSetTwice());
|
|
150
|
+
}
|
|
151
|
+
if (value !== undefined) {
|
|
152
|
+
return parsed(value, "the command line");
|
|
153
|
+
}
|
|
154
|
+
if (file !== undefined) {
|
|
155
|
+
return parsed(fileOf(path.resolve(root, file)), file);
|
|
156
|
+
}
|
|
157
|
+
return parsed(await input(), "standard input");
|
|
158
|
+
}
|
|
159
|
+
// [function]
|
|
160
|
+
// sets one value, or, with no key, every value in the project's folder
|
|
161
|
+
// (DEVELOPER_DIR), in batches: each batch is written whole or not at all,
|
|
162
|
+
// and a failure says which key it stopped at. Resolves with the keys set.
|
|
163
|
+
export async function set(current, { channel, file, input, key, value, ...conf }) {
|
|
164
|
+
if (key === undefined && (value !== undefined || file !== undefined)) {
|
|
134
165
|
throw new ArcError(ARGUMENT_INVALID, valueSetWhat());
|
|
135
166
|
}
|
|
136
|
-
const named =
|
|
167
|
+
const named = key === undefined ? null : keyOf(key);
|
|
137
168
|
const where = needOf(channel);
|
|
138
169
|
const id = await gameOf(conf);
|
|
139
170
|
const headers = headersOf(current);
|
|
140
|
-
const at = (given) => path.resolve(conf.root, given);
|
|
141
171
|
const items = named === null
|
|
142
|
-
? folderOf(
|
|
172
|
+
? folderOf(conf.root)
|
|
143
173
|
: [
|
|
144
174
|
{
|
|
145
175
|
key: named,
|
|
146
|
-
value: file
|
|
147
|
-
? parsed(await input(), "standard input")
|
|
148
|
-
: parsed(fileOf(at(file)), file),
|
|
176
|
+
value: await valueOf(conf.root, { file, input, value }),
|
|
149
177
|
},
|
|
150
178
|
];
|
|
151
179
|
for (const batch of batches(items)) {
|
|
@@ -174,7 +202,7 @@ export async function get(current, { channel, key, ...conf }) {
|
|
|
174
202
|
if (!value) {
|
|
175
203
|
throw new ArcError(VALUE_NOT_FOUND, valueNotFound({ channel: where, key: named }));
|
|
176
204
|
}
|
|
177
|
-
return { channel: where, ...value };
|
|
205
|
+
return { channel: where, ...value, updated_at: iso(value.updated_at) };
|
|
178
206
|
}
|
|
179
207
|
// [function]
|
|
180
208
|
// every key that starts with `prefix`, in order, each with its size and when
|
|
@@ -190,7 +218,10 @@ export async function list(current, { channel, prefix = "", ...conf }) {
|
|
|
190
218
|
let after = "";
|
|
191
219
|
for (;;) {
|
|
192
220
|
const page = await gameValuesList(id, where, { after, limit: PAGE, prefix }, headers).catch(refused(id, where, headers));
|
|
193
|
-
all.push(...page.entries)
|
|
221
|
+
all.push(...page.entries.map((entry) => ({
|
|
222
|
+
...entry,
|
|
223
|
+
updated_at: iso(entry.updated_at),
|
|
224
|
+
})));
|
|
194
225
|
if (page.next === null) {
|
|
195
226
|
return all;
|
|
196
227
|
}
|
|
@@ -222,9 +253,16 @@ export async function usage(current, { channel, ...conf }) {
|
|
|
222
253
|
const id = await gameOf(conf);
|
|
223
254
|
const headers = headersOf(current);
|
|
224
255
|
const scopes = (await gameValueUsages(id, where, headers).catch(refused(id, where, headers))) ?? [];
|
|
225
|
-
const
|
|
256
|
+
const all = await gameValueCalls(id, headers).catch(() => null);
|
|
257
|
+
const calls = all?.find((each) => each.channel === where) ?? null;
|
|
226
258
|
return {
|
|
227
|
-
|
|
228
|
-
|
|
259
|
+
account: calls
|
|
260
|
+
? { allowance: calls.pool_allowance, calls: calls.pool_used }
|
|
261
|
+
: null,
|
|
262
|
+
channel: where,
|
|
263
|
+
channel_today: calls ? { reads: calls.reads, writes: calls.writes } : null,
|
|
264
|
+
month: calls ? { calls: calls.month_used } : null,
|
|
265
|
+
scopes: scopes.map(scopeOf),
|
|
266
|
+
today: calls ? { allowance: calls.allowance, calls: calls.used } : null,
|
|
229
267
|
};
|
|
230
268
|
}
|
package/dist/action/wire/tool.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// arc
|
|
1
|
+
// arc 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/cli/command.js
CHANGED
|
@@ -105,7 +105,19 @@ function withCommands(cli, family, conf, matched) {
|
|
|
105
105
|
});
|
|
106
106
|
});
|
|
107
107
|
}, cli);
|
|
108
|
-
|
|
108
|
+
// a family with no commands, as `arc unstable` is between them, takes
|
|
109
|
+
// nothing: yargs knows no command to call another unknown, so it's said
|
|
110
|
+
// here, as yargs says it
|
|
111
|
+
const demanded = family.commands.length > 0
|
|
112
|
+
? added.demandCommand(1)
|
|
113
|
+
: added.demandCommand(1).check((argv) => {
|
|
114
|
+
const given = argv._.map(String);
|
|
115
|
+
const extra = given.slice(given.indexOf(family.name) + 1);
|
|
116
|
+
if (extra.length > 0) {
|
|
117
|
+
throw new Error(`Unknown argument: ${extra.join(", ")}`);
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
});
|
|
109
121
|
return family.epilogue ? demanded.epilogue(family.epilogue) : demanded;
|
|
110
122
|
}
|
|
111
123
|
// [function]
|
package/dist/cli/options.js
CHANGED
|
@@ -54,6 +54,13 @@ export const CHANNEL = {
|
|
|
54
54
|
staging: { describe: "On staging", type: "boolean" },
|
|
55
55
|
};
|
|
56
56
|
// [declare]
|
|
57
|
+
// the pair for `arc value`'s commands, which, given neither, work on the
|
|
58
|
+
// project's own values, the local channel `arc serve` reads (cli:13a).
|
|
59
|
+
export const CHANNEL_VALUES = {
|
|
60
|
+
production: { describe: "On Arcadible's production", type: "boolean" },
|
|
61
|
+
staging: { describe: "On Arcadible's staging", type: "boolean" },
|
|
62
|
+
};
|
|
63
|
+
// [declare]
|
|
57
64
|
// the pair for a command that only shows, which takes one, or neither for
|
|
58
65
|
// both.
|
|
59
66
|
export const CHANNEL_SHOWS = {
|
package/dist/cli/prompt.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// the three questions arc asks at a terminal, on `node:readline`: a yes or
|
|
2
2
|
// no (./confirm.ts), `arc init`'s choice of a starter, and a secret typed
|
|
3
|
-
// unseen (`arc
|
|
3
|
+
// unseen (`arc function secret set`). Each is asked only where
|
|
4
4
|
// there's a terminal; a caller without one never gets here. Ctrl+C ends a
|
|
5
5
|
// question with `Cancelled`, which the one error path ends as 130
|
|
6
6
|
// (./command.ts). No test has a terminal, so each is tried by hand before a
|
|
@@ -54,20 +54,20 @@ export function handler({ json, pb, quiet, sw, warnings, }) {
|
|
|
54
54
|
// what was deployed, whether workflow.build ran, where it will be once it's
|
|
55
55
|
// published (the store only shows production), and what happens next. Once
|
|
56
56
|
// waited on, it's published, so it says so.
|
|
57
|
-
export function report({ built, channel, store, tag,
|
|
57
|
+
export function report({ built, channel, play_url: play, store_url: store, tag, version }, { git, published }) {
|
|
58
58
|
let heading = git
|
|
59
59
|
? tagPushed(String(tag))
|
|
60
|
-
: buildSubmitted(version
|
|
60
|
+
: buildSubmitted(version, channel, built);
|
|
61
61
|
let next = git
|
|
62
62
|
? buildPublishingGit(channel)
|
|
63
63
|
: buildPublishing();
|
|
64
64
|
if (published) {
|
|
65
|
-
heading = releasePublished(version
|
|
65
|
+
heading = releasePublished(version, channel, built);
|
|
66
66
|
next = null;
|
|
67
67
|
}
|
|
68
68
|
logResult(heading, [
|
|
69
69
|
store ? [storeLabel(), store] : null,
|
|
70
|
-
[playLabel(),
|
|
70
|
+
[playLabel(), play],
|
|
71
71
|
next,
|
|
72
72
|
]);
|
|
73
73
|
}
|
|
@@ -100,7 +100,7 @@ export async function waitAndReport(current, deployed, result, { git, json, quie
|
|
|
100
100
|
const data = { ...result, release: releaseJson(waited.release) };
|
|
101
101
|
if (waited.timedOut) {
|
|
102
102
|
const found = Boolean(waited.release);
|
|
103
|
-
const reason = releaseTimedOut(result.version
|
|
103
|
+
const reason = releaseTimedOut(result.version, timeout, {
|
|
104
104
|
actions,
|
|
105
105
|
found,
|
|
106
106
|
git,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// arc
|
|
1
|
+
// arc function: a game's function, the server code Arcadible runs
|
|
2
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).
|
|
4
|
-
// `arc unstable` until functions ship, with the docs.
|
|
3
|
+
// release, its logs, and its secrets (./secret/index.ts).
|
|
5
4
|
// [import]
|
|
6
5
|
import { defineCommand } from "../../cli/command.js";
|
|
7
6
|
import secret from "./secret/index.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// arc
|
|
1
|
+
// arc function logs: what the game's function said, as Arcadible keeps it,
|
|
2
2
|
// for its owner (plan/FUNCTION-LOGS.md, Reading them): the newest 100
|
|
3
3
|
// requests, oldest first, as `tail` prints, or those and then each as it
|
|
4
4
|
// comes, with `--follow`. With `--json`, an entry a line, as the logs
|
|
@@ -105,7 +105,7 @@ export default defineCommand({
|
|
|
105
105
|
describe: "From a time: 10m, 2h, 1d, or an ISO time",
|
|
106
106
|
type: "string",
|
|
107
107
|
},
|
|
108
|
-
|
|
108
|
+
failed: {
|
|
109
109
|
describe: "Only the requests that failed",
|
|
110
110
|
type: "boolean",
|
|
111
111
|
},
|
|
@@ -131,7 +131,7 @@ export default defineCommand({
|
|
|
131
131
|
sw.stop(true);
|
|
132
132
|
const conf = {
|
|
133
133
|
channel: where,
|
|
134
|
-
|
|
134
|
+
failed: argv.failed,
|
|
135
135
|
root: resolvePath(process.cwd(), argv.cwd),
|
|
136
136
|
since: argv.since,
|
|
137
137
|
version: argv.release,
|
|
@@ -153,7 +153,7 @@ export default defineCommand({
|
|
|
153
153
|
show(entry, json);
|
|
154
154
|
if (!entries.length && !json) {
|
|
155
155
|
p(functionLogsNone({
|
|
156
|
-
filtered: Boolean(where || argv.release || argv.since || argv.
|
|
156
|
+
filtered: Boolean(where || argv.release || argv.since || argv.failed),
|
|
157
157
|
}));
|
|
158
158
|
}
|
|
159
159
|
},
|
|
@@ -12,7 +12,7 @@ export default defineCommand({
|
|
|
12
12
|
run(argv, aborting) {
|
|
13
13
|
return run(argv, aborting, pause, (paused) => {
|
|
14
14
|
p(functionPaused(paused));
|
|
15
|
-
}, "arc
|
|
15
|
+
}, "arc function pause");
|
|
16
16
|
},
|
|
17
17
|
summary: "Pause the game's function on a channel",
|
|
18
18
|
});
|
|
@@ -12,7 +12,7 @@ export default defineCommand({
|
|
|
12
12
|
run(argv, aborting) {
|
|
13
13
|
return run(argv, aborting, resume, (resumed) => {
|
|
14
14
|
p(functionResumed(resumed));
|
|
15
|
-
}, "arc
|
|
15
|
+
}, "arc function resume");
|
|
16
16
|
},
|
|
17
17
|
summary: "Resume the game's function on a channel",
|
|
18
18
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// arc
|
|
1
|
+
// arc function secret: a function's secrets, the values a game's function
|
|
2
2
|
// needs and its repository mustn't hold. `set` takes the value from standard
|
|
3
3
|
// input, or asks for it at a terminal, so it's never an argument, in a
|
|
4
4
|
// shell's history or a process list.
|
|
@@ -19,7 +19,8 @@ export default defineCommand({
|
|
|
19
19
|
name: "list",
|
|
20
20
|
options: { ...CHANNEL_SHOWS, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
|
|
21
21
|
run(argv, aborting) {
|
|
22
|
-
|
|
22
|
+
// an object, not a bare list, so it can gain a field (OUTPUT.md)
|
|
23
|
+
return run(argv, aborting, async (current, conf) => ({ secrets: await list(current, conf) }), ({ secrets }) => {
|
|
23
24
|
p(secrets.length ? rows(secrets) : secretNone());
|
|
24
25
|
});
|
|
25
26
|
},
|