arcadible 1.0.41 → 1.0.43

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.
Files changed (44) hide show
  1. package/dist/action/delete/tool.js +2 -2
  2. package/dist/action/deploy/tool.js +5 -5
  3. package/dist/action/function/logs.js +100 -30
  4. package/dist/action/function/tool.js +10 -8
  5. package/dist/action/game.js +15 -3
  6. package/dist/action/init/tool.js +26 -4
  7. package/dist/action/key/tool.js +21 -12
  8. package/dist/action/pack/tool.js +2 -2
  9. package/dist/action/predeploy/ac.js +4 -4
  10. package/dist/action/secret/tool.js +11 -9
  11. package/dist/action/serve/tool.js +3 -3
  12. package/dist/action/value/tool.js +14 -8
  13. package/dist/action/wire/tool.js +2 -2
  14. package/dist/api.js +2 -2
  15. package/dist/command/init.js +2 -2
  16. package/dist/command/open.js +1 -1
  17. package/dist/command/play.js +1 -1
  18. package/dist/config/code.js +29 -24
  19. package/dist/config/retry.js +105 -0
  20. package/dist/phrase/common.js +5 -2
  21. package/dist/phrase/deploy.js +2 -2
  22. package/dist/phrase/function.js +3 -3
  23. package/dist/phrase/game.js +1 -1
  24. package/dist/phrase/init.js +7 -1
  25. package/dist/phrase/pack.js +6 -1
  26. package/dist/phrase/server.js +1 -1
  27. package/dist/phrase/value.js +6 -0
  28. package/dist/runner/bundle.js +2 -2
  29. package/dist/runner/outbound.js +2 -0
  30. package/dist/schema/game.js +1 -1
  31. package/dist/serve/message.js +79 -0
  32. package/dist/serve/page.js +70 -60
  33. package/dist/serve/retry.js +4 -8
  34. package/dist/serve/runner.js +15 -6
  35. package/dist/serve/ticket.js +5 -5
  36. package/dist/serve/wires.js +10 -6
  37. package/dist/util/error.js +28 -8
  38. package/dist/util/http.js +6 -2
  39. package/dist/util/output.js +54 -16
  40. package/dist/util/request.js +2 -1
  41. package/dist/util/s3.js +1 -1
  42. package/dist/wires/room.js +30 -37
  43. package/npm-shrinkwrap.json +67 -67
  44. package/package.json +2 -2
@@ -6,10 +6,11 @@
6
6
  import fs from "node:fs";
7
7
  import path from "node:path";
8
8
  import { gameValuesList, gameValuesRead, gameValuesRemove, gameValuesWrite, gameValueCalls, gameValueUsages, } from "../../api.js";
9
- import { ARGUMENT_INVALID, GAME_UNAVAILABLE, VALUE_NOT_FOUND, VALUE_STORAGE_FULL, VALUE_TOO_LARGE, } from "../../config/code.js";
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
+ import { HttpError } from "../../util/http.js";
11
12
  import { gameOf, headersOf, isStatus, needOf } from "../game.js";
12
- import { gameNotOwned, valueDirEmpty, valueFileUnread, valueFull, valueHolds, valueKeyInvalid, valueNotFound, valueNotJson, valueSetWhat, valueTooLarge, } from "../../phrase/index.js";
13
+ import { gameNotOwned, valueCallsSpent, valueDirEmpty, valueFileUnread, valueFull, valueHolds, valueKeyInvalid, valueNotFound, valueNotJson, valueSetWhat, valueTooLarge, } from "../../phrase/index.js";
13
14
  // [declare]
14
15
  // a key, as Arcadible takes one (db/function/game_value.sql, value_keys).
15
16
  export const KEY = /^[A-Za-z0-9_./-]{1,128}$/u;
@@ -35,7 +36,7 @@ function parsed(text, source) {
35
36
  return JSON.parse(text);
36
37
  }
37
38
  catch (err) {
38
- throw new ArcError(ARGUMENT_INVALID, valueNotJson(source), { cause: err });
39
+ throw new ArcError(PARSE_FAILED, valueNotJson(source), { cause: err });
39
40
  }
40
41
  }
41
42
  // [function]
@@ -44,7 +45,7 @@ function fileOf(file) {
44
45
  return fs.readFileSync(file, "utf8");
45
46
  }
46
47
  catch (err) {
47
- throw new ArcError(ARGUMENT_INVALID, valueFileUnread(file), { cause: err });
48
+ throw new ArcError(PATH_NOT_FOUND, valueFileUnread(file), { cause: err });
48
49
  }
49
50
  }
50
51
  // [function]
@@ -56,7 +57,7 @@ function folderOf(dir) {
56
57
  names = fs.readdirSync(dir, { recursive: true });
57
58
  }
58
59
  catch (err) {
59
- throw new ArcError(ARGUMENT_INVALID, valueFileUnread(dir), { cause: err });
60
+ throw new ArcError(PATH_NOT_FOUND, valueFileUnread(dir), { cause: err });
60
61
  }
61
62
  const items = names
62
63
  .filter((name) => name.endsWith(FILE))
@@ -105,16 +106,21 @@ async function holds(id, channel, headers) {
105
106
  }
106
107
  // [function]
107
108
  // the API's refusals, said for a developer's values: a game that isn't the
108
- // caller's, and a scope that's full, with what it may hold.
109
+ // caller's, a scope that's full, with what it may hold, and the game's
110
+ // calls for the day, or its account's for the month, spent (a `429` that
111
+ // says `limit_reached`, never a minute's).
109
112
  function refused(id, channel, headers) {
110
113
  return async (err) => {
111
114
  if (isStatus(err, 404)) {
112
- throw new ArcError(GAME_UNAVAILABLE, gameNotOwned(id), {
115
+ throw new ArcError(GAME_NOT_FOUND, gameNotOwned(id), {
113
116
  cause: err,
114
117
  });
115
118
  }
116
119
  if (isStatus(err, 507)) {
117
- throw new ArcError(VALUE_STORAGE_FULL, valueFull(channel, await holds(id, channel, headers)), { cause: err });
120
+ throw new ArcError(VALUE_STORAGE_QUOTA_FULL, valueFull(channel, await holds(id, channel, headers)), { cause: err });
121
+ }
122
+ if (err instanceof HttpError && err.code === LIMIT_REACHED) {
123
+ throw new ArcError(LIMIT_REACHED, valueCallsSpent(), { cause: err });
118
124
  }
119
125
  throw err;
120
126
  };
@@ -2,7 +2,7 @@
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";
5
- import { GAME_UNAVAILABLE } from "../../config/code.js";
5
+ import { GAME_NOT_FOUND } from "../../config/code.js";
6
6
  import { ArcError } from "../../util/error.js";
7
7
  import { channelOf, CHANNELS, gameOf, headersOf, } from "../game.js";
8
8
  import { gameNotOwned } from "../../phrase/index.js";
@@ -16,7 +16,7 @@ export async function usage(current, { channel, ...conf }) {
16
16
  // its owner always reads today's row for each channel: no rows at all is
17
17
  // a game that isn't the caller's
18
18
  if (rows.length === 0) {
19
- throw new ArcError(GAME_UNAVAILABLE, gameNotOwned(id));
19
+ throw new ArcError(GAME_NOT_FOUND, gameNotOwned(id));
20
20
  }
21
21
  const today = new Date().toISOString().slice(0, 10);
22
22
  const sum = (of) => ({
package/dist/api.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // [import]
2
- import { INTERNAL } from "./config/code.js";
2
+ import { UNEXPECTED } from "./config/code.js";
3
3
  import { ArcError } from "./util/error.js";
4
4
  import { answerUnread } from "./phrase/index.js";
5
5
  import { del, get, post, postJson, put } from "./util/request.js";
@@ -144,7 +144,7 @@ const isUsage = shaped({
144
144
  function answer(is, what, data) {
145
145
  return data.then((value) => {
146
146
  if (!is(value)) {
147
- throw new ArcError(INTERNAL, answerUnread(what));
147
+ throw new ArcError(UNEXPECTED, answerUnread(what));
148
148
  }
149
149
  return value;
150
150
  });
@@ -3,7 +3,7 @@ import { resolve } from "node:path";
3
3
  // [import]
4
4
  import fs from "fs-extra";
5
5
  // [import]
6
- import { TEMPLATE_MISSING } from "../config/code.js";
6
+ import { ARGUMENT_INVALID } from "../config/code.js";
7
7
  import { defineCommand } from "../cli/command.js";
8
8
  import { ArcError } from "../util/error.js";
9
9
  import { initialized, initializedNoStarter, templateMissing, } from "../phrase/index.js";
@@ -39,7 +39,7 @@ async function prompt({ cwd, project, template, yes, }) {
39
39
  if (!template) {
40
40
  // without a terminal, the prompt would read end-of-input and exit.
41
41
  if (!process.stdin.isTTY) {
42
- throw new ArcError(TEMPLATE_MISSING, templateMissing());
42
+ throw new ArcError(ARGUMENT_INVALID, templateMissing());
43
43
  }
44
44
  const answer = await select({
45
45
  choices,
@@ -30,7 +30,7 @@ export default defineCommand({
30
30
  root: resolve(process.cwd(), argv.cwd),
31
31
  });
32
32
  if (!data) {
33
- throw new ArcError(GAME_ID_MISSING, gameIdMissing());
33
+ throw new ArcError(GAME_ID_MISSING, gameIdMissing(true));
34
34
  }
35
35
  const { page, url } = data;
36
36
  const where = await (argv.browser
@@ -59,7 +59,7 @@ export default defineCommand({
59
59
  const orientation = data?.orientation;
60
60
  const url = data?.url;
61
61
  if (!data || !orientation || !url) {
62
- throw new ArcError(GAME_ID_MISSING, gameIdMissing());
62
+ throw new ArcError(GAME_ID_MISSING, gameIdMissing(true));
63
63
  }
64
64
  sw.stop(true);
65
65
  if (data.fallback && !argv.json && !argv.quiet) {
@@ -11,11 +11,13 @@ const CLI = {
11
11
  BUILD_FAILED: "build_failed",
12
12
  DEPLOY_DIR_MISSING: "deploy_dir_missing",
13
13
  DEPLOY_RATE_LIMITED: "deploy_rate_limited",
14
- FUNCTION_PAUSE_RESERVED: "function_pause_reserved",
14
+ FUNCTION_LOGS_FOLLOWS_FULL: "function_logs_follows_full",
15
+ FUNCTION_MAIN_MISSING: "function_main_missing",
16
+ FUNCTION_NOT_BUILT: "function_not_built",
17
+ FUNCTION_PAUSE_NOT_OWNED: "function_pause_not_owned",
15
18
  GAME_HANDLE_TAKEN: "game_handle_taken",
16
19
  GAME_ID_MISSING: "game_id_missing",
17
20
  GAME_NOT_DEPLOYED: "game_not_deployed",
18
- GAME_NOT_FOUND: "game_not_found",
19
21
  GIT_REMOTE_MISSING: "git_remote_missing",
20
22
  GIT_REMOTE_UNREACHABLE: "git_remote_unreachable",
21
23
  GIT_REPO_MISSING: "git_repo_missing",
@@ -23,55 +25,61 @@ const CLI = {
23
25
  GIT_TAG_EXISTS: "git_tag_exists",
24
26
  GIT_TAG_PUSH_FAILED: "git_tag_push_failed",
25
27
  GIT_UNCOMMITTED: "git_uncommitted",
26
- KEY_LIMIT_REACHED: "key_limit_reached",
27
28
  KEY_NOT_FOUND: "key_not_found",
29
+ KEY_QUOTA_FULL: "key_quota_full",
30
+ LIMIT_REACHED: "limit_reached",
28
31
  LOCKFILE_MISSING: "lockfile_missing",
29
32
  LOGIN_CODE_EXPIRED: "login_code_expired",
30
33
  LOGIN_FAILED: "login_failed",
31
34
  MANIFEST_MISSING: "manifest_missing",
32
35
  NOT_LOGGED_IN: "not_logged_in",
33
- PACKAGE_FILE_TOO_LARGE: "package_file_too_large",
34
36
  PACKAGE_INDEX_MISSING: "package_index_missing",
35
37
  PACKAGE_LINK_INVALID: "package_link_invalid",
36
- PACKAGE_PATH_RESERVED: "package_path_reserved",
37
38
  PACKAGE_TOO_LARGE: "package_too_large",
38
- PACKAGE_TOO_MANY_FILES: "package_too_many_files",
39
- PACKAGE_UNCOMPRESSED_TOO_LARGE: "package_uncompressed_too_large",
40
39
  PARSE_FAILED: "parse_failed",
41
40
  PATH_NOT_FOUND: "path_not_found",
42
41
  PORT_IN_USE: "port_in_use",
43
42
  PROJECT_NOT_REPO_ROOT: "project_not_repo_root",
44
- SECRET_LIMIT_REACHED: "secret_limit_reached",
45
43
  SECRET_NOT_FOUND: "secret_not_found",
44
+ SECRET_QUOTA_FULL: "secret_quota_full",
45
+ SECRET_TOO_LARGE: "secret_too_large",
46
46
  SESSION_EXPIRED: "session_expired",
47
- TEMPLATE_MISSING: "template_missing",
48
- TEMPLATE_UNAVAILABLE: "template_unavailable",
47
+ TEMPLATE_NOT_FOUND: "template_not_found",
48
+ UNAVAILABLE: "unavailable",
49
49
  UNEXPECTED: "unexpected",
50
50
  UPLOAD_FAILED: "upload_failed",
51
51
  VALIDATION_FAILED: "validation_failed",
52
52
  VALUE_NOT_FOUND: "value_not_found",
53
- VALUE_STORAGE_FULL: "value_storage_full",
53
+ VALUE_STORAGE_QUOTA_FULL: "value_storage_quota_full",
54
54
  VALUE_TOO_LARGE: "value_too_large",
55
55
  WAIT_TIMED_OUT: "wait_timed_out",
56
56
  };
57
57
  // a release's reasons, from the pipeline (the API's
58
58
  // db/type/release_reason.sql). The CLI shares them, so a name means the same
59
59
  // thing wherever it appears: FUNCTION_TOO_LARGE, GAME_HANDLE_CHANGED,
60
- // GAME_UNAVAILABLE, INTERNAL, PACKAGE_PATH_INVALID, as well as
60
+ // GAME_NOT_FOUND, INTERNAL, the PACKAGE_ codes here, as well as
61
61
  // REPO_NOT_CONNECTED and VERSION_EXISTS, are the CLI's too.
62
62
  export const RELEASE = {
63
+ ACCOUNT_NOT_FOUND: "account_not_found",
64
+ BUILD_NOT_PUBLISHED: "build_not_published",
63
65
  BUILD_RATE_LIMITED: "build_rate_limited",
64
66
  FUNCTION_INVALID: "function_invalid",
65
67
  FUNCTION_TOO_LARGE: "function_too_large",
66
68
  GAME_HANDLE_CHANGED: "game_handle_changed",
67
- GAME_LIMIT_REACHED: "game_limit_reached",
68
69
  GAME_MISMATCH: "game_mismatch",
69
- GAME_UNAVAILABLE: "game_unavailable",
70
+ GAME_NOT_FOUND: "game_not_found",
71
+ GAME_QUOTA_FULL: "game_quota_full",
72
+ GIT_RELEASE_NOT_FOUND: "git_release_not_found",
70
73
  GITHUB_APP_NOT_INSTALLED: "github_app_not_installed",
71
74
  INTERNAL: "internal",
72
75
  MANIFEST_INVALID: "manifest_invalid",
76
+ MANIFEST_TOO_LARGE: "manifest_too_large",
77
+ PACKAGE_FILE_TOO_LARGE: "package_file_too_large",
73
78
  PACKAGE_PATH_INVALID: "package_path_invalid",
74
- RELEASE_EXPIRED: "release_expired",
79
+ PACKAGE_PATH_RESERVED: "package_path_reserved",
80
+ PACKAGE_TOO_MANY_FILES: "package_too_many_files",
81
+ PACKAGE_UNCOMPRESSED_TOO_LARGE: "package_uncompressed_too_large",
82
+ RELEASE_TIMED_OUT: "release_timed_out",
75
83
  REPO_NOT_CONNECTED: "repo_not_connected",
76
84
  SERVERS_CHANGED: "servers_changed",
77
85
  VERSION_EXISTS: "version_exists",
@@ -85,6 +93,7 @@ export const RELEASE = {
85
93
  // checks for workflow_missing before it pushes.
86
94
  export const GITHUB = {
87
95
  GIT_TAG_INVALID: "git_tag_invalid",
96
+ GITHUB_APP_NOT_CONNECTED: "github_app_not_connected",
88
97
  WORKFLOW_MISSING: "workflow_missing",
89
98
  };
90
99
  // an `arc validate` issue's codes, named for the rule it breaks; the field
@@ -95,10 +104,6 @@ export const ISSUE = {
95
104
  DESCRIPTION_RULES_MISSING: "description_rules_missing",
96
105
  DUPLICATE: "duplicate",
97
106
  EMPTY: "empty",
98
- // no longer used: arc validate checked deploy_dir for an index.html before
99
- // 1.0.37, which packing checks now (package_index_missing). Kept, as
100
- // every code is.
101
- INDEX_MISSING: "index_missing",
102
107
  INVALID: "invalid",
103
108
  MARKDOWN_INVALID: "markdown_invalid",
104
109
  MEDIA_INVALID: "media_invalid",
@@ -106,7 +111,7 @@ export const ISSUE = {
106
111
  OUT_OF_RANGE: "out_of_range",
107
112
  PATH_INVALID: "path_invalid",
108
113
  REQUIRED: "required",
109
- SCREENSHOT_NUMBER_REPEATED: "screenshot_number_repeated",
114
+ SCREENSHOT_NUMBER_DUPLICATE: "screenshot_number_duplicate",
110
115
  TOO_LONG: "too_long",
111
116
  TOO_MANY: "too_many",
112
117
  TOO_SHORT: "too_short",
@@ -125,7 +130,7 @@ export const WARNING = {
125
130
  FIELD_UNSET: "field_unset",
126
131
  FUNCTION_IMPORT_WRONG: "function_import_wrong",
127
132
  GAME_HANDLE_LAPSED: "game_handle_lapsed",
128
- GAME_HANDLE_LIMIT_REACHED: "game_handle_limit_reached",
133
+ GAME_HANDLE_QUOTA_FULL: "game_handle_quota_full",
129
134
  PACKAGE_FILE_DEV: "package_file_dev",
130
135
  PACKAGE_FILE_PRIVATE: "package_file_private",
131
136
  SCREENSHOT_NAME_INVALID: "screenshot_name_invalid",
@@ -145,6 +150,6 @@ export const ISSUES = new Set(Object.values(ISSUE));
145
150
  export const WARNINGS = new Set(Object.values(WARNING));
146
151
  // [declare]
147
152
  // each error code by its own name too: `cfgcode.NOT_LOGGED_IN`.
148
- export const { API_REFUSED, API_UNREACHABLE, ARGUMENT_INVALID, BUILD_FAILED, DEPLOY_DIR_MISSING, DEPLOY_RATE_LIMITED, FUNCTION_PAUSE_RESERVED, GAME_HANDLE_TAKEN, GAME_ID_MISSING, GAME_NOT_DEPLOYED, GAME_NOT_FOUND, GIT_REMOTE_MISSING, GIT_REMOTE_UNREACHABLE, GIT_REPO_MISSING, GIT_TAG_CREATE_FAILED, GIT_TAG_EXISTS, GIT_TAG_PUSH_FAILED, GIT_UNCOMMITTED, KEY_LIMIT_REACHED, KEY_NOT_FOUND, LOCKFILE_MISSING, LOGIN_CODE_EXPIRED, LOGIN_FAILED, MANIFEST_MISSING, NOT_LOGGED_IN, PACKAGE_FILE_TOO_LARGE, PACKAGE_INDEX_MISSING, PACKAGE_LINK_INVALID, PACKAGE_PATH_RESERVED, PACKAGE_TOO_LARGE, PACKAGE_TOO_MANY_FILES, PACKAGE_UNCOMPRESSED_TOO_LARGE, PARSE_FAILED, PATH_NOT_FOUND, PORT_IN_USE, PROJECT_NOT_REPO_ROOT, SECRET_LIMIT_REACHED, SECRET_NOT_FOUND, SESSION_EXPIRED, TEMPLATE_MISSING, TEMPLATE_UNAVAILABLE, UNEXPECTED, UPLOAD_FAILED, VALIDATION_FAILED, VALUE_NOT_FOUND, VALUE_STORAGE_FULL, VALUE_TOO_LARGE, WAIT_TIMED_OUT, } = CLI;
149
- export const { BUILD_RATE_LIMITED, FUNCTION_INVALID, FUNCTION_TOO_LARGE, GAME_HANDLE_CHANGED, GAME_LIMIT_REACHED, GAME_MISMATCH, GAME_UNAVAILABLE, GITHUB_APP_NOT_INSTALLED, INTERNAL, MANIFEST_INVALID, PACKAGE_PATH_INVALID, RELEASE_EXPIRED, REPO_NOT_CONNECTED, VERSION_EXISTS, VERSION_MISMATCH, ZIP_INVALID, ZIP_MISSING, ZIP_TOO_LARGE, } = RELEASE;
150
- export const { GIT_TAG_INVALID, WORKFLOW_MISSING } = GITHUB;
153
+ export const { API_REFUSED, API_UNREACHABLE, ARGUMENT_INVALID, BUILD_FAILED, DEPLOY_DIR_MISSING, DEPLOY_RATE_LIMITED, FUNCTION_LOGS_FOLLOWS_FULL, FUNCTION_MAIN_MISSING, FUNCTION_NOT_BUILT, FUNCTION_PAUSE_NOT_OWNED, GAME_HANDLE_TAKEN, GAME_ID_MISSING, GAME_NOT_DEPLOYED, GIT_REMOTE_MISSING, GIT_REMOTE_UNREACHABLE, GIT_REPO_MISSING, GIT_TAG_CREATE_FAILED, GIT_TAG_EXISTS, GIT_TAG_PUSH_FAILED, GIT_UNCOMMITTED, KEY_NOT_FOUND, KEY_QUOTA_FULL, LIMIT_REACHED, LOCKFILE_MISSING, LOGIN_CODE_EXPIRED, LOGIN_FAILED, MANIFEST_MISSING, NOT_LOGGED_IN, PACKAGE_INDEX_MISSING, PACKAGE_LINK_INVALID, PACKAGE_TOO_LARGE, PARSE_FAILED, PATH_NOT_FOUND, PORT_IN_USE, PROJECT_NOT_REPO_ROOT, SECRET_NOT_FOUND, SECRET_QUOTA_FULL, SECRET_TOO_LARGE, SESSION_EXPIRED, TEMPLATE_NOT_FOUND, UNAVAILABLE, UNEXPECTED, UPLOAD_FAILED, VALIDATION_FAILED, VALUE_NOT_FOUND, VALUE_STORAGE_QUOTA_FULL, VALUE_TOO_LARGE, WAIT_TIMED_OUT, } = CLI;
154
+ export const { ACCOUNT_NOT_FOUND, BUILD_NOT_PUBLISHED, BUILD_RATE_LIMITED, FUNCTION_INVALID, FUNCTION_TOO_LARGE, GAME_HANDLE_CHANGED, GAME_MISMATCH, GAME_NOT_FOUND, GAME_QUOTA_FULL, GIT_RELEASE_NOT_FOUND, GITHUB_APP_NOT_INSTALLED, INTERNAL, MANIFEST_INVALID, MANIFEST_TOO_LARGE, PACKAGE_FILE_TOO_LARGE, PACKAGE_PATH_INVALID, PACKAGE_PATH_RESERVED, PACKAGE_TOO_MANY_FILES, PACKAGE_UNCOMPRESSED_TOO_LARGE, RELEASE_TIMED_OUT, REPO_NOT_CONNECTED, VERSION_EXISTS, VERSION_MISMATCH, ZIP_INVALID, ZIP_MISSING, ZIP_TOO_LARGE, } = RELEASE;
155
+ export const { GIT_TAG_INVALID, GITHUB_APP_NOT_CONNECTED, WORKFLOW_MISSING } = GITHUB;
@@ -0,0 +1,105 @@
1
+ // whether to try again, for each code a failure can have (ERRORS.md,
2
+ // Rules): `yes`, the same command after a moment; `later`, the same
3
+ // command once something outside it changes (a window renews, one is
4
+ // freed, you log in, a repository is connected); `no`, not as it is: the
5
+ // command, or the project it reads, has to change. It's `error.retry` with
6
+ // `--json`, so a script or an agent has its next step without knowing the
7
+ // code. A release's reasons are ERRORS.md's, held to its table
8
+ // (test/docs/retry.test.js).
9
+ // [import]
10
+ import * as code from "./code.js";
11
+ // [declare]
12
+ export const RETRY = {
13
+ // the CLI's own
14
+ [code.API_REFUSED]: "no",
15
+ [code.API_UNREACHABLE]: "yes",
16
+ [code.ARGUMENT_INVALID]: "no",
17
+ [code.BUILD_FAILED]: "no",
18
+ [code.DEPLOY_DIR_MISSING]: "no",
19
+ [code.DEPLOY_RATE_LIMITED]: "later",
20
+ [code.FUNCTION_LOGS_FOLLOWS_FULL]: "later",
21
+ [code.FUNCTION_MAIN_MISSING]: "no",
22
+ [code.FUNCTION_NOT_BUILT]: "no",
23
+ [code.FUNCTION_PAUSE_NOT_OWNED]: "no",
24
+ [code.GAME_HANDLE_TAKEN]: "no",
25
+ [code.GAME_ID_MISSING]: "no",
26
+ [code.GAME_NOT_DEPLOYED]: "later",
27
+ [code.GAME_NOT_FOUND]: "no",
28
+ [code.GIT_REMOTE_MISSING]: "no",
29
+ [code.GIT_REMOTE_UNREACHABLE]: "yes",
30
+ [code.GIT_REPO_MISSING]: "no",
31
+ [code.GIT_TAG_CREATE_FAILED]: "no",
32
+ [code.GIT_TAG_EXISTS]: "no",
33
+ [code.GIT_TAG_PUSH_FAILED]: "no",
34
+ [code.GIT_UNCOMMITTED]: "no",
35
+ [code.KEY_NOT_FOUND]: "no",
36
+ [code.KEY_QUOTA_FULL]: "later",
37
+ [code.LIMIT_REACHED]: "later",
38
+ [code.LOCKFILE_MISSING]: "no",
39
+ [code.LOGIN_CODE_EXPIRED]: "later",
40
+ [code.LOGIN_FAILED]: "yes",
41
+ [code.MANIFEST_MISSING]: "no",
42
+ [code.NOT_LOGGED_IN]: "later",
43
+ [code.PACKAGE_INDEX_MISSING]: "no",
44
+ [code.PACKAGE_LINK_INVALID]: "no",
45
+ [code.PACKAGE_TOO_LARGE]: "no",
46
+ [code.PARSE_FAILED]: "no",
47
+ [code.PATH_NOT_FOUND]: "no",
48
+ [code.PORT_IN_USE]: "later",
49
+ [code.PROJECT_NOT_REPO_ROOT]: "no",
50
+ [code.SECRET_NOT_FOUND]: "no",
51
+ [code.SECRET_QUOTA_FULL]: "later",
52
+ [code.SECRET_TOO_LARGE]: "no",
53
+ [code.SESSION_EXPIRED]: "later",
54
+ [code.TEMPLATE_NOT_FOUND]: "no",
55
+ [code.UNAVAILABLE]: "yes",
56
+ [code.UNEXPECTED]: "no",
57
+ [code.UPLOAD_FAILED]: "later",
58
+ [code.VALIDATION_FAILED]: "no",
59
+ [code.VALUE_NOT_FOUND]: "no",
60
+ [code.VALUE_STORAGE_QUOTA_FULL]: "later",
61
+ [code.VALUE_TOO_LARGE]: "no",
62
+ [code.WAIT_TIMED_OUT]: "later",
63
+ // a release's reasons
64
+ [code.ACCOUNT_NOT_FOUND]: "no",
65
+ [code.BUILD_NOT_PUBLISHED]: "no",
66
+ [code.BUILD_RATE_LIMITED]: "later",
67
+ [code.FUNCTION_INVALID]: "no",
68
+ [code.FUNCTION_TOO_LARGE]: "no",
69
+ [code.GAME_HANDLE_CHANGED]: "no",
70
+ [code.GAME_MISMATCH]: "no",
71
+ [code.GAME_QUOTA_FULL]: "later",
72
+ [code.GIT_RELEASE_NOT_FOUND]: "no",
73
+ [code.GITHUB_APP_NOT_INSTALLED]: "later",
74
+ [code.INTERNAL]: "yes",
75
+ [code.MANIFEST_INVALID]: "no",
76
+ [code.MANIFEST_TOO_LARGE]: "no",
77
+ [code.PACKAGE_FILE_TOO_LARGE]: "no",
78
+ [code.PACKAGE_PATH_INVALID]: "no",
79
+ [code.PACKAGE_PATH_RESERVED]: "no",
80
+ [code.PACKAGE_TOO_MANY_FILES]: "no",
81
+ [code.PACKAGE_UNCOMPRESSED_TOO_LARGE]: "no",
82
+ [code.RELEASE_TIMED_OUT]: "yes",
83
+ [code.REPO_NOT_CONNECTED]: "later",
84
+ [code.RELEASE.SERVERS_CHANGED]: "no",
85
+ [code.VERSION_EXISTS]: "no",
86
+ [code.VERSION_MISMATCH]: "no",
87
+ [code.ZIP_INVALID]: "no",
88
+ [code.ZIP_MISSING]: "no",
89
+ [code.ZIP_TOO_LARGE]: "no",
90
+ // the GitHub check's own
91
+ [code.GIT_TAG_INVALID]: "no",
92
+ [code.GITHUB_APP_NOT_CONNECTED]: "later",
93
+ [code.WORKFLOW_MISSING]: "no",
94
+ };
95
+ // [function]
96
+ // whether a word is one of the three.
97
+ export function isRetry(said) {
98
+ return said === "yes" || said === "later" || said === "no";
99
+ }
100
+ // [function]
101
+ // a code's retry: its own, or `no` for one this CLI doesn't know (a
102
+ // release's reason the API added since), which is a failure as it stands.
103
+ export function retryOf(shown) {
104
+ return RETRY[shown] ?? "no";
105
+ }
@@ -81,8 +81,11 @@ export function httpError(name, status, detail) {
81
81
  return detail ? `${head}: ${detail}` : `${head}.`;
82
82
  }
83
83
  // [function]
84
- export function gameIdMissing() {
85
- return blocks("No game handle or ID.", `Pass one, or run it in a project after ${cmdInit()} has added an ID.`);
84
+ // no game: a command that takes one (`arc play`, `arc open`) says to pass
85
+ // it; the rest read only the project's id, so they say where to run.
86
+ export function gameIdMissing(passable = false) {
87
+ const where = `in a project after ${cmdInit()} has added an ID.`;
88
+ return blocks("No game handle or ID.", passable ? `Pass one, or run it ${where}` : `Run it ${where}`);
86
89
  }
87
90
  // [function]
88
91
  export function noProductionRelease() {
@@ -62,8 +62,8 @@ export function repoNotConnected(game, repo, url) {
62
62
  return blocks(`${repo} isn't ${game}'s repository on ${TITLE}.`, [`Connect it on the game's Repository tab in ${TITLE} Studio:`, url], "If it was renamed on GitHub, connect it again.");
63
63
  }
64
64
  // [function]
65
- export function gameUnavailable(id) {
66
- return blocks(`Game unavailable: ${id}\nIt was deleted, or belongs to another account.`, "Give game.id a new UUID to deploy it as a new game.");
65
+ export function gameDeletedOrNotOwned(id) {
66
+ return blocks(`Game not found: ${id}\nIt was deleted, or belongs to another account.`, "Give game.id a new UUID to deploy it as a new game.");
67
67
  }
68
68
  // [function]
69
69
  export function gitUncommitted() {
@@ -94,7 +94,7 @@ export function cpuTime(ms) {
94
94
  // [function]
95
95
  // a resume with no pause of the owner's to lift, and one of another's: who
96
96
  // lifts it.
97
- export function functionPauseReserved({ channel, paused, }) {
97
+ export function functionPauseNotOwned({ channel, paused, }) {
98
98
  if (paused === "arcadible") {
99
99
  return blocks(`The game's function is paused by Arcadible on ${channel}.`, "Only Arcadible can resume it.");
100
100
  }
@@ -123,7 +123,7 @@ export function secretNone() {
123
123
  }
124
124
  // [function]
125
125
  // the most secrets a game has for a channel, when one more is asked for.
126
- export function secretLimitReached(channel) {
126
+ export function secretQuotaFull(channel) {
127
127
  return blocks(`Sixteen secrets already for ${channel}.`, "Remove one with `arc unstable function secret remove <name>`, then try again.");
128
128
  }
129
129
  // [function]
@@ -199,7 +199,7 @@ export function functionLogsVersionInvalid(text) {
199
199
  }
200
200
  // [function]
201
201
  // a sixth follow of a game's logs, while five are open.
202
- export function functionLogsBusy() {
202
+ export function functionLogsFull() {
203
203
  return blocks("The game's logs are followed five times already.", "Stop one of them, then try again.");
204
204
  }
205
205
  // [function]
@@ -25,5 +25,5 @@ export function gameDeletedProject() {
25
25
  // that isn't on Arcadible, one that's deleted already, and another account's
26
26
  // are the same.
27
27
  export function gameNotOwned(id) {
28
- return blocks(`Game unavailable: ${id}\nIt was never deployed, was deleted, or belongs to another account.`, `${cmdWhoami()} shows the account you're logged in to.`);
28
+ return blocks(`Game not found: ${id}\nIt was never deployed, was deleted, or belongs to another account.`, `${cmdWhoami()} shows the account you're logged in to.`);
29
29
  }
@@ -45,8 +45,14 @@ export function starterThreeJs() {
45
45
  return "Three.js starter.";
46
46
  }
47
47
  // [function]
48
+ // a template's download that got no response: offline, or GitHub not
49
+ // reached.
50
+ export function templateUnreachable(template) {
51
+ return blocks(`Unable to reach GitHub to download template ${template}.`, "Check your internet connection, and try again.");
52
+ }
53
+ // [function]
48
54
  // `starter` is the starter its name suggests.
49
- export function templateUnavailable(template, starter) {
55
+ export function templateNotFound(template, starter) {
50
56
  return blocks(`Unable to download template ${template}.`, starter
51
57
  ? `Did you mean: ${starter}?`
52
58
  : "Check that it's a public GitHub repository, or a folder in one.");
@@ -1,7 +1,7 @@
1
1
  // arc build and arc pack: the build, and the package's limits.
2
2
  // [import]
3
3
  import { MEDIA } from "../config/file.js";
4
- import { blocks, cmdBuild, tail } from "./internal.js";
4
+ import { blocks, cmdBuild, cmdValidate, tail } from "./internal.js";
5
5
  import { handle, title } from "../config/product.js";
6
6
  // [declare]
7
7
  const HANDLE = handle;
@@ -48,6 +48,11 @@ export function deployDirMissing(dir) {
48
48
  return blocks(`Unable to find deploy_dir: ${dir}`, `Run ${cmdBuild()}, or set deploy_dir to the folder your build writes.`);
49
49
  }
50
50
  // [function]
51
+ // arc serve's deploy_dir that isn't text, which it reads without validating.
52
+ export function deployDirNotPath(dir) {
53
+ return blocks(`deploy_dir isn't a folder's path: ${dir}`, `Run ${cmdValidate()} to check arcadible.toml.`);
54
+ }
55
+ // [function]
51
56
  export function packed() {
52
57
  return "Packed.";
53
58
  }
@@ -16,7 +16,7 @@ export function keyNone() {
16
16
  }
17
17
  // [function]
18
18
  // the most keys a game has for a channel, when one more is asked for.
19
- export function keyLimitReached(channel) {
19
+ export function keyQuotaFull(channel) {
20
20
  return blocks(`Five keys already for ${channel}.`, "Revoke one with `arc unstable server key revoke <id>`, then try again.");
21
21
  }
22
22
  // [function]
@@ -47,6 +47,12 @@ export function valueHolds({ bytes_limit: bytes, keys_limit: keys, }) {
47
47
  return `${keys === null ? "any number of" : keys.toLocaleString("en-US")} keys, ${bytes === null ? "any size" : valueSize(bytes)}`;
48
48
  }
49
49
  // [function]
50
+ // the game's calls to its values spent: its own for the day, or its
51
+ // account's for the month, as the API doesn't say which.
52
+ export function valueCallsSpent() {
53
+ return blocks("The game's calls to its values are spent for the day, or its account's for the month.", "Writes and removes go on when the day or the month turns (UTC). Reads still work.");
54
+ }
55
+ // [function]
50
56
  // the developer's values on `channel` full, with what they may hold, the
51
57
  // account's plan's, when the API could say.
52
58
  export function valueFull(channel, holds) {
@@ -11,7 +11,7 @@ import { join, resolve } from "node:path";
11
11
  import { build } from "esbuild";
12
12
  import { pathExists } from "fs-extra";
13
13
  // [import]
14
- import { BUILD_FAILED, FUNCTION_TOO_LARGE } from "../config/code.js";
14
+ import { BUILD_FAILED, FUNCTION_MAIN_MISSING, FUNCTION_TOO_LARGE, } from "../config/code.js";
15
15
  import { FUNCTION_SIZE } from "../config/limit.js";
16
16
  import * as phrase from "../phrase/index.js";
17
17
  import { ArcError } from "../util/error.js";
@@ -44,7 +44,7 @@ export const WRONG = {
44
44
  // changes, wherever it is (a game's rules its function shares).
45
45
  export async function bundle({ main, onInputs, onPackages, outfile, }) {
46
46
  if (!(await pathExists(main))) {
47
- throw new ArcError(BUILD_FAILED, phrase.runnerMissing(main));
47
+ throw new ArcError(FUNCTION_MAIN_MISSING, phrase.runnerMissing(main));
48
48
  }
49
49
  let inputs;
50
50
  try {
@@ -53,6 +53,8 @@ export function refuse(url) {
53
53
  message: arcadible
54
54
  ? `The function may not call ${host} itself. Arcadible is reached through the Function SDK (@arcadible/function-sdk), which needs no host declared.`
55
55
  : `The function may not call ${host}. To allow it, add it to function.outbound_hosts in arcadible.toml, as a name reached over HTTPS.`,
56
+ // not as it is: the build's hosts don't change (ERRORS.md, The shape)
57
+ retry: "no",
56
58
  }, { status: STATUS });
57
59
  }
58
60
  // [function]
@@ -322,7 +322,7 @@ function zGallery(root) {
322
322
  for (const group of repeated(files)) {
323
323
  ctx.addIssue({
324
324
  code: "custom",
325
- ...message(field, screenshotNumberRepeated(group), ISSUE.SCREENSHOT_NUMBER_REPEATED),
325
+ ...message(field, screenshotNumberRepeated(group), ISSUE.SCREENSHOT_NUMBER_DUPLICATE),
326
326
  });
327
327
  }
328
328
  }));
@@ -0,0 +1,79 @@
1
+ // What each of `arc serve`'s refusals says to a person, beside its code and
2
+ // retry, as Arcadible's own part says it (ERRORS.md, The shape): the
3
+ // dispatcher's words for the function's, the wires' Worker's for a wire's,
4
+ // and the API's for the page's own API and the server API, which the play
5
+ // site passes on as they came. Each table has the codes `arc serve`
6
+ // answers with, in its source's words. Never matched on; each is held to
7
+ // its source (test/unit/serve/message.test.mjs).
8
+ // [declare]
9
+ // the dispatcher's (app/src/cloudflare/io-arcadible-runner-dispatch,
10
+ // dispatch.js's MESSAGES).
11
+ const RUNNER = {
12
+ expired: "The ticket's time ran out. Get a new one, and try again.",
13
+ function_failed: "The game's function failed: it threw, or went past what it may use.",
14
+ invalid: "The request's body couldn't be read.",
15
+ no_function: "This build has no function.",
16
+ too_large: "The request's body is over 1 MB.",
17
+ unauthorized: "The request has no ticket Arcadible takes for this build.",
18
+ };
19
+ // the wires' Worker's, to a game (app/src/cloudflare/io-arcadible-wires,
20
+ // wires.js's MESSAGES).
21
+ const WIRES = {
22
+ denied: "A guest Arcadible has given no id can't be on a wire.",
23
+ expired: "The ticket's time ran out. Get a new one, and try again.",
24
+ unauthorized: "The request has no ticket Arcadible takes for this build.",
25
+ };
26
+ // the Worker's words by status, for a code it says more than one way: its
27
+ // `invalid` (its INVALID), the first for a status it has none for.
28
+ const WIRES_BY_STATUS = {
29
+ invalid: {
30
+ 400: "This address takes a connection to a wire.",
31
+ 405: "A wire is opened with a POST.",
32
+ },
33
+ };
34
+ // the API's (app/src/web/arcadible-api/app/result.py's MESSAGES), for the
35
+ // codes `arc serve`'s page and server API answer with; and the ticket
36
+ // check's, for a ticket it doesn't take (app/api/server.py's
37
+ // TICKET_REFUSED).
38
+ const API = {
39
+ conflict: "This was changed since it was read, and nothing was written. Read it again, then write.",
40
+ denied: "This account or game isn't allowed to do this.",
41
+ full: "This holds all it may. Free some space, then try again.",
42
+ invalid: "This request isn't one the API takes. Check it against the API's docs, then send it again.",
43
+ not_found: "Not found: it isn't there, or it isn't this caller's to see.",
44
+ too_large: "This is past its size. Make it smaller, then send it again.",
45
+ too_many: "This names more items than one call takes. Split it into smaller calls.",
46
+ };
47
+ const TICKET_REFUSED = {
48
+ expired: "The ticket's time ran out. The game gets a new one, and sends it again.",
49
+ unauthorized: "The ticket isn't one Arcadible signed for this server, game, and channel.",
50
+ };
51
+ // what any of them says of a code it has no words for, as the Workers do.
52
+ const REFUSED = "Arcadible refused the request.";
53
+ // [function]
54
+ /** What the function's refusal with this code says, as the dispatcher's. */
55
+ export function runnerMessage(code) {
56
+ return RUNNER[code] ?? REFUSED;
57
+ }
58
+ // [function]
59
+ /** What a wire's refusal with this status and code says, as the Worker's. */
60
+ export function wiresMessage(status, code) {
61
+ const byStatus = WIRES_BY_STATUS[code];
62
+ if (byStatus) {
63
+ return byStatus[status] ?? Object.values(byStatus)[0] ?? REFUSED;
64
+ }
65
+ return WIRES[code] ?? REFUSED;
66
+ }
67
+ // [function]
68
+ /** What the page's API, or the server API, says of a code, as the API's. */
69
+ export function apiMessage(code) {
70
+ return API[code] ?? REFUSED;
71
+ }
72
+ // [function]
73
+ /**
74
+ * What the ticket check says of a ticket it doesn't take, as the API's: a
75
+ * code it has no words for is said as one it doesn't take.
76
+ */
77
+ export function ticketMessage(code) {
78
+ return TICKET_REFUSED[code] ?? TICKET_REFUSED.unauthorized ?? REFUSED;
79
+ }