@pipelex/sdk 0.32.0 → 0.34.0

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 (87) hide show
  1. package/README.md +40 -5
  2. package/dist/artifacts.js +23 -9
  3. package/dist/artifacts.js.map +1 -1
  4. package/dist/cli/args.d.ts +41 -0
  5. package/dist/cli/args.js +96 -0
  6. package/dist/cli/args.js.map +1 -0
  7. package/dist/cli/bundle.d.ts +45 -0
  8. package/dist/cli/bundle.js +148 -0
  9. package/dist/cli/bundle.js.map +1 -0
  10. package/dist/cli/environment.d.ts +36 -0
  11. package/dist/cli/environment.js +72 -0
  12. package/dist/cli/environment.js.map +1 -0
  13. package/dist/cli/help.d.ts +4 -0
  14. package/dist/cli/help.js +56 -0
  15. package/dist/cli/help.js.map +1 -0
  16. package/dist/cli/inputs.d.ts +13 -0
  17. package/dist/cli/inputs.js +70 -0
  18. package/dist/cli/inputs.js.map +1 -0
  19. package/dist/cli/io.d.ts +79 -0
  20. package/dist/cli/io.js +96 -0
  21. package/dist/cli/io.js.map +1 -0
  22. package/dist/cli/main.d.ts +18 -0
  23. package/dist/cli/main.js +58 -0
  24. package/dist/cli/main.js.map +1 -0
  25. package/dist/cli/method.d.ts +56 -0
  26. package/dist/cli/method.js +108 -0
  27. package/dist/cli/method.js.map +1 -0
  28. package/dist/cli/present.d.ts +43 -0
  29. package/dist/cli/present.js +191 -0
  30. package/dist/cli/present.js.map +1 -0
  31. package/dist/cli/run.d.ts +17 -0
  32. package/dist/cli/run.js +290 -0
  33. package/dist/cli/run.js.map +1 -0
  34. package/dist/cli/script.d.ts +23 -0
  35. package/dist/cli/script.js +212 -0
  36. package/dist/cli/script.js.map +1 -0
  37. package/dist/cli/source.d.ts +49 -0
  38. package/dist/cli/source.js +71 -0
  39. package/dist/cli/source.js.map +1 -0
  40. package/dist/cli.d.ts +10 -0
  41. package/dist/cli.js +65 -0
  42. package/dist/cli.js.map +1 -0
  43. package/dist/client.d.ts +125 -17
  44. package/dist/client.js +383 -109
  45. package/dist/client.js.map +1 -1
  46. package/dist/codegen-check.d.ts +9 -0
  47. package/dist/codegen-check.js +12 -6
  48. package/dist/codegen-check.js.map +1 -1
  49. package/dist/error-models.d.ts +60 -2
  50. package/dist/error-models.js +169 -3
  51. package/dist/error-models.js.map +1 -1
  52. package/dist/error-verdicts.d.ts +34 -0
  53. package/dist/error-verdicts.js +69 -0
  54. package/dist/error-verdicts.js.map +1 -0
  55. package/dist/errors.d.ts +250 -48
  56. package/dist/errors.js +330 -64
  57. package/dist/errors.js.map +1 -1
  58. package/dist/hooks/validate-client.d.ts +3 -3
  59. package/dist/hooks/validate-client.js +3 -3
  60. package/dist/index.d.ts +4 -4
  61. package/dist/index.js +3 -2
  62. package/dist/index.js.map +1 -1
  63. package/dist/prepare-inputs.d.ts +6 -0
  64. package/dist/prepare-inputs.js +46 -14
  65. package/dist/prepare-inputs.js.map +1 -1
  66. package/dist/runs.d.ts +28 -1
  67. package/dist/runs.js +2 -1
  68. package/dist/runs.js.map +1 -1
  69. package/dist/upload-grant.d.ts +15 -10
  70. package/dist/upload-grant.js +36 -17
  71. package/dist/upload-grant.js.map +1 -1
  72. package/dist/upload.d.ts +6 -0
  73. package/dist/upload.js +25 -7
  74. package/dist/upload.js.map +1 -1
  75. package/dist/user-agent.d.ts +3 -2
  76. package/dist/user-agent.js +3 -2
  77. package/dist/user-agent.js.map +1 -1
  78. package/dist/version.d.ts +1 -1
  79. package/dist/version.js +1 -1
  80. package/docs/architecture.md +15 -9
  81. package/docs/artifact-download.md +3 -3
  82. package/docs/cli.md +123 -0
  83. package/docs/client-identification.md +1 -1
  84. package/docs/errors.md +96 -11
  85. package/docs/input-preparation.md +16 -8
  86. package/docs/run-results.md +20 -0
  87. package/package.json +5 -1
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The `pipelex-sdk` command: `run` runs a method and prints its main output, `script` writes the
3
+ * per-method shell script. `docs/cli.md` describes both, and `tests/fixtures/cli-cases.json`
4
+ * records what each prints for every case, which the Python twin answers too.
5
+ *
6
+ * Nothing in the SDK imports this module or its siblings, and the package entry does not export
7
+ * them (`.dependency-cruiser.cjs`): the command sits at the top of the dependency graph, and reaches
8
+ * the SDK only through its public barrel, as any other caller would.
9
+ */
10
+ import { SDK_VERSION } from "../index.js";
11
+ import { MAIN_HELP } from "./help.js";
12
+ import { EXIT_OK, usageError, writeLines } from "./io.js";
13
+ import { presentError } from "./present.js";
14
+ import { runCommandRun } from "./run.js";
15
+ import { runCommandScript } from "./script.js";
16
+ /**
17
+ * Run the command on `argv`, the arguments after the command's own name, and return its exit
18
+ * code: 0 when it did what it was asked, 1 when the run failed or the API refused it, 2 for a
19
+ * usage error and 130 when interrupted. Every failure is printed on stderr before it returns; it
20
+ * never throws.
21
+ */
22
+ export async function runCommand(argv, io) {
23
+ try {
24
+ const [command, ...rest] = argv;
25
+ switch (command) {
26
+ case undefined:
27
+ throw usageError("name a command: run or script.", [
28
+ "Run 'pipelex-sdk --help' to see what each does.",
29
+ ]);
30
+ case "--help":
31
+ case "-h":
32
+ // The help wins whatever follows it, as it does in a subcommand.
33
+ io.writeStdout(MAIN_HELP);
34
+ return EXIT_OK;
35
+ case "--version":
36
+ // Unlike the help, the version is not printed over a command line it does not answer.
37
+ if (rest.length > 0) {
38
+ throw usageError(`unexpected argument "${rest[0]}" after --version.`, [
39
+ "Run 'pipelex-sdk --version' alone to print the version.",
40
+ ]);
41
+ }
42
+ io.writeStdout(`${SDK_VERSION}\n`);
43
+ return EXIT_OK;
44
+ case "run":
45
+ return await runCommandRun(rest, io);
46
+ case "script":
47
+ return await runCommandScript(rest, io);
48
+ default:
49
+ throw usageError(command.startsWith("-") ? `unknown option ${command}.` : `unknown command "${command}".`, ["The commands are run and script. Run 'pipelex-sdk --help' to see what each does."]);
50
+ }
51
+ }
52
+ catch (error) {
53
+ const presented = presentError(error);
54
+ writeLines(io, presented.lines);
55
+ return presented.exitCode;
56
+ }
57
+ }
58
+ //# sour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KAAK,QAAQ;gBACX,OAAO,MAAM,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC1C;gBACE,MAAM,UAAU,CACd,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,kBAAkB,OAAO,GAAG,CAAC,CAAC,CAAC,oBAAoB,OAAO,IAAI,EACxF,CAAC,kFAAkF,CAAC,CACrF,CAAC;QACN,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACtC,UAAU,CAAC,EAAE,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;QAChC,OAAO,SAAS,CAAC,QAAQ,CAAC;IAC5B,CAAC;AACH,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * How the command names a method and a pipe: the forms of `--method`, the qualified form of
3
+ * `--pipe`, and the names and quoting `script` derives from them.
4
+ */
5
+ /** The prefix of a published method's address. */
6
+ export declare const ADDRESS_PREFIX = "github.com/";
7
+ /** The prefix of a stored method's catalog id. */
8
+ export declare const CATALOG_ID_PREFIX = "mt_";
9
+ /** A `--method` value, told apart by its shape alone. */
10
+ export type MethodSelector = {
11
+ readonly kind: "address";
12
+ readonly methodRef: string;
13
+ } | {
14
+ readonly kind: "catalog";
15
+ readonly methodId: string;
16
+ } | {
17
+ readonly kind: "path";
18
+ readonly path: string;
19
+ };
20
+ /**
21
+ * Tell a `--method` value's form by its shape: `mt_…` is a catalog id, `github.com/…` an address,
22
+ * and anything else a path to a `.mthds` file or a bundle directory. A file or directory that
23
+ * happens to be named `mt_…` is reached as `./mt_…`, so that what a value names never depends on
24
+ * what the current directory holds.
25
+ *
26
+ * @throws {CommandError} A usage error for an `mt_…` value holding a character no catalog id
27
+ * holds (a letter, a digit, `_` or `-`), such as `mt_review.mthds`, which is a path written
28
+ * without its `./`.
29
+ */
30
+ export declare function classifyMethod(value: string): MethodSelector;
31
+ /**
32
+ * Hold `--pipe` to the qualified ref, `domain.pipe_code`, which the input preparation and the
33
+ * pipe I/O route require. A bare code is refused, and so is an `alias->domain.pipe_code` ref,
34
+ * which names a dependency package's pipe rather than one of the method's own.
35
+ */
36
+ export declare function checkPipeRef(value: string): void;
37
+ /** Whether a value holds a control character, which no line of a written script may carry. */
38
+ export declare function hasControlCharacter(value: string): boolean;
39
+ /**
40
+ * An address's tag, the text after its last `@`, or `undefined` for an address with none. An
41
+ * empty tag counts as none.
42
+ */
43
+ export declare function addressTag(methodRef: string): string | undefined;
44
+ /** An address's last path segment, without its tag: the default name of the script it gets. */
45
+ export declare function addressName(methodRef: string): string;
46
+ /**
47
+ * A catalog method's name as a script's file name: decomposed (NFKD), stripped of its combining
48
+ * marks, lowercased, every run of characters outside `a-z` and `0-9` turned into one `-`, and
49
+ * trimmed of `-` at both ends. `Résumé Review (v2)` becomes `resume-review-v2`; a name of no
50
+ * letter or digit becomes the empty string.
51
+ */
52
+ export declare function kebabCase(text: string): string;
53
+ /** Why a script's file name cannot be used, or `undefined` when it can. */
54
+ export declare function scriptNameProblem(name: string): string | undefined;
55
+ /** A value as one single-quoted shell word, an inner `'` spelled `'\''`. */
56
+ export declare function shellQuote(value: string): string;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * How the command names a method and a pipe: the forms of `--method`, the qualified form of
3
+ * `--pipe`, and the names and quoting `script` derives from them.
4
+ */
5
+ import { usageError } from "./io.js";
6
+ /** The prefix of a published method's address. */
7
+ export const ADDRESS_PREFIX = "github.com/";
8
+ /** The prefix of a stored method's catalog id. */
9
+ export const CATALOG_ID_PREFIX = "mt_";
10
+ /** The characters a catalog id is made of, which the API's run route accepts and no other. */
11
+ const CATALOG_ID_SHAPE = /^[A-Za-z0-9_-]+$/;
12
+ /**
13
+ * Tell a `--method` value's form by its shape: `mt_…` is a catalog id, `github.com/…` an address,
14
+ * and anything else a path to a `.mthds` file or a bundle directory. A file or directory that
15
+ * happens to be named `mt_…` is reached as `./mt_…`, so that what a value names never depends on
16
+ * what the current directory holds.
17
+ *
18
+ * @throws {CommandError} A usage error for an `mt_…` value holding a character no catalog id
19
+ * holds (a letter, a digit, `_` or `-`), such as `mt_review.mthds`, which is a path written
20
+ * without its `./`.
21
+ */
22
+ export function classifyMethod(value) {
23
+ if (value.startsWith(CATALOG_ID_PREFIX)) {
24
+ if (!CATALOG_ID_SHAPE.test(value)) {
25
+ throw usageError(`--method "${value}" is not a catalog id: a catalog id holds only letters, digits, _ and -.`, [`To name a local file or directory whose name starts with mt_, write it as ./${value}.`]);
26
+ }
27
+ return { kind: "catalog", methodId: value };
28
+ }
29
+ if (value.startsWith(ADDRESS_PREFIX))
30
+ return { kind: "address", methodRef: value };
31
+ return { kind: "path", path: value };
32
+ }
33
+ /**
34
+ * Hold `--pipe` to the qualified ref, `domain.pipe_code`, which the input preparation and the
35
+ * pipe I/O route require. A bare code is refused, and so is an `alias->domain.pipe_code` ref,
36
+ * which names a dependency package's pipe rather than one of the method's own.
37
+ */
38
+ export function checkPipeRef(value) {
39
+ if (value.includes("->")) {
40
+ throw usageError(`--pipe "${value}" names a dependency package's pipe; name one of the method's own pipes as domain.pipe_code.`);
41
+ }
42
+ if (!value.includes(".")) {
43
+ throw usageError(`--pipe takes a pipe's qualified ref, domain.pipe_code, and "${value}" has no domain.`, [`Write it as <domain>.${value}, the domain being the one its .mthds file declares.`]);
44
+ }
45
+ }
46
+ /** Whether a value holds a control character, which no line of a written script may carry. */
47
+ export function hasControlCharacter(value) {
48
+ for (let index = 0; index < value.length; index += 1) {
49
+ const code = value.charCodeAt(index);
50
+ if (code < 0x20 || code === 0x7f)
51
+ return true;
52
+ }
53
+ return false;
54
+ }
55
+ /**
56
+ * An address's tag, the text after its last `@`, or `undefined` for an address with none. An
57
+ * empty tag counts as none.
58
+ */
59
+ export function addressTag(methodRef) {
60
+ const at = methodRef.lastIndexOf("@");
61
+ if (at < 0)
62
+ return undefined;
63
+ const tag = methodRef.slice(at + 1);
64
+ return tag === "" ? undefined : tag;
65
+ }
66
+ /** An address's last path segment, without its tag: the default name of the script it gets. */
67
+ export function addressName(methodRef) {
68
+ const at = methodRef.lastIndexOf("@");
69
+ const base = at < 0 ? methodRef : methodRef.slice(0, at);
70
+ const segments = base.split("/").filter((segment) => segment !== "");
71
+ return segments[segments.length - 1] ?? "";
72
+ }
73
+ /**
74
+ * A catalog method's name as a script's file name: decomposed (NFKD), stripped of its combining
75
+ * marks, lowercased, every run of characters outside `a-z` and `0-9` turned into one `-`, and
76
+ * trimmed of `-` at both ends. `Résumé Review (v2)` becomes `resume-review-v2`; a name of no
77
+ * letter or digit becomes the empty string.
78
+ */
79
+ export function kebabCase(text) {
80
+ return text
81
+ .normalize("NFKD")
82
+ .replace(/\p{M}/gu, "")
83
+ .toLowerCase()
84
+ .replace(/[^a-z0-9]+/g, "-")
85
+ .replace(/^-+|-+$/g, "");
86
+ }
87
+ /** Why a script's file name cannot be used, or `undefined` when it can. */
88
+ export function scriptNameProblem(name) {
89
+ if (name === "")
90
+ return "is empty";
91
+ if (name === "." || name === "..")
92
+ return `"${name}" names a directory`;
93
+ if (name.includes("/"))
94
+ return `"${name}" holds a /, and --dir is where the script goes`;
95
+ // On every platform, so both SDKs refuse the same names: Windows reads a \ as a /, and
96
+ // `..\outside` would leave --dir there.
97
+ if (name.includes("\\")) {
98
+ return `"${name}" holds a \\, which Windows reads as a /, and --dir is where the script goes`;
99
+ }
100
+ if (hasControlCharacter(name))
101
+ return "holds a control character";
102
+ return undefined;
103
+ }
104
+ /** A value as one single-quoted shell word, an inner `'` spelled `'\''`. */
105
+ export function shellQuote(value) {
106
+ return `'${value.replaceAll("'", "'\\''")}'`;
107
+ }
108
+ //# sourceMappingURL=method.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method.js","sourceRoot":"","sources":["../../src/cli/method.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,kDAAkD;AAClD,MAAM,CAA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AO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,UAAU,CAAC;IACnC,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,IAAI,qBAAqB,CAAC;IACxE,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,IAAI,iDAAiD,CAAC;IACzF,uFAAuF;IACvF,wCAAwC;IACxC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,IAAI,8EAA8E,CAAC;IAChG,CAAC;IACD,IAAI,mBAAmB,CAAC,IAAI,CAAC;QAAE,OAAO,2BAA2B,CAAC;IAClE,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * What the command prints: a finished run's result on stdout, and every failure on stderr.
3
+ *
4
+ * A failure is worded by the command from the error's typed fields, never from an SDK message
5
+ * whose wording is the SDK's own, wherever the fields carry what a person needs: the API's reason,
6
+ * the next step it advises and the request id support asks for. That keeps the two commands, this
7
+ * one and its Python twin, saying the same thing for the same answer, which is what the recorded
8
+ * case table holds them to.
9
+ */
10
+ import type { ValidationErrorItem } from "../index.js";
11
+ import type { CommandIO } from "./io.js";
12
+ /** A failure as the command prints it: its lines, and the exit code it ends with. */
13
+ export interface PresentedError {
14
+ readonly lines: readonly string[];
15
+ readonly exitCode: number;
16
+ }
17
+ /** Word any failure for stderr and choose its exit code. */
18
+ export declare function presentError(error: unknown): PresentedError;
19
+ /** The first line of a method that does not load, after `Error: `. */
20
+ export declare const METHOD_DOES_NOT_LOAD_SENTENCE = "the method does not load.";
21
+ /**
22
+ * The lines under "the method does not load": one per validation item that carries a string
23
+ * `category` and `message`, the rule the SDK reads a failed load's items by, and when there is
24
+ * none, the answer's own message.
25
+ */
26
+ export declare function loadFailureLines(items: unknown, message: unknown): string[];
27
+ /** One validation error, as an indented line naming its file when it has one. */
28
+ export declare function validationLine(item: Pick<ValidationErrorItem, "message"> & {
29
+ source?: unknown;
30
+ }): string;
31
+ /**
32
+ * Whether a run's main output is the absence of one: nothing at all, or the runtime's absence
33
+ * document, matched by its whole shape (exactly its keys, each of the type the runtime writes) and
34
+ * never by its `absent` key alone, since a method's own output may carry such a field. The same
35
+ * rule `cli-python` applies.
36
+ */
37
+ export declare function isAbsence(mainStuff: unknown): boolean;
38
+ /**
39
+ * Print a finished run's main output on stdout, as the method produced it: indented JSON,
40
+ * unvalidated and unrepaired, a list included whichever shape it arrived in. An output the method
41
+ * left absent prints `null`, and a line on stderr says so.
42
+ */
43
+ export declare function printResult(mainStuff: unknown, io: CommandIO): void;
@@ -0,0 +1,191 @@
1
+ /**
2
+ * What the command prints: a finished run's result on stdout, and every failure on stderr.
3
+ *
4
+ * A failure is worded by the command from the error's typed fields, never from an SDK message
5
+ * whose wording is the SDK's own, wherever the fields carry what a person needs: the API's reason,
6
+ * the next step it advises and the request id support asks for. That keeps the two commands, this
7
+ * one and its Python twin, saying the same thing for the same answer, which is what the recorded
8
+ * case table holds them to.
9
+ */
10
+ import { ApiResponseError, ApiUnreachableError, InputPreparationError, InvalidInputValueError, InvalidLocalSourceError, MethodLoadError, PipelineRequestError, RejectedAssetError, RunFailedError, UnsupportedUploadCapabilityError, UploadAuthenticationError, UploadTransportError, } from "../index.js";
11
+ import { CommandError, EXIT_FAILED, EXIT_USAGE } from "./io.js";
12
+ /** Word any failure for stderr and choose its exit code. */
13
+ export function presentError(error) {
14
+ if (error instanceof CommandError) {
15
+ const first = error.bare ? error.message : `Error: ${error.message}`;
16
+ return { lines: [first, ...error.details], exitCode: error.exitCode };
17
+ }
18
+ if (error instanceof RunFailedError) {
19
+ const report = error.error;
20
+ const lines = [`Error: run ${error.runId} ended with status ${error.status}.`];
21
+ lines.push(`Reason: ${report?.message ?? error.message}`);
22
+ if (report?.user_action?.detail)
23
+ lines.push(`Next step: ${report.user_action.detail}`);
24
+ return { lines, exitCode: EXIT_FAILED };
25
+ }
26
+ if (error instanceof InvalidLocalSourceError) {
27
+ // A file the inputs name that cannot be read is the inputs' fault, as an unreadable inputs
28
+ // file is, so it is a usage error.
29
+ return {
30
+ lines: [
31
+ `Error: ${error.message}`,
32
+ "A relative path in the inputs resolves against the current directory.",
33
+ ],
34
+ exitCode: EXIT_USAGE,
35
+ };
36
+ }
37
+ if (error instanceof InvalidInputValueError) {
38
+ // A value at a file input that is no file, such as a data: URL that does not decode or a
39
+ // number, is the inputs' fault too.
40
+ return {
41
+ lines: [
42
+ "Error: the inputs hold a value at a file input that cannot be read as a file.",
43
+ `Reason: ${error.message}`,
44
+ FILE_INPUT_FORMS,
45
+ ],
46
+ exitCode: EXIT_USAGE,
47
+ };
48
+ }
49
+ if (error instanceof MethodLoadError) {
50
+ // The same lines whichever route said so: the input preparation here, the pipe I/O call of
51
+ // `--inputs-template` and `script` in `source.ts`.
52
+ return {
53
+ lines: [
54
+ METHOD_DOES_NOT_LOAD,
55
+ ...loadFailureLines(error.validationErrors, error.serverMessage),
56
+ ],
57
+ exitCode: EXIT_FAILED,
58
+ };
59
+ }
60
+ if (error instanceof RejectedAssetError ||
61
+ error instanceof UploadAuthenticationError ||
62
+ error instanceof UnsupportedUploadCapabilityError ||
63
+ error instanceof UploadTransportError) {
64
+ return presentUploadFailure(error);
65
+ }
66
+ if (error instanceof InputPreparationError && error.cause instanceof ApiResponseError) {
67
+ return presentRefusal(error.cause);
68
+ }
69
+ if (error instanceof ApiResponseError) {
70
+ return presentRefusal(error);
71
+ }
72
+ if (error instanceof ApiUnreachableError) {
73
+ return {
74
+ lines: [
75
+ `Error: could not reach the Pipelex API at ${error.apiUrl} (${error.code ?? "network error"}).`,
76
+ ],
77
+ exitCode: EXIT_FAILED,
78
+ };
79
+ }
80
+ if (error instanceof PipelineRequestError) {
81
+ return { lines: [`Error: ${error.message}`], exitCode: EXIT_FAILED };
82
+ }
83
+ const detail = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
84
+ return { lines: [`Error: unexpected failure, ${detail}`], exitCode: EXIT_FAILED };
85
+ }
86
+ /**
87
+ * A file the inputs name that could not be uploaded: which file, the status the upload route
88
+ * answered when it answered, and the SDK's own sentence, which says what the status means for an
89
+ * upload (a file past the size limit, a deployment without upload), followed by the advice and the
90
+ * request id of the API's answer when it carries them.
91
+ */
92
+ function presentUploadFailure(error) {
93
+ const cause = error.cause instanceof ApiResponseError ? error.cause : undefined;
94
+ const status = "status" in error && typeof error.status === "number" ? error.status : cause?.status;
95
+ const what = error.filename === undefined ? "an upload failed" : `the upload of "${error.filename}" failed`;
96
+ const lines = [`Error: ${what}${status === undefined ? "" : ` (status ${status})`}.`];
97
+ lines.push(`Reason: ${error.message}`);
98
+ if (cause?.userAction?.detail)
99
+ lines.push(`Next step: ${cause.userAction.detail}`);
100
+ if (cause?.requestId)
101
+ lines.push(`Request id: ${cause.requestId}`);
102
+ return { lines, exitCode: EXIT_FAILED };
103
+ }
104
+ /** An answer the API gave instead of a result: its status, its reason and its advice. */
105
+ function presentRefusal(error) {
106
+ const lines = error.status >= 200 && error.status < 300
107
+ ? [`Error: the API's answer could not be read (status ${error.status}).`]
108
+ : [`Error: the API refused the request (status ${error.status}).`];
109
+ lines.push(`Reason: ${error.serverMessage ?? error.title ?? "the answer gives no reason"}`);
110
+ for (const item of error.validationErrors ?? [])
111
+ lines.push(validationLine(item));
112
+ if (error.userAction?.detail)
113
+ lines.push(`Next step: ${error.userAction.detail}`);
114
+ if (error.requestId)
115
+ lines.push(`Request id: ${error.requestId}`);
116
+ return { lines, exitCode: EXIT_FAILED };
117
+ }
118
+ /** What a file input takes, the hint under a value it cannot take. */
119
+ const FILE_INPUT_FORMS = 'A file input takes a local path, an http(s) or pipelex-storage:// URL, a data: URL, or an object whose "url" is one of these.';
120
+ /** The first line of a method that does not load, after `Error: `. */
121
+ export const METHOD_DOES_NOT_LOAD_SENTENCE = "the method does not load.";
122
+ const METHOD_DOES_NOT_LOAD = `Error: ${METHOD_DOES_NOT_LOAD_SENTENCE}`;
123
+ /**
124
+ * The lines under "the method does not load": one per validation item that carries a string
125
+ * `category` and `message`, the rule the SDK reads a failed load's items by, and when there is
126
+ * none, the answer's own message.
127
+ */
128
+ export function loadFailureLines(items, message) {
129
+ const lines = (Array.isArray(items) ? items : []).filter(isLoadItem).map(validationLine);
130
+ if (lines.length === 0) {
131
+ lines.push(` - ${typeof message === "string" ? message : "the answer gives no reason"}`);
132
+ }
133
+ return lines;
134
+ }
135
+ function isLoadItem(value) {
136
+ return (isPlainObject(value) && typeof value.category === "string" && typeof value.message === "string");
137
+ }
138
+ /** One validation error, as an indented line naming its file when it has one. */
139
+ export function validationLine(item) {
140
+ const source = typeof item.source === "string" && item.source !== "" ? `${item.source}: ` : "";
141
+ return ` - ${source}${item.message}`;
142
+ }
143
+ /** The keys of the runtime's absence document, and no other. */
144
+ const ABSENCE_KEYS = ["absent", "variable_name", "kind", "reason", "producing_pipe", "upstream"];
145
+ const ABSENCE_KINDS = ["declared_absent", "skipped", "not_provided"];
146
+ function isPlainObject(value) {
147
+ return typeof value === "object" && value !== null && !Array.isArray(value);
148
+ }
149
+ /**
150
+ * Whether a run's main output is the absence of one: nothing at all, or the runtime's absence
151
+ * document, matched by its whole shape (exactly its keys, each of the type the runtime writes) and
152
+ * never by its `absent` key alone, since a method's own output may carry such a field. The same
153
+ * rule `cli-python` applies.
154
+ */
155
+ export function isAbsence(mainStuff) {
156
+ if (mainStuff === null || mainStuff === undefined)
157
+ return true;
158
+ if (!isPlainObject(mainStuff))
159
+ return false;
160
+ const keys = Object.keys(mainStuff);
161
+ if (keys.length !== ABSENCE_KEYS.length || !ABSENCE_KEYS.every((key) => keys.includes(key))) {
162
+ return false;
163
+ }
164
+ const { absent, variable_name, kind, reason, producing_pipe, upstream } = mainStuff;
165
+ return (absent === true &&
166
+ typeof variable_name === "string" &&
167
+ typeof kind === "string" &&
168
+ ABSENCE_KINDS.includes(kind) &&
169
+ typeof reason === "string" &&
170
+ (producing_pipe === null || typeof producing_pipe === "string") &&
171
+ (upstream === null || isPlainObject(upstream)));
172
+ }
173
+ /**
174
+ * Print a finished run's main output on stdout, as the method produced it: indented JSON,
175
+ * unvalidated and unrepaired, a list included whichever shape it arrived in. An output the method
176
+ * left absent prints `null`, and a line on stderr says so.
177
+ */
178
+ export function printResult(mainStuff, io) {
179
+ if (isAbsence(mainStuff)) {
180
+ io.writeStdout("null\n");
181
+ if (isPlainObject(mainStuff)) {
182
+ io.writeStderr(`The method left its output "${String(mainStuff.variable_name)}" absent (${String(mainStuff.reason)}), so the result is null.\n`);
183
+ }
184
+ else {
185
+ io.writeStderr("The method produced no output, so the result is null.\n");
186
+ }
187
+ return;
188
+ }
189
+ io.writeStdout(`${JSON.stringify(mainStuff, null, 2)}\n`);
190
+ }
191
+ //# sourceMappingURL=present.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"present.js","sourceRoot":"","sources":["../../src/cli/present.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAShE,4DAA4D;AAC5D,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IAAI,KAAK,Y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`: run one method and print its main output.
3
+ *
4
+ * Every check that needs no request comes first, in this order, so that a mistake costs nothing:
5
+ * the flags, `--pipe`'s form, the method (a path is read from disk), the inputs, the poll interval
6
+ * and the key. Then the inputs are prepared, which uploads each local file at a file input; the
7
+ * run is started through the SDK's start-and-wait, whose `onStarted` gives the run id to stderr
8
+ * as soon as the run exists; and the main output reaches stdout once the run completes, however
9
+ * long that takes.
10
+ */
11
+ import type { CommandIO } from "./io.js";
12
+ /** Run `pipelex-sdk run` and return its exit code. */
13
+ export declare function runCommandRun(args: readonly string[], io: CommandIO): Promise<number>;
14
+ /** The line under a failure that leaves it unknown whether a run was created. */
15
+ export declare const RUN_MAY_HAVE_STARTED_LINE = "A run may have started on the server without the command learning of it, so check before starting it again.";
16
+ /** The line under a failure met while waiting on a run that exists. */
17
+ export declare function runStillGoingLine(runId: string): string;