@akterjs/cli 0.1.1 → 0.1.3

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 (86) hide show
  1. package/README.md +2 -2
  2. package/dist/{Argument-D81dqizB.mjs → Argument-BKjmk8CZ.mjs} +1 -1
  3. package/dist/{ChildProcess-BCIwxPGc.mjs → ChildProcess-UWPy-kPn.mjs} +2 -2
  4. package/dist/{CliError-Cf5xqkkj.mjs → CliError-CphGZMfO.mjs} +2 -2
  5. package/dist/{Command-Dzq9KM-h.mjs → Command-D3hF_i6F.mjs} +8 -8
  6. package/dist/{Config-B6OND9WR.mjs → Config-DEUiBxw4.mjs} +2 -2
  7. package/dist/{Console-BKHUkH6a.mjs → Console-DY7H086H.mjs} +1 -1
  8. package/dist/{Digest-CBd3uv5B.mjs → Digest-CnBYV3Oh.mjs} +2 -2
  9. package/dist/{Effect-CKFpqbmw.mjs → Effect-CFIPV2Jg.mjs} +44 -4
  10. package/dist/{FileSystem-4pPcEb_i.mjs → FileSystem-iEC-kUB-.mjs} +2 -2
  11. package/dist/{HttpClientError-BUeMWx70.mjs → HttpClientError-BVd83gxQ.mjs} +1 -1
  12. package/dist/{HttpClientResponse-D5ZKICVV.mjs → HttpClientResponse-CifutXCF.mjs} +4 -4
  13. package/dist/{Path-Djdv_eF5.mjs → Path-BRnAx8py.mjs} +1 -1
  14. package/dist/{Queue-CO5UQ6os.mjs → Queue-CyWN-MDp.mjs} +1 -1
  15. package/dist/{Ref-BIPOxJNH.mjs → Ref-CX3ghLq6.mjs} +1 -1
  16. package/dist/{Runtime-BInIAwK3.mjs → Runtime-CyqeMpLX.mjs} +1 -1
  17. package/dist/{Schema-MiKt5K1v.mjs → Schema-O3QUdX3B.mjs} +1 -1
  18. package/dist/{SecureRandom-B_U4ysO3.mjs → SecureRandom-DYpl-YDn.mjs} +2 -2
  19. package/dist/{Semaphore-DOVJ4ZGS.mjs → Semaphore-DHYKAQSv.mjs} +1 -1
  20. package/dist/{Stdio-KylmOBX_.mjs → Stdio-7l23nD6W.mjs} +1 -1
  21. package/dist/{Stream-bK9QIETN.mjs → Stream-BeqiANg7.mjs} +3 -3
  22. package/dist/{TerminalCapabilities-w_44MAca.mjs → TerminalCapabilities-R2LPyCNs.mjs} +3 -3
  23. package/dist/{WebCrypto-ZI_GNVlw.mjs → WebCrypto-C_95GMdw.mjs} +1 -1
  24. package/dist/{actor-call.service-CGM_vD9u.mjs → actor-call.service-vJm8gKjI.mjs} +15 -15
  25. package/dist/{actor-client.adapter-Coem7gF1.mjs → actor-client.adapter-CfKUj7Gi.mjs} +32 -16
  26. package/dist/{akter-program.config-D8yb9xQP.mjs → akter-program.config-BqHoPt6H.mjs} +252 -39
  27. package/dist/akter.cli.mjs +1 -1
  28. package/dist/app-cli.config.mjs +4 -3
  29. package/dist/archive/akter-archive.schema.mjs +1 -1
  30. package/dist/archive/akter-archive.service.mjs +7 -7
  31. package/dist/archive/archive-cli.config.mjs +6 -6
  32. package/dist/archive/archive-invalid.errors.mjs +1 -1
  33. package/dist/archive/tar.pure.mjs +1 -1
  34. package/dist/archive/zstd.adapter.mjs +2 -2
  35. package/dist/bench/bench-report.pure.mjs +7 -2
  36. package/dist/bench/bench-runner.pure.mjs +40 -3
  37. package/dist/bench/bench.service.mjs +17 -14
  38. package/dist/{cli-runtime.layer-BqK2mmVL.mjs → cli-runtime.layer-Bwuqll8h.mjs} +13 -13
  39. package/dist/cli-runtime.layer.mjs +1 -1
  40. package/dist/{cloud-client.adapter-Cy1BjDbG.mjs → cloud-client.adapter-Ce4oyGNh.mjs} +94 -17
  41. package/dist/{cloud-client.adapter-DOVMoYAj.mjs → cloud-client.adapter-Dln8NW-9.mjs} +9 -9
  42. package/dist/command/akter-commands.config.mjs +2 -2
  43. package/dist/command/akter-program.config.mjs +1 -1
  44. package/dist/credentials/credentials.service.mjs +5 -5
  45. package/dist/credentials/keychain.adapter.mjs +3 -3
  46. package/dist/credentials/login.config.mjs +9 -9
  47. package/dist/deploy/auth/api-attempt.service.mjs +4 -4
  48. package/dist/deploy/auth/token-refresh.errors.mjs +1 -1
  49. package/dist/deploy/build-bundle.adapter.mjs +8 -8
  50. package/dist/deploy/cloud-client.adapter.mjs +1 -1
  51. package/dist/deploy/cloud-url.pure.mjs +2 -2
  52. package/dist/deploy/deploy-failed.errors.mjs +2 -2
  53. package/dist/deploy/deploy.service.mjs +6 -6
  54. package/dist/deploy/request-failure.pure.mjs +3 -3
  55. package/dist/docs/docs.config.mjs +1 -1
  56. package/dist/{docs.config-D2amjsje.mjs → docs.config-Dy0MFrKd.mjs} +10 -42
  57. package/dist/export/actor-export.service.mjs +8 -8
  58. package/dist/export/export-failed.errors.mjs +1 -1
  59. package/dist/export/export-failure.pure.mjs +2 -2
  60. package/dist/export/ordered-lines.pure.mjs +3 -3
  61. package/dist/export/ranged-download.pure.mjs +3 -3
  62. package/dist/export/snapshot-download.pure.mjs +3 -3
  63. package/dist/{hosted-runtime.layer-Cx3IPsEd.mjs → hosted-runtime.layer-BDXPqzSp.mjs} +128 -99
  64. package/dist/local/environment-cli.config.mjs +4 -4
  65. package/dist/local/local-cli.config.mjs +9 -9
  66. package/dist/logs/log-follow.config.mjs +2 -2
  67. package/dist/logs/log-follow.service.mjs +7 -7
  68. package/dist/logs/log-lines.pure.mjs +4 -4
  69. package/dist/{operation-input.pure-CS9iUhqK.mjs → operation-input.pure-B72BbxCG.mjs} +2 -2
  70. package/dist/operation-output.pure-ChUlePFj.mjs +120 -0
  71. package/dist/{operation-registry.pure-DVC8EDgj.mjs → operation-registry.pure-DeoTbR3J.mjs} +2 -2
  72. package/dist/registry/actor-call.service.mjs +1 -1
  73. package/dist/registry/actor-commands.config.mjs +6 -6
  74. package/dist/registry/approval.service.mjs +5 -5
  75. package/dist/registry/cloud-commands.config.mjs +3 -3
  76. package/dist/registry/cloud-served.pure.mjs +1 -1
  77. package/dist/registry/operation-call.service.mjs +42 -23
  78. package/dist/registry/operation-input.pure.mjs +1 -1
  79. package/dist/registry/operation-output.pure.mjs +1 -91
  80. package/dist/registry/served-command.config.mjs +6 -6
  81. package/dist/runner-exited.errors.mjs +2 -2
  82. package/dist/terminal/cli-exit.errors.mjs +2 -2
  83. package/dist/terminal/cli-failure.pure.mjs +7 -7
  84. package/dist/terminal/confirm.adapter.mjs +2 -2
  85. package/package.json +3 -3
  86. package/dist/docs.config-D3zzLzLR.mjs +0 -190
@@ -0,0 +1,120 @@
1
+ import { $ as isFailure, D as lastNonEmpty, T as join, j as map, p as flatMap, w as isReadonlyArrayNonEmpty } from "./Array-B4kuTQeW.mjs";
2
+ import { t as match } from "./Boolean-kILIvmhE.mjs";
3
+ import { An as setInputType, B as flatMap$1, Dn as max, En as exponential, Et as orDie, In as while_, M as fail, Mn as tap, On as min, Tn as during, jn as spaced, kn as passthrough, o as andThen, ri as isTimeoutError } from "./Effect-CFIPV2Jg.mjs";
4
+ import { n as log, t as error } from "./Console-DY7H086H.mjs";
5
+ import { h as toSeconds, l as millis } from "./Duration-EH9Vy4U6.mjs";
6
+ import { Tn as pipe, cn as isString, d as fromUndefinedOr, f as getOrElse, i as filter, x as match$1 } from "./Option-DkxSnBhp.mjs";
7
+ import { B as TaggedStruct, F as String, b as JsonObject, ct as encodeOption, fr as map$1, hr as toEntries, mt as is, n as ArraySchema, pr as remove, pt as fromJsonString, qt as isPattern, sr as get, st as encodeEffect, y as Json } from "./Schema-O3QUdX3B.mjs";
8
+ import { v as trim } from "./String-q5dcsVe4.mjs";
9
+ import { CliExitError } from "./terminal/cli-exit.errors.mjs";
10
+ import { TokenRefreshError } from "./deploy/auth/token-refresh.errors.mjs";
11
+ import { DeployFailedError } from "./deploy/deploy-failed.errors.mjs";
12
+ import { RunnerExitedError } from "./runner-exited.errors.mjs";
13
+ // ../client/src/cloud/cloud-pending.pure.ts
14
+ /**
15
+ * The Cloud API answers an operation that outlasts its 30 s deadline, such as a fork that copies computers, with 503
16
+ * ActorUnavailableError and a reason saying it is still running and to ask again with the same id, which answers it and
17
+ * never does the work twice (akter-cloud's actorForks.create). Anything else a 503 says, such as a lost reply or a fork
18
+ * that didn't finish, is an error: only this reason means that asking again, unchanged, is the way to the answer.
19
+ */
20
+ const unavailable$1 = 503;
21
+ const StillRunning = TaggedStruct("ActorUnavailableError", { reason: String.check(isPattern(/\bis still running\b.*\bask again with the same \w+ id\b/iu)) });
22
+ /** Whether an answer is the Cloud API's documented "still running, ask again with the same id". */
23
+ const isStillRunning = ({ body, status }) => status === unavailable$1 && is(StillRunning)(body);
24
+ /** How long a caller keeps asking again before it gives the 503 back as the answer. */
25
+ const stillRunningWait = "5 minutes";
26
+ /**
27
+ * How a caller asks again while an operation is still running: 1, 2 and 4 seconds apart, then every 5, for about
28
+ * five minutes. Each ask is held by the Cloud API for up to its 30 s deadline, so the waits only keep a fast refusal
29
+ * from becoming a tight loop.
30
+ */
31
+ const askAgainSchedule = max([min([exponential("1 second"), spaced("5 seconds")]), during(stillRunningWait)]);
32
+ // src/registry/operation-output.pure.ts
33
+ const compact = encodeEffect(fromJsonString(Json));
34
+ const pretty = encodeEffect(fromJsonString(Json, { space: 2 }));
35
+ const compactOption = encodeOption(fromJsonString(Json));
36
+ const encodeExit = encodeEffect(CliExitError);
37
+ const compactJson = (value) => orDie(compact(value));
38
+ const prettyJson = (value) => orDie(pretty(value));
39
+ const exitJson = (failure) => flatMap$1(orDie(encodeExit(failure)), compactJson);
40
+ const shown = (value) => {
41
+ if (isString(value)) return value;
42
+ return getOrElse(compactOption(value), () => "");
43
+ };
44
+ const errorLine = ({ body, status }) => {
45
+ if (!is(JsonObject)(body)) return trim(`HTTP ${status} ${shown(body)}`);
46
+ const tag = pipe(get(body, "_tag"), filter(isString), getOrElse(() => "Error"));
47
+ const fields = pipe(toEntries(remove(body, "_tag")), map(([key, value]) => `${key}: ${shown(value)}`));
48
+ if (isReadonlyArrayNonEmpty(fields)) return `HTTP ${status} ${tag} (${join(fields, ", ")})`;
49
+ return `HTTP ${status} ${tag}`;
50
+ };
51
+ const unavailableStatus = 503;
52
+ /**
53
+ * After a 503 an idempotent change may have stopped partway, as erasing an actor can between releasing its files and
54
+ * destroying its key (FK6); running it again finishes it.
55
+ */
56
+ const retryHint = ({ idempotent, readOnly, status }) => {
57
+ if (status === unavailableStatus && idempotent && !readOnly) return ". It may have stopped partway, and it is safe to repeat: run the same command again.";
58
+ return "";
59
+ };
60
+ const unavailable = (message) => CliExitError.make({
61
+ code: CliExitError.codes.unavailable,
62
+ message,
63
+ reason: "Unavailable"
64
+ });
65
+ const signInCode = (failure) => match$1(fromUndefinedOr(failure.status), {
66
+ onNone: () => CliExitError.codes.unavailable,
67
+ onSome: CliExitError.ofStatus
68
+ });
69
+ /**
70
+ * A token exchange that failed, with the exit code of what failed it: 3 only when the API refused the key (401 or
71
+ * 403), and 5 when it couldn't answer, answered 5xx, or a refresh failed, since trying again may succeed.
72
+ */
73
+ const signInFailure = (failure) => {
74
+ if (is(TokenRefreshError)(failure)) return unavailable(failure.message);
75
+ const message = `Signing in failed: ${failure.message}`;
76
+ return CliExitError.make({
77
+ code: signInCode(failure),
78
+ message,
79
+ reason: "SignInFailed"
80
+ });
81
+ };
82
+ const unanswered = ({ command, failure, wait }) => {
83
+ if (is(DeployFailedError)(failure) || is(TokenRefreshError)(failure)) return signInFailure(failure);
84
+ if (isTimeoutError(failure)) return unavailable(`${command} got no answer within ${wait}; the request may still have run.`);
85
+ return unavailable(`${command} could not reach the API: ${failure.message}`);
86
+ };
87
+ const printJson = (json) => (value) => {
88
+ const text = match(json, {
89
+ onFalse: () => prettyJson(value),
90
+ onTrue: () => compactJson(value)
91
+ });
92
+ return flatMap$1(text, (line) => log(line));
93
+ };
94
+ const JsonArray = ArraySchema(Json);
95
+ const arrayAt = (page, key) => getOrElse(filter(get(page, key), is(JsonArray)), () => []);
96
+ const joinedPages = (pages) => {
97
+ const last = lastNonEmpty(pages);
98
+ const joined = map$1(last, (value, key) => match(is(JsonArray)(value), {
99
+ onFalse: () => value,
100
+ onTrue: () => flatMap(pages, (page) => arrayAt(page, key))
101
+ }));
102
+ return remove(joined, "next");
103
+ };
104
+ const reported = (json) => (failure) => {
105
+ const printed = match(json, {
106
+ onFalse: () => error(failure.message),
107
+ onTrue: () => flatMap$1(exitJson(failure), (line) => log(line))
108
+ });
109
+ return andThen(printed, fail(RunnerExitedError.make({ code: failure.code })));
110
+ };
111
+ const wholeSeconds = (millis$1) => Math.floor(toSeconds(millis(millis$1)));
112
+ /** Whether the API refused with its "still running, ask again with the same id", as a fork that outlasts its 30 s deadline does. */
113
+ const stillRunning = (refusal) => isStillRunning(refusal);
114
+ /**
115
+ * How a call the API answers "still running" is asked again: unchanged, since it names the same id and the API answers
116
+ * it without doing the work twice. The wait is bounded, and each ask is noted on stderr. The schedule ends with the
117
+ * Result a settled call gave, or the last "still running" one.
118
+ */
119
+ const askingAgain = (command) => askAgainSchedule.pipe(setInputType(), passthrough, while_(({ input }) => isFailure(input)), tap(({ elapsed }) => error(`${command}: still running; asking again with the same request (${wholeSeconds(elapsed)}s of ${stillRunningWait})`)));
120
+ export { joinedPages as a, retryHint as c, unanswered as d, exitJson as i, signInFailure as l, compactJson as n, printJson as o, errorLine as r, reported as s, askingAgain as t, stillRunning as u };
@@ -1,9 +1,9 @@
1
1
  import { C as isReadonlyArrayEmpty, M as match, N as matchLeft, P as min, R as some, i as dedupe, j as map, l as filter, m as flatten, p as flatMap, r as contains, w as isReadonlyArrayNonEmpty } from "./Array-B4kuTQeW.mjs";
2
2
  import { t as match$1 } from "./Boolean-kILIvmhE.mjs";
3
- import { K as forEach, W as fnUntraced, dt as map$1 } from "./Effect-CKFpqbmw.mjs";
3
+ import { K as forEach, W as fnUntraced, dt as map$1 } from "./Effect-CFIPV2Jg.mjs";
4
4
  import { S as none, T as toArray, Tn as pipe, _ as isSome, b as map$2, cn as isString, d as fromUndefinedOr, f as getOrElse, i as filter$1, o as flatMap$1, r as exists, v as liftPredicate, x as match$2 } from "./Option-DkxSnBhp.mjs";
5
5
  import { i as Number$1 } from "./Order-C1JC991I.mjs";
6
- import { F as String$1, I as Struct, M as Record, Q as brand, _r as values, a as Boolean, an as optionalKey, at as decodeUnknownEffect, b as JsonObject, dr as keys, fr as map$3, hr as toEntries, mr as set, mt as is, n as ArraySchema, or as fromEntries, ot as decodeUnknownOption, qt as isPattern, sr as get, ur as isEmptyRecord, y as Json } from "./Schema-MiKt5K1v.mjs";
6
+ import { F as String$1, I as Struct, M as Record, Q as brand, _r as values, a as Boolean, an as optionalKey, at as decodeUnknownEffect, b as JsonObject, dr as keys, fr as map$3, hr as toEntries, mr as set, mt as is, n as ArraySchema, or as fromEntries, ot as decodeUnknownOption, qt as isPattern, sr as get, ur as isEmptyRecord, y as Json } from "./Schema-O3QUdX3B.mjs";
7
7
  import { _ as toUpperCase, f as replaceAll, h as startsWith, m as split, n as camelToSnake, p as slice, s as isNonEmpty } from "./String-q5dcsVe4.mjs";
8
8
  // ../../node_modules/.pnpm/@akterjs+cloud-api@file+..+akter-cloud+packages+cloud-api_effect@4.1.2_patch_hash=0e611_59e8fdba67d150970876667b4296bdf6/node_modules/@akterjs/cloud-api/src/flags/flag-name.schema.ts
9
9
  /**
@@ -1 +1 @@
1
- export { t as ActorCall } from "../actor-call.service-CGM_vD9u.mjs";
1
+ export { t as ActorCall } from "../actor-call.service-vJm8gKjI.mjs";
@@ -1,13 +1,13 @@
1
1
  import { T as join, _ as getSomes, c as every, j as map, p as flatMap, v as groupBy } from "../Array-B4kuTQeW.mjs";
2
- import { Xt as succeed, _n as when, d as asVoid, o as andThen, x as catchTag } from "../Effect-CKFpqbmw.mjs";
2
+ import { Xt as succeed, _n as when, d as asVoid, o as andThen, x as catchTag } from "../Effect-CFIPV2Jg.mjs";
3
3
  import { S as none, T as toArray, _ as isSome, c as flatten, f as getOrElse, v as liftPredicate, x as match } from "../Option-DkxSnBhp.mjs";
4
- import { fr as map$1, or as fromEntries, sr as get } from "../Schema-MiKt5K1v.mjs";
5
- import { c as Int, f as optional, i as withDescription$1, l as String, m as withDescription, o as Boolean, p as withDefault, r as unlisted, t as make } from "../Command-Dzq9KM-h.mjs";
6
- import { n as actorOperations, t as ActorCall } from "../actor-call.service-CGM_vD9u.mjs";
7
- import { t as kebab } from "../operation-registry.pure-DVC8EDgj.mjs";
4
+ import { fr as map$1, or as fromEntries, sr as get } from "../Schema-O3QUdX3B.mjs";
5
+ import { c as Int, f as optional, i as withDescription$1, l as String, m as withDescription, o as Boolean, p as withDefault, r as unlisted, t as make } from "../Command-D3hF_i6F.mjs";
6
+ import { n as actorOperations, t as ActorCall } from "../actor-call.service-vJm8gKjI.mjs";
7
+ import { t as kebab } from "../operation-registry.pure-DeoTbR3J.mjs";
8
8
  import { servedBy } from "./cloud-served.pure.mjs";
9
9
  import { servedCommandOf } from "./served-command.config.mjs";
10
- import { reported } from "./operation-output.pure.mjs";
10
+ import { s as reported } from "../operation-output.pure-ChUlePFj.mjs";
11
11
  import { Confirmation } from "../terminal/confirm.adapter.mjs";
12
12
  // src/registry/actor-commands.config.ts
13
13
  const help = {
@@ -1,12 +1,12 @@
1
1
  import { T as join } from "../Array-B4kuTQeW.mjs";
2
2
  import { t as match } from "../Boolean-kILIvmhE.mjs";
3
- import { t as error } from "../Console-BKHUkH6a.mjs";
4
- import { At as provideContext, T as context, Vn as effect, W as fnUntraced, Wn as merge, Xt as succeed, _n as when, aa as Service, d as asVoid, et as gen, ht as mapError, in as timeout } from "../Effect-CKFpqbmw.mjs";
3
+ import { t as error } from "../Console-DY7H086H.mjs";
4
+ import { At as provideContext, Kn as merge, T as context, Un as effect, W as fnUntraced, Xt as succeed, _n as when, d as asVoid, et as gen, ht as mapError, in as timeout, sa as Service } from "../Effect-CFIPV2Jg.mjs";
5
5
  import { b as map, i as filter, in as isNumber, qt as hasProperty, un as isTagged, v as liftPredicate, x as match$1 } from "../Option-DkxSnBhp.mjs";
6
- import { ot as decodeUnknownOption } from "../Schema-MiKt5K1v.mjs";
6
+ import { ot as decodeUnknownOption } from "../Schema-O3QUdX3B.mjs";
7
7
  import { v as trim } from "../String-q5dcsVe4.mjs";
8
- import { c as String, d as run, t as TerminalCapabilities } from "../TerminalCapabilities-w_44MAca.mjs";
9
- import { d as make, r as ConfirmationRequiredErrorEncoded } from "../cloud-client.adapter-Cy1BjDbG.mjs";
8
+ import { c as String, d as run, t as TerminalCapabilities } from "../TerminalCapabilities-R2LPyCNs.mjs";
9
+ import { d as make, r as ConfirmationRequiredErrorEncoded } from "../cloud-client.adapter-Ce4oyGNh.mjs";
10
10
  import { CliExitError } from "../terminal/cli-exit.errors.mjs";
11
11
  import { Confirmation } from "../terminal/confirm.adapter.mjs";
12
12
  // src/registry/approval.service.ts
@@ -1,11 +1,11 @@
1
1
  import { C as isReadonlyArrayEmpty, R as some$1, c as every, j as map, l as filter, r as contains, v as groupBy, w as isReadonlyArrayNonEmpty } from "../Array-B4kuTQeW.mjs";
2
2
  import { t as match } from "../Boolean-kILIvmhE.mjs";
3
3
  import { S as none, _ as isSome, f as getOrElse, i as filter$1, w as some$2, x as match$1 } from "../Option-DkxSnBhp.mjs";
4
- import { ar as filter$2, hr as toEntries, lr as has, or as fromEntries, pt as fromJsonString, sr as get, y as Json } from "../Schema-MiKt5K1v.mjs";
4
+ import { ar as filter$2, hr as toEntries, lr as has, or as fromEntries, pt as fromJsonString, sr as get, y as Json } from "../Schema-O3QUdX3B.mjs";
5
5
  import { v as trim } from "../String-q5dcsVe4.mjs";
6
- import { a as withSubcommands, c as Int, d as map$1, f as optional, g as withSchema, i as withDescription$1, l as String$1, m as withDescription, o as Boolean, p as withDefault, r as unlisted, s as Finite, t as make, u as atLeast } from "../Command-Dzq9KM-h.mjs";
6
+ import { a as withSubcommands, c as Int, d as map$1, f as optional, g as withSchema, i as withDescription$1, l as String$1, m as withDescription, o as Boolean, p as withDefault, r as unlisted, s as Finite, t as make, u as atLeast } from "../Command-D3hF_i6F.mjs";
7
7
  import { OperationCall } from "./operation-call.service.mjs";
8
- import { t as kebab } from "../operation-registry.pure-DVC8EDgj.mjs";
8
+ import { t as kebab } from "../operation-registry.pure-DeoTbR3J.mjs";
9
9
  // src/registry/cloud-commands.config.ts
10
10
  const noneRequired = 0;
11
11
  const reservedFlags = [
@@ -1,7 +1,7 @@
1
1
  import { R as some, T as join, j as map, l as filter, r as contains, u as findFirst } from "../Array-B4kuTQeW.mjs";
2
2
  import { t as match } from "../Boolean-kILIvmhE.mjs";
3
3
  import { _ as isSome, b as map$1, c as flatten, cn as isString, f as getOrElse, h as isNone, i as filter$1, o as flatMap, r as exists, u as fromNullishOr, w as some$1 } from "../Option-DkxSnBhp.mjs";
4
- import { nt as decodeOption, or as fromEntries, pt as fromJsonString, sr as get, y as Json } from "../Schema-MiKt5K1v.mjs";
4
+ import { nt as decodeOption, or as fromEntries, pt as fromJsonString, sr as get, y as Json } from "../Schema-O3QUdX3B.mjs";
5
5
  // src/registry/cloud-served.pure.ts
6
6
  const loopbackHosts = [
7
7
  "localhost",
@@ -1,21 +1,21 @@
1
- import { R as some, T as join } from "../Array-B4kuTQeW.mjs";
1
+ import { R as some, T as join, Y as fail, at as succeed, tt as isSuccess } from "../Array-B4kuTQeW.mjs";
2
2
  import { t as match } from "../Boolean-kILIvmhE.mjs";
3
- import { n as log, t as error } from "../Console-BKHUkH6a.mjs";
4
- import { At as provideContext, B as flatMap, Dt as orElseSucceed, Et as orDie, Gn as mergeAll, Gt as scoped, T as context, Vn as effect, W as fnUntraced, Xt as succeed, aa as Service, et as gen, ht as mapError, in as timeout, l as as, qn as provideMerge, x as catchTag } from "../Effect-CKFpqbmw.mjs";
5
- import { t as FileSystem } from "../FileSystem-4pPcEb_i.mjs";
3
+ import { n as log, t as error } from "../Console-DY7H086H.mjs";
4
+ import { At as provideContext, B as flatMap, Dt as orElseSucceed, Et as orDie, Ft as repeat, Gt as scoped, T as context, Un as effect, W as fnUntraced, Xt as succeed$1, Yn as provideMerge, et as gen, ht as mapError, in as timeout, qn as mergeAll, sa as Service, x as catchTag } from "../Effect-CFIPV2Jg.mjs";
5
+ import { t as FileSystem } from "../FileSystem-iEC-kUB-.mjs";
6
6
  import { C as orElse, S as none, _ as isSome, b as map, cn as isString, f as getOrElse, h as isNone, i as filter, in as isNumber, o as flatMap$1, p as getOrNull, t as all, v as liftPredicate, w as some$1, x as match$1 } from "../Option-DkxSnBhp.mjs";
7
- import { at as decodeUnknownEffect, b as JsonObject, cr as getSomes, gr as union, lr as has, mr as set, pt as fromJsonString, q as Uint8ArrayFromBase64, sr as get, st as encodeEffect, tt as decodeEffect, y as Json } from "../Schema-MiKt5K1v.mjs";
8
- import { t as Stdio } from "../Stdio-KylmOBX_.mjs";
9
- import { M as mkString, T as make, i as decodeText, z as run } from "../Stream-bK9QIETN.mjs";
7
+ import { at as decodeUnknownEffect, b as JsonObject, cr as getSomes, gr as union, lr as has, mr as set, pt as fromJsonString, q as Uint8ArrayFromBase64, sr as get, st as encodeEffect, tt as decodeEffect, y as Json } from "../Schema-O3QUdX3B.mjs";
8
+ import { t as Stdio } from "../Stdio-7l23nD6W.mjs";
9
+ import { M as mkString, T as make, i as decodeText, z as run } from "../Stream-BeqiANg7.mjs";
10
10
  import { h as startsWith, p as slice } from "../String-q5dcsVe4.mjs";
11
- import { f as HttpClient, g as mapRequest, y as isHttpMethod } from "../cloud-client.adapter-Cy1BjDbG.mjs";
12
- import { E as setUrlParams, S as prependUrl, T as setUrlParam, d as acceptJson, p as bodyJson, w as setHeaders, y as make$1 } from "../HttpClientResponse-D5ZKICVV.mjs";
11
+ import { f as HttpClient, g as mapRequest, y as isHttpMethod } from "../cloud-client.adapter-Ce4oyGNh.mjs";
12
+ import { E as setUrlParams, S as prependUrl, T as setUrlParam, d as acceptJson, p as bodyJson, w as setHeaders, y as make$1 } from "../HttpClientResponse-CifutXCF.mjs";
13
13
  import { CliExitError } from "../terminal/cli-exit.errors.mjs";
14
14
  import { Credentials } from "../credentials/credentials.service.mjs";
15
- import { t as CloudClient } from "../cloud-client.adapter-DOVMoYAj.mjs";
15
+ import { t as CloudClient } from "../cloud-client.adapter-Dln8NW-9.mjs";
16
16
  import { Approval } from "./approval.service.mjs";
17
- import { i as validInput, n as parseInput, r as targetOf, t as checkedSchema } from "../operation-input.pure-CS9iUhqK.mjs";
18
- import { errorLine, joinedPages, printJson, reported, retryHint, unanswered } from "./operation-output.pure.mjs";
17
+ import { i as validInput, n as parseInput, r as targetOf, t as checkedSchema } from "../operation-input.pure-B72BbxCG.mjs";
18
+ import { a as joinedPages, c as retryHint, d as unanswered, o as printJson, r as errorLine, s as reported, t as askingAgain, u as stillRunning } from "../operation-output.pure-ChUlePFj.mjs";
19
19
  import { RunnerExitedError } from "../runner-exited.errors.mjs";
20
20
  // src/registry/operation-call.service.ts
21
21
  const approvalHeader = "akter-approval";
@@ -54,7 +54,7 @@ const readText = fnUntraced(function* readText(raw) {
54
54
  });
55
55
  const inputOf = fnUntraced(function* inputOf(operation, options) {
56
56
  const base = yield* match$1(options.input, {
57
- onNone: () => succeed({}),
57
+ onNone: () => succeed$1({}),
58
58
  onSome: (raw) => flatMap(readText(raw), parseInput)
59
59
  });
60
60
  const assembled = union(base, getSomes(options.values), (_given, flag) => flag);
@@ -118,7 +118,7 @@ const requestFor = ({ operation, options, request }) => {
118
118
  });
119
119
  const base = make$1(methodOf(operation))(request.path).pipe(setUrlParams(request.query), acceptJson, setHeaders(approvalHeaders));
120
120
  return match$1(request.body, {
121
- onNone: () => succeed(base),
121
+ onNone: () => succeed$1(base),
122
122
  onSome: (body) => orDie(bodyJson(base, body))
123
123
  });
124
124
  };
@@ -143,7 +143,23 @@ const approvalAsked = fnUntraced(function* approvalAsked(planned, answer, body)
143
143
  required: asked
144
144
  })));
145
145
  });
146
- const attempt = fnUntraced(function* attempt(planned, http) {
146
+ const refusedOnce = fnUntraced(function* refusedOnce(planned, http, answer) {
147
+ const body = yield* bodyOf(answer.response);
148
+ if (stillRunning({
149
+ body,
150
+ status: answer.response.status
151
+ })) return fail({
152
+ answer,
153
+ body
154
+ });
155
+ const asked = yield* approvalAsked(planned, answer, body);
156
+ if (isSome(asked)) return succeed(some$1({
157
+ ...asked.value,
158
+ http
159
+ }));
160
+ return yield* printRefusal(answer, body);
161
+ });
162
+ const askOnce = fnUntraced(function* askOnce(planned, http) {
147
163
  const { operation, options } = planned;
148
164
  const response = yield* flatMap(requestFor(planned), http.execute).pipe(timeout(callWait), mapError((failure) => unanswered({
149
165
  command: commandName(operation),
@@ -155,15 +171,18 @@ const attempt = fnUntraced(function* attempt(planned, http) {
155
171
  operation,
156
172
  response
157
173
  };
158
- if (response.status >= firstSuccess && response.status < firstRedirect) return yield* as(printSuccess(answer), none());
159
- const body = yield* bodyOf(response);
160
- const asked = yield* approvalAsked(planned, answer, body);
161
- if (isSome(asked)) return some$1({
162
- ...asked.value,
163
- http
164
- });
165
- return yield* printRefusal(answer, body);
174
+ if (response.status >= firstSuccess && response.status < firstRedirect) {
175
+ yield* printSuccess(answer);
176
+ return succeed(none());
177
+ }
178
+ return yield* refusedOnce(planned, http, answer);
166
179
  }, scoped);
180
+ const attempt = fnUntraced(function* attempt(planned, http) {
181
+ const ask = askOnce(planned, http);
182
+ const settled = yield* repeat(ask, askingAgain(commandName(planned.operation)));
183
+ if (isSuccess(settled)) return settled.success;
184
+ return yield* printRefusal(settled.failure.answer, settled.failure.body);
185
+ });
167
186
  const nextOf = (page) => flatMap$1(get(page, "next"), (next) => orElse(liftPredicate(next, isString), () => map(liftPredicate(next, isNumber), String)));
168
187
  const pageAfter = fnUntraced(function* pageAfter(planned, http, after) {
169
188
  const { operation, options } = planned;
@@ -1 +1 @@
1
- export { t as checkedSchema, n as parseInput, r as targetOf, i as validInput } from "../operation-input.pure-CS9iUhqK.mjs";
1
+ export { t as checkedSchema, n as parseInput, r as targetOf, i as validInput } from "../operation-input.pure-B72BbxCG.mjs";
@@ -1,91 +1 @@
1
- import { D as lastNonEmpty, T as join, j as map, p as flatMap, w as isReadonlyArrayNonEmpty } from "../Array-B4kuTQeW.mjs";
2
- import { t as match } from "../Boolean-kILIvmhE.mjs";
3
- import { B as flatMap$1, Et as orDie, M as fail, o as andThen, ti as isTimeoutError } from "../Effect-CKFpqbmw.mjs";
4
- import { n as log, t as error } from "../Console-BKHUkH6a.mjs";
5
- import { Tn as pipe, cn as isString, d as fromUndefinedOr, f as getOrElse, i as filter, x as match$1 } from "../Option-DkxSnBhp.mjs";
6
- import { b as JsonObject, ct as encodeOption, fr as map$1, hr as toEntries, mt as is, n as ArraySchema, pr as remove, pt as fromJsonString, sr as get, st as encodeEffect, y as Json } from "../Schema-MiKt5K1v.mjs";
7
- import { v as trim } from "../String-q5dcsVe4.mjs";
8
- import { CliExitError } from "../terminal/cli-exit.errors.mjs";
9
- import { TokenRefreshError } from "../deploy/auth/token-refresh.errors.mjs";
10
- import { DeployFailedError } from "../deploy/deploy-failed.errors.mjs";
11
- import { RunnerExitedError } from "../runner-exited.errors.mjs";
12
- // src/registry/operation-output.pure.ts
13
- const compact = encodeEffect(fromJsonString(Json));
14
- const pretty = encodeEffect(fromJsonString(Json, { space: 2 }));
15
- const compactOption = encodeOption(fromJsonString(Json));
16
- const encodeExit = encodeEffect(CliExitError);
17
- const compactJson = (value) => orDie(compact(value));
18
- const prettyJson = (value) => orDie(pretty(value));
19
- const exitJson = (failure) => flatMap$1(orDie(encodeExit(failure)), compactJson);
20
- const shown = (value) => {
21
- if (isString(value)) return value;
22
- return getOrElse(compactOption(value), () => "");
23
- };
24
- const errorLine = ({ body, status }) => {
25
- if (!is(JsonObject)(body)) return trim(`HTTP ${status} ${shown(body)}`);
26
- const tag = pipe(get(body, "_tag"), filter(isString), getOrElse(() => "Error"));
27
- const fields = pipe(toEntries(remove(body, "_tag")), map(([key, value]) => `${key}: ${shown(value)}`));
28
- if (isReadonlyArrayNonEmpty(fields)) return `HTTP ${status} ${tag} (${join(fields, ", ")})`;
29
- return `HTTP ${status} ${tag}`;
30
- };
31
- const unavailableStatus = 503;
32
- /**
33
- * After a 503 an idempotent change may have stopped partway, as erasing an actor can between releasing its files and
34
- * destroying its key (FK6); running it again finishes it.
35
- */
36
- const retryHint = ({ idempotent, readOnly, status }) => {
37
- if (status === unavailableStatus && idempotent && !readOnly) return ". It may have stopped partway, and it is safe to repeat: run the same command again.";
38
- return "";
39
- };
40
- const unavailable = (message) => CliExitError.make({
41
- code: CliExitError.codes.unavailable,
42
- message,
43
- reason: "Unavailable"
44
- });
45
- const signInCode = (failure) => match$1(fromUndefinedOr(failure.status), {
46
- onNone: () => CliExitError.codes.unavailable,
47
- onSome: CliExitError.ofStatus
48
- });
49
- /**
50
- * A token exchange that failed, with the exit code of what failed it: 3 only when the API refused the key (401 or
51
- * 403), and 5 when it couldn't answer, answered 5xx, or a refresh failed, since trying again may succeed.
52
- */
53
- const signInFailure = (failure) => {
54
- if (is(TokenRefreshError)(failure)) return unavailable(failure.message);
55
- const message = `Signing in failed: ${failure.message}`;
56
- return CliExitError.make({
57
- code: signInCode(failure),
58
- message,
59
- reason: "SignInFailed"
60
- });
61
- };
62
- const unanswered = ({ command, failure, wait }) => {
63
- if (is(DeployFailedError)(failure) || is(TokenRefreshError)(failure)) return signInFailure(failure);
64
- if (isTimeoutError(failure)) return unavailable(`${command} got no answer within ${wait}; the request may still have run.`);
65
- return unavailable(`${command} could not reach the API: ${failure.message}`);
66
- };
67
- const printJson = (json) => (value) => {
68
- const text = match(json, {
69
- onFalse: () => prettyJson(value),
70
- onTrue: () => compactJson(value)
71
- });
72
- return flatMap$1(text, (line) => log(line));
73
- };
74
- const JsonArray = ArraySchema(Json);
75
- const arrayAt = (page, key) => getOrElse(filter(get(page, key), is(JsonArray)), () => []);
76
- const joinedPages = (pages) => {
77
- const last = lastNonEmpty(pages);
78
- const joined = map$1(last, (value, key) => match(is(JsonArray)(value), {
79
- onFalse: () => value,
80
- onTrue: () => flatMap(pages, (page) => arrayAt(page, key))
81
- }));
82
- return remove(joined, "next");
83
- };
84
- const reported = (json) => (failure) => {
85
- const printed = match(json, {
86
- onFalse: () => error(failure.message),
87
- onTrue: () => flatMap$1(exitJson(failure), (line) => log(line))
88
- });
89
- return andThen(printed, fail(RunnerExitedError.make({ code: failure.code })));
90
- };
91
- export { compactJson, errorLine, exitJson, joinedPages, printJson, reported, retryHint, signInFailure, unanswered };
1
+ export { t as askingAgain, n as compactJson, r as errorLine, i as exitJson, a as joinedPages, o as printJson, s as reported, c as retryHint, l as signInFailure, u as stillRunning, d as unanswered } from "../operation-output.pure-ChUlePFj.mjs";
@@ -1,11 +1,11 @@
1
1
  import { T as join, j as map } from "../Array-B4kuTQeW.mjs";
2
- import { a as option, i as String } from "../Config-B6OND9WR.mjs";
3
- import { Dt as orElseSucceed, W as fnUntraced, dt as map$1 } from "../Effect-CKFpqbmw.mjs";
2
+ import { a as option, i as String } from "../Config-DEUiBxw4.mjs";
3
+ import { Dt as orElseSucceed, W as fnUntraced, dt as map$1 } from "../Effect-CFIPV2Jg.mjs";
4
4
  import { C as orElse, S as none, x as match } from "../Option-DkxSnBhp.mjs";
5
- import { or as fromEntries } from "../Schema-MiKt5K1v.mjs";
6
- import { f as optional, i as withDescription$1, l as String$1, m as withDescription, r as unlisted, t as make } from "../Command-Dzq9KM-h.mjs";
7
- import { t as SecureRandom } from "../SecureRandom-B_U4ysO3.mjs";
8
- import { t as kebab } from "../operation-registry.pure-DVC8EDgj.mjs";
5
+ import { or as fromEntries } from "../Schema-O3QUdX3B.mjs";
6
+ import { f as optional, i as withDescription$1, l as String$1, m as withDescription, r as unlisted, t as make } from "../Command-D3hF_i6F.mjs";
7
+ import { t as SecureRandom } from "../SecureRandom-DYpl-YDn.mjs";
8
+ import { t as kebab } from "../operation-registry.pure-DeoTbR3J.mjs";
9
9
  import { cloudOnlyFields, cloudValuesOf, isLocalApp } from "./cloud-served.pure.mjs";
10
10
  import { OperationCall } from "./operation-call.service.mjs";
11
11
  // src/registry/served-command.config.ts
@@ -1,5 +1,5 @@
1
- import { n as errorReported, t as errorExitCode } from "./Runtime-BInIAwK3.mjs";
2
- import { v as Int, z as TaggedError } from "./Schema-MiKt5K1v.mjs";
1
+ import { n as errorReported, t as errorExitCode } from "./Runtime-CyqeMpLX.mjs";
2
+ import { v as Int, z as TaggedError } from "./Schema-O3QUdX3B.mjs";
3
3
  // src/runner-exited.errors.ts
4
4
  var RunnerExitedError = class extends TaggedError()("RunnerExitedError", { code: Int }) {
5
5
  [errorReported] = false;
@@ -1,6 +1,6 @@
1
1
  import { r as contains } from "../Array-B4kuTQeW.mjs";
2
- import { t as errorExitCode } from "../Runtime-BInIAwK3.mjs";
3
- import { F as String, v as Int, z as TaggedError } from "../Schema-MiKt5K1v.mjs";
2
+ import { t as errorExitCode } from "../Runtime-CyqeMpLX.mjs";
3
+ import { F as String, v as Int, z as TaggedError } from "../Schema-O3QUdX3B.mjs";
4
4
  // src/terminal/cli-exit.errors.ts
5
5
  const exitCodes = {
6
6
  authentication: 3,
@@ -1,10 +1,10 @@
1
- import { n as log, t as error } from "../Console-BKHUkH6a.mjs";
2
- import { B as flatMap, W as fnUntraced, Xt as succeed, _n as when } from "../Effect-CKFpqbmw.mjs";
3
- import { r as getErrorExitCode } from "../Runtime-BInIAwK3.mjs";
4
- import { mt as is } from "../Schema-MiKt5K1v.mjs";
5
- import { t as Stdio } from "../Stdio-KylmOBX_.mjs";
6
- import { a as ShowHelp } from "../CliError-Cf5xqkkj.mjs";
7
- import { exitJson } from "../registry/operation-output.pure.mjs";
1
+ import { n as log, t as error } from "../Console-DY7H086H.mjs";
2
+ import { B as flatMap, W as fnUntraced, Xt as succeed, _n as when } from "../Effect-CFIPV2Jg.mjs";
3
+ import { r as getErrorExitCode } from "../Runtime-CyqeMpLX.mjs";
4
+ import { mt as is } from "../Schema-O3QUdX3B.mjs";
5
+ import { t as Stdio } from "../Stdio-7l23nD6W.mjs";
6
+ import { a as ShowHelp } from "../CliError-CphGZMfO.mjs";
7
+ import { i as exitJson } from "../operation-output.pure-ChUlePFj.mjs";
8
8
  import { RunnerExitedError } from "../runner-exited.errors.mjs";
9
9
  import { CliExitError } from "./cli-exit.errors.mjs";
10
10
  // src/terminal/cli-failure.pure.ts
@@ -1,5 +1,5 @@
1
- import { At as provideContext, T as context, Vn as effect, W as fnUntraced, Xt as succeed, aa as Service, et as gen, x as catchTag } from "../Effect-CKFpqbmw.mjs";
2
- import { d as run, n as Confirm, t as TerminalCapabilities } from "../TerminalCapabilities-w_44MAca.mjs";
1
+ import { At as provideContext, T as context, Un as effect, W as fnUntraced, Xt as succeed, et as gen, sa as Service, x as catchTag } from "../Effect-CFIPV2Jg.mjs";
2
+ import { d as run, n as Confirm, t as TerminalCapabilities } from "../TerminalCapabilities-R2LPyCNs.mjs";
3
3
  import { CliExitError } from "./cli-exit.errors.mjs";
4
4
  // src/terminal/confirm.adapter.ts
5
5
  const declined = () => CliExitError.make({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akterjs/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "The akter command: local engine, deploy, branch, restore, history, export, migrate and bench.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -32,9 +32,9 @@
32
32
  "esbuild": "0.28.2"
33
33
  },
34
34
  "devDependencies": {
35
- "@akterjs/client": "0.1.1",
35
+ "@akterjs/client": "0.1.3",
36
36
  "@akterjs/cloud-api": "file:../../../akter-cloud/packages/cloud-api",
37
- "@akterjs/effect": "0.1.1",
37
+ "@akterjs/effect": "0.1.3",
38
38
  "@effect/openapi-generator": "4.1.2",
39
39
  "@effect/platform-node": "4.1.2",
40
40
  "@effect/vitest": "4.1.2",