@nasebanal/cli 1.0.0 → 1.2.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.
package/README.md CHANGED
@@ -127,19 +127,28 @@ nb assurance report upload --dir locust/logs/20261001_090000
127
127
  job land in the same run, and re-running a job replaces its own result.
128
128
  Commit, branch and CI URL are detected the same way; override with `--run-key`,
129
129
  `--commit`, `--branch`, `--ci-url`.
130
- - **Keep the tool's own report (`--attach <file|folder>`):** a CI runner is thrown away
131
- when the job ends, and the summary above is not the tool's report (Playwright's HTML
132
- report, Specmatic's report, a JUnit file with everything in it). `--attach` sends the
133
- original with the result: a file as it is, a folder as a zip made by the CLI (regular
134
- files only, symbolic links are never followed). Up to 20 MiB per result and 200 MiB per
135
- repository; the CLI checks the size before anything is sent. It is **opt-in twice** - nothing is
136
- attached unless you pass it, and the server refuses it (403 `ATTACHMENTS_DISABLED`) until
137
- the spec has turned on "Attaching original reports" in its settings (off by
138
- default). Make sure the report holds no secrets or personal data.
139
- The server only stores it (next to the result's cases, deleted with the result and by
140
- the repository's retention) and offers it as a **download** to the repository's members in
141
- Assurance; it is never opened, unzipped or shown in the browser. A failed attachment
142
- leaves the result reported and the command exits non-zero with the reason.
130
+ - **Keep the tool's own report (`--attach`, `--attach-if-enabled <file|folder>`):** a CI runner
131
+ is thrown away when the job ends, and the summary above is not the tool's report (Playwright's
132
+ HTML report, Specmatic's report, a JUnit file with everything in it). Both options send the
133
+ original with the result: a file as it is, a folder as a zip made by the CLI (regular files
134
+ only, symbolic links are never followed). Up to 20 MiB per result and 200 MiB per spec; the
135
+ CLI checks the size before it sends anything. It is **opt-in twice**: nothing is attached unless
136
+ you ask, and the repository must have attachments on (Repository Management, or
137
+ `nb specs repositories update <id> --attachments on`; off by default). The CLI reads that
138
+ setting first, so a file the repository does not take never leaves the machine; the server
139
+ checks again. Make sure the report holds no secrets or personal data. The server only stores
140
+ it (deleted with the result and by retention) and offers it as a **download**; it is never
141
+ opened, unzipped or shown in the browser. A result is always reported first.
142
+
143
+ | Repository's attachments | `--attach` (the report is required) | `--attach-if-enabled` |
144
+ |---|---|---|
145
+ | on | attaches it | attaches it |
146
+ | off | does not send it, **fails** | does not send it, says so, succeeds |
147
+ | cannot be told | does not send it, **fails** | does not send it, warns, succeeds |
148
+ | on, but attaching fails (size, limit, network) | **fails** | **fails** |
149
+
150
+ To be sure the report is kept, use `--attach`. Reporting the same result again replaces it,
151
+ **including its attached report**: send it again with the same option, or the old one is gone.
143
152
  - **Pass / fail:** JUnit - any failed or errored test fails the suite. Locust - an
144
153
  unhandled task exception, or a failure ratio above `--max-fail-ratio` (default
145
154
  `$LOCUST_MAX_FAIL_RATIO`, else 0), fails it - the same rule as nb-quickstarts'
@@ -148,7 +157,7 @@ nb assurance report upload --dir locust/logs/20261001_090000
148
157
  failure, its message plus the stack trace, so the Assurance screens can list them. Up to
149
158
  5000 cases per suite - over that, failed and skipped tests are kept first and passed ones
150
159
  fill the rest; a failure text is clipped to 2000 characters, and about 1 MB of failure text
151
- is sent in total (names and outcomes always stay). Locust reports have no cases.
160
+ is sent in total (names and outcomes always stay). A Locust report sends one case per endpoint row of the stats CSV: failed when any of its requests failed (the run's pass / fail is the rule above, so a passed run can list a failed endpoint), timed by its 95th percentile, with the counts, median, max and requests per second as the message.
152
161
  - `--dry-run` prints what would be sent and calls nothing.
153
162
 
154
163
  ## Repositories and the API catalog from a pipeline (`nb specs`)
@@ -689,7 +698,20 @@ How it behaves:
689
698
  - **A published tool that is not installed** gets a message with its repository instead of "unknown command".
690
699
  - Names are plain lowercase (`[a-z][a-z0-9-]*`); the first match on `PATH` wins; macOS and Linux only. Anything named `nb-<name>` and executable on your `PATH` runs with your rights, as with any command, so keep `PATH` to directories you trust.
691
700
 
692
- To make your own: an executable `nb-<name>` on `PATH` whose second line is `# nb-<name> - <one line>`.
701
+ To make your own: an executable `nb-<name>` on `PATH` whose second line is `# nb-<name> - <one line>`. To complete below it, see "Tab completion".
702
+
703
+ ## Tab completion
704
+
705
+ ```bash
706
+ # ~/.zshrc, after compinit # ~/.bashrc
707
+ source <(nb completion zsh) source <(nb completion bash)
708
+ ```
709
+
710
+ The `source` line has to come **after** the shell's completion system is started (`compinit`). With oh-my-zsh that means below `source "$ZSH/oh-my-zsh.sh"` (oh-my-zsh runs `compinit` there), so add it at the very end of `~/.zshrc`. Then open a new terminal tab, or run `exec zsh`. `print -r -- ${_comps[nb]}` prints `_nb` once it is registered. Without the line, `nb quick<TAB>` falls back to file names (and may offer a directory such as `nb-quickstarts/`). Needs nb 1.1.0 or later.
711
+
712
+ `nb quick<TAB>` completes to `nb quickstarts`, `nb assu<TAB>` to `nb assurance`, and below a command its sub-commands and (after a `-`) its options. The script only asks `nb __complete <words...>`, so it follows the command tree, the generated API groups included, with no list to keep in step.
713
+
714
+ A tool answers for the words after its name: `nb quickstarts kong re<TAB>` runs `nb-quickstarts --complete kong re`, which prints one candidate per line (the last word is the one being typed). `nb` asks a tool only when its script contains the literal `--complete`, so it never runs an `nb-*` program that did not say it can answer (the same rule as `nb -h`); a tool that fails or takes more than 2 seconds just gives no candidates.
693
715
 
694
716
  ## Adding a New API
695
717
 
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Tab completion: `nb completion zsh|bash` prints a script that asks `nb __complete <words...>` for candidates.
3
+ *
4
+ * The script is thin on purpose; what can be completed lives here, so it follows the command tree (the generated API
5
+ * groups included) without a second list to keep up to date.
6
+ *
7
+ * - The first word: the built-in commands and the tools found on PATH (`nb quick<TAB>` -> `quickstarts`).
8
+ * - Below a built-in command: its sub-commands, or its options after a `-`.
9
+ * - Below a tool: whatever `nb-<tool> --complete <words...>` prints, one candidate per line (the last word is the
10
+ * one being typed). A tool is asked only when its script contains the literal `--complete`: like `nb -h`, this
11
+ * must not run an `nb-*` program that never said it can answer.
12
+ */
13
+ import { execFile } from "node:child_process";
14
+ import { closeSync, openSync, readSync } from "node:fs";
15
+ export const SHELLS = ["zsh", "bash"];
16
+ /** Global options that take a value, so the word after one is not a command. */
17
+ const GLOBAL_OPTIONS_WITH_VALUE = new Set(["--env", "--token"]);
18
+ const TOOL_TIMEOUT_MS = 2000;
19
+ const SCAN_BYTES = 64 * 1024;
20
+ export function completionScript(shell) {
21
+ if (shell === "zsh") {
22
+ return [
23
+ "# nb tab completion (zsh). Add to ~/.zshrc, after compinit: source <(nb completion zsh)",
24
+ "_nb() {",
25
+ " local -a candidates",
26
+ ' candidates=("${(@f)$(nb __complete "${(@)words[2,CURRENT]}" 2>/dev/null)}")',
27
+ " candidates=(${candidates:#})",
28
+ " (( ${#candidates} )) && compadd -- $candidates",
29
+ "}",
30
+ "compdef _nb nb",
31
+ "",
32
+ ].join("\n");
33
+ }
34
+ return [
35
+ "# nb tab completion (bash). Add to ~/.bashrc: source <(nb completion bash)",
36
+ "_nb_complete() {",
37
+ " local IFS=$'\\n'",
38
+ ' COMPREPLY=($(nb __complete "${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))',
39
+ "}",
40
+ "complete -F _nb_complete nb",
41
+ "",
42
+ ].join("\n");
43
+ }
44
+ /** Whether the tool's script says it answers `--complete` (read, never run). */
45
+ export function supportsComplete(file) {
46
+ try {
47
+ const fd = openSync(file, "r");
48
+ try {
49
+ const buf = Buffer.alloc(SCAN_BYTES);
50
+ const n = readSync(fd, buf, 0, buf.length, 0);
51
+ const text = buf.subarray(0, n).toString("utf8");
52
+ return text.startsWith("#!") && text.includes("--complete");
53
+ }
54
+ finally {
55
+ closeSync(fd);
56
+ }
57
+ }
58
+ catch {
59
+ return false;
60
+ }
61
+ }
62
+ /** Ask a tool for candidates: its stdout lines, or nothing when it fails, times out or is silent. */
63
+ export function askTool(plugin, words) {
64
+ return new Promise((resolve) => {
65
+ execFile(plugin.file, ["--complete", ...words], { timeout: TOOL_TIMEOUT_MS, maxBuffer: 1024 * 1024, env: { ...process.env, NB_PLUGIN_NAME: `nb ${plugin.name}` } }, (err, stdout) => resolve(err ? [] : lines(stdout))).stdin?.end();
66
+ });
67
+ }
68
+ function lines(text) {
69
+ return text.split("\n").filter((l) => l !== "");
70
+ }
71
+ function visible(cmd) {
72
+ return cmd.commands.filter((c) => !c._hidden);
73
+ }
74
+ /**
75
+ * The candidates for `words` (what follows `nb`; the last one is being typed, possibly empty).
76
+ * `ask` is how a tool is asked, injected so a test needs no process.
77
+ */
78
+ export async function complete(program, plugins, words, ask = askTool) {
79
+ if (words.length === 0)
80
+ return [];
81
+ const current = words[words.length - 1];
82
+ let prior = words.slice(0, -1);
83
+ // Global options come before the command: `nb --env local assu<TAB>`.
84
+ while (prior.length > 0 && prior[0].startsWith("-")) {
85
+ prior = prior.slice(GLOBAL_OPTIONS_WITH_VALUE.has(prior[0]) ? 2 : 1);
86
+ }
87
+ let names;
88
+ if (prior.length === 0) {
89
+ if (current.startsWith("-")) {
90
+ names = program.options.flatMap((o) => (o.long ? [o.long] : []));
91
+ }
92
+ else {
93
+ names = [...visible(program).map((c) => c.name()), ...plugins.map((p) => p.name)];
94
+ }
95
+ }
96
+ else {
97
+ const builtin = program.commands.find((c) => c.name() === prior[0] || c.aliases().includes(prior[0]));
98
+ const plugin = builtin ? undefined : plugins.find((p) => p.name === prior[0]);
99
+ if (plugin) {
100
+ return supportsComplete(plugin.file) ? ask(plugin, [...prior.slice(1), current]) : [];
101
+ }
102
+ let cmd = builtin;
103
+ for (const w of prior.slice(1)) {
104
+ if (!cmd)
105
+ break;
106
+ if (w.startsWith("-"))
107
+ continue;
108
+ cmd = cmd.commands.find((c) => c.name() === w || c.aliases().includes(w));
109
+ }
110
+ if (!cmd)
111
+ return [];
112
+ names = current.startsWith("-")
113
+ ? cmd.options.flatMap((o) => (o.long ? [o.long] : []))
114
+ : visible(cmd).map((c) => c.name());
115
+ }
116
+ return [...new Set(names)].filter((n) => n.startsWith(current)).sort();
117
+ }
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ import { attachMonitorSpecOptions } from "./reports/monitors.js";
18
18
  import { attachSpecsCommands, buildSpecsCommand } from "./specs/command.js";
19
19
  import { buildUpgradeCommand, startUpdateNotifier } from "./update.js";
20
20
  import { findPlugins, missingMessage, pluginCall, pluginHelp, runPlugin } from "./plugins.js";
21
+ import { SHELLS, complete, completionScript } from "./completion.js";
21
22
  // Single source of truth for the version: package.json (dist/ and src/ both sit
22
23
  // next to it). A hard-coded string here drifts from the release tag.
23
24
  const { version } = createRequire(import.meta.url)("../package.json");
@@ -32,6 +33,18 @@ program
32
33
  .showHelpAfterError();
33
34
  program.addCommand(buildAuthCommand());
34
35
  program.addCommand(buildUpgradeCommand(version));
36
+ program
37
+ .command("completion")
38
+ .description("Print the tab-completion script: source <(nb completion zsh)")
39
+ .argument("<shell>", `shell: ${SHELLS.join(" | ")}`)
40
+ .action((shell) => {
41
+ if (!SHELLS.includes(shell)) {
42
+ printError(new Error(`Unknown shell '${shell}'. Use one of: ${SHELLS.join(", ")}.`));
43
+ process.exitCode = 1;
44
+ return;
45
+ }
46
+ process.stdout.write(completionScript(shell));
47
+ });
35
48
  for (const api of API_CATALOG) {
36
49
  if (!specExists(api.spec)) {
37
50
  // `nb specs push` / `pull` need no contract to run: without one the old standalone group still works.
@@ -70,6 +83,13 @@ const reserved = new Set(["help", ...program.commands.flatMap((c) => [c.name(),
70
83
  program.addHelpText("after", '\n[beta] marks the groups of NASEBANAL Evolution\'s beta: they may change in any release.\nSee README, "Stability and compatibility".');
71
84
  program.addHelpText("after", () => pluginHelp(findPlugins(process.env.PATH, reserved)));
72
85
  async function main() {
86
+ // The shells' completion scripts call `nb __complete <words...>`: one candidate per line, nothing else on stdout.
87
+ if (process.argv[2] === "__complete") {
88
+ const candidates = await complete(program, findPlugins(process.env.PATH, reserved), process.argv.slice(3));
89
+ if (candidates.length > 0)
90
+ process.stdout.write(candidates.join("\n") + "\n");
91
+ return;
92
+ }
73
93
  const call = pluginCall(process.argv, process.env.PATH, reserved);
74
94
  if (call) {
75
95
  if ("missing" in call) {
@@ -28,10 +28,38 @@ function num(value) {
28
28
  return Number.isFinite(n) ? n : null;
29
29
  }
30
30
  const round = (n, digits = 2) => Math.round(n * 10 ** digits) / 10 ** digits;
31
+ const isAggregate = (r) => r.Name === "Aggregated" || r.Name === "Total";
32
+ /**
33
+ * An endpoint's row as a case: failed when any of its requests failed (the run's own verdict is separate: it
34
+ * allows a failure ratio), its time the 95th percentile in whole ms, the other numbers in the message.
35
+ */
36
+ function endpointCase(r) {
37
+ const requests = read(r, COLUMNS.requests) ?? 0;
38
+ const failed = read(r, COLUMNS.failures) ?? 0;
39
+ const median = num(r["50%"]) ?? read(r, COLUMNS.median);
40
+ const p95 = num(r["95%"]);
41
+ const max = read(r, COLUMNS.max);
42
+ const rps = num(r["Requests/s"]);
43
+ const parts = [`${requests} requests`, `${failed} failures`];
44
+ if (median !== null)
45
+ parts.push(`median ${round(median)} ms`);
46
+ if (p95 !== null)
47
+ parts.push(`p95 ${round(p95)} ms`);
48
+ if (max !== null)
49
+ parts.push(`max ${round(max)} ms`);
50
+ if (rps !== null)
51
+ parts.push(`${round(rps)} req/s`);
52
+ return {
53
+ name: `${r.Type ?? r.Method ?? ""} ${r.Name ?? ""}`.trim() || "(unnamed request)",
54
+ status: failed > 0 ? "failed" : "passed",
55
+ duration_ms: p95 === null ? null : Math.round(p95),
56
+ message: parts.join(", "),
57
+ };
58
+ }
31
59
  export function summariseLocust(files, maxFailRatio) {
32
60
  const stats = toRecords(files.stats);
33
61
  // The row of all requests together: "Aggregated" (2.x) or "Total" (1.x).
34
- const total = stats.find((r) => r.Name === "Aggregated" || r.Name === "Total");
62
+ const total = stats.find(isAggregate);
35
63
  if (!total)
36
64
  throw new Error('No "Aggregated" (or "Total") row in the stats CSV - is this a Locust *_stats.csv file?');
37
65
  // Without the counts the numbers below would silently be 0, a green result for a report nobody understood: refuse it.
@@ -81,6 +109,7 @@ export function summariseLocust(files, maxFailRatio) {
81
109
  duration_ms,
82
110
  metrics,
83
111
  failures,
112
+ cases: stats.filter((r) => !isAggregate(r)).map(endpointCase),
84
113
  status: reasons.length === 0 ? "passed" : "failed",
85
114
  reasons,
86
115
  };
@@ -202,6 +202,7 @@ export function parseReport(opts) {
202
202
  ...(l.duration_ms !== null ? { duration_ms: l.duration_ms } : {}),
203
203
  metrics: l.metrics,
204
204
  ...(toFailures(l.failures) ? { failures: toFailures(l.failures) } : {}),
205
+ ...(toCases(l.cases) ? { cases: toCases(l.cases) } : {}),
205
206
  },
206
207
  };
207
208
  }
@@ -294,6 +295,17 @@ function resolveFormat(opts, file) {
294
295
  return "junit";
295
296
  return fail("Cannot tell the report format from the file name; pass --format junit|locust");
296
297
  }
298
+ export function attachmentSetting(repository) {
299
+ if (repository.attachments_enabled === true)
300
+ return "enabled";
301
+ return repository.attachments_enabled === false ? "disabled" : "unknown";
302
+ }
303
+ /** Why a report was not sent, and what to do about it. */
304
+ function notSentReason(setting, repositoryId) {
305
+ return setting === "disabled"
306
+ ? `attachments are off for the repository (turn them on in Repository Management, or: nb specs repositories update ${repositoryId} --attachments on)`
307
+ : "the catalog did not say whether attachments are on for the repository";
308
+ }
297
309
  /** `--attach`: a file as it is, or a folder as a zip. Refuses before anything is sent: missing, empty, or too big for the server. */
298
310
  export function prepareAttachment(path, limit = MAX_ATTACHMENT_BYTES) {
299
311
  if (!existsSync(path))
@@ -366,7 +378,8 @@ export function buildReportUploadCommand() {
366
378
  .option("--contract-file <path>", "the contract document the result was produced against (e.g. node_modules/@nasebanal/api-specs-<api>/spec.yaml): its SHA-256 is sent as --spec-hash would, the same hash the catalog keeps for that document. Exclusive with --spec-hash")
367
379
  .option("--metric <key=value>", "an extra number for the suite, repeatable (e.g. --metric high=0 --metric medium=3; for security: critical, high, medium, low, info)", (v, all = []) => [...all, v])
368
380
  .option("--api-version <v>", "by names: the API version (v1, v2) of the spec, part of the spec's key (a new major API version is a new spec). It selects the spec; a result has no API version of its own. Left out, it is the API version of the one spec the rest of the key matches (several: the error lists them). With --all-specs: only the specs at this API version get the result (a release branch feeds its own API version)")
369
- .option("--attach <path>", "keep the tool's own report with the result: a file as it is, or a folder as a zip (up to 20 MiB). The server only stores it and offers it for download; nothing opens it. Nothing is attached unless you pass this, so check the report holds no secrets")
381
+ .option("--attach <path>", "keep the tool's own report with the result: a file as it is, or a folder as a zip (up to 20 MiB). The server only stores it and offers it for download; nothing opens it. Nothing is attached unless you ask, so check the report holds no secrets. The report is required: if the repository's attachments are off (or that cannot be told), the result is still reported, the file is not sent and the command fails")
382
+ .option("--attach-if-enabled <path>", "as --attach, but only when the repository's attachments are on: otherwise the file is not sent, a line says so and the command succeeds. When they are on, a report that cannot be attached still fails the command. Exclusive with --attach")
370
383
  .option("--spec-id <id>", "the spec to report to, by its id in the catalog (default: $NB_SPEC_ID). Keep the id in the pipeline's variable: a rename of the spec or its repository never moves the results. Exclusive with --repository / --component / --spec")
371
384
  .option("--repository <owner/name>", "by names: the repository the spec is tied to (owner/name for a git host). Needs --spec; --component is optional (none = the repository as a whole). The three are checked against each other: the spec must be tied to exactly that repository row. Nothing is created")
372
385
  .option("--component <name>", "by names: the component part of the repository's key (the owner's own name for a part of it, e.g. account-api, web); optional, none = the repository as a whole")
@@ -441,7 +454,12 @@ export function buildReportUploadCommand() {
441
454
  }
442
455
  const ci = detectCi(process.env);
443
456
  const runKey = opts.runKey ?? ci.runKey ?? fail("Cannot determine the run key; pass --run-key");
444
- const attachment = opts.attach !== undefined ? prepareAttachment(opts.attach) : undefined;
457
+ if (opts.attach !== undefined && opts.attachIfEnabled !== undefined)
458
+ fail("--attach and --attach-if-enabled are exclusive: one requires the report to be kept, the other keeps it only when attachments are on");
459
+ const attachPath = opts.attach ?? opts.attachIfEnabled;
460
+ const required = opts.attach !== undefined;
461
+ // A required report is read before anything is sent; an optional one only once the repository says it takes it.
462
+ let attachment = required ? prepareAttachment(opts.attach) : undefined;
445
463
  // Which spec the result is for is settled before anything is sent: an id, or names the catalog turns into one (or, with
446
464
  // --all-specs, every spec of one repository row: only for results that belong to the source).
447
465
  if (opts.allSpecs) {
@@ -476,8 +494,11 @@ export function buildReportUploadCommand() {
476
494
  });
477
495
  const env = opts.env || resolveEnv();
478
496
  const specsConn = { baseUrl: specsBaseUrl(env), token: opts.token || (await resolveAccessToken()), org };
479
- const attachmentNote = attachment ? { attachment: { name: attachment.name, size_bytes: attachment.bytes.length } } : {};
497
+ const noteOf = (a) => (a ? { attachment: { name: a.name, size_bytes: a.bytes.length } } : {});
480
498
  if (opts.dryRun) {
499
+ if (!required && attachPath !== undefined)
500
+ attachment = prepareAttachment(attachPath);
501
+ const attachmentNote = { ...noteOf(attachment), ...(attachment && !required ? { attachment_only_if_enabled: true } : {}) };
481
502
  // Nothing is written. By names the catalog is only read (to say which spec and repository they mean); by id nothing is called.
482
503
  if (opts.allSpecs) {
483
504
  const hits = await resolveRepositorySpecs(specsConn, ref);
@@ -498,16 +519,34 @@ export function buildReportUploadCommand() {
498
519
  const orgHeaders = org === "personal" ? undefined : { "X-Active-Organization-Id": org };
499
520
  const hits = opts.allSpecs ? await resolveRepositorySpecs(specsConn, ref) : [await resolveSpec(specsConn, ref)];
500
521
  const conn = { baseUrl, token: specsConn.token, ...(orgHeaders ? { headers: orgHeaders } : {}) };
522
+ // Whether to send the file is settled per repository before any result goes out: a file the repository does not
523
+ // take never leaves this machine.
524
+ if (!required && attachPath !== undefined && hits.some((h) => attachmentSetting(h.repository) === "enabled"))
525
+ attachment = prepareAttachment(attachPath);
501
526
  const results = [];
527
+ let notKept;
528
+ let attached = false;
502
529
  for (const hit of hits) {
503
530
  const label = `${hit.spec_name} (${hit.repository.provider} ${hit.repository.name}${hit.repository.component ? ` / ${hit.repository.component}` : ""}), id ${hit.spec_id}`;
504
531
  const result = await uploadReport({ conn, specId: hit.spec_id, payload: buildPayload(hit.repository_id) });
505
- if (attachment)
506
- await uploadAttachment(conn, result, attachment);
532
+ const setting = attachPath === undefined ? undefined : attachmentSetting(hit.repository);
533
+ const sent = setting === "enabled" ? attachment : undefined;
534
+ if (sent) {
535
+ await uploadAttachment(conn, result, sent);
536
+ attached = true;
537
+ }
538
+ else if (setting !== undefined && setting !== "enabled") {
539
+ const why = notSentReason(setting, hit.repository_id);
540
+ if (required)
541
+ notKept = why;
542
+ else
543
+ process.stderr.write(`${setting === "unknown" ? "!" : "-"} report not attached: ${why}\n`);
544
+ }
507
545
  results.push(result);
508
546
  process.stderr.write(`✓ ${kind}/${checkedTool} ${parsed.suite.status}: ${parsed.note} -> spec ${label}, run '${runKey}'${result.replaced ? " (replaced)" : ""}` +
509
- `${attachment ? `, attached ${attachment.name} (${(attachment.bytes.length / 1024).toFixed(0)} KiB)` : ""}\n`);
547
+ `${sent ? `, attached ${sent.name} (${(sent.bytes.length / 1024).toFixed(0)} KiB)` : ""}\n`);
510
548
  }
549
+ const attachmentNote = attached ? noteOf(attachment) : {};
511
550
  if (opts.allSpecs) {
512
551
  printJson({ results, ...attachmentNote });
513
552
  exportGithubOutput("spec_ids", results.map((x) => x.spec_id).join(","));
@@ -517,5 +556,8 @@ export function buildReportUploadCommand() {
517
556
  exportGithubOutput("spec_id", results[0].spec_id);
518
557
  }
519
558
  exportGithubOutput("repository_id", results[0].repository_id);
559
+ // After every result is in: a missing report must not cost the pipeline its test results.
560
+ if (notKept)
561
+ throw new Error(`The result was reported, but the attached report was not kept: ${notKept}. The file was not sent`);
520
562
  });
521
563
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nasebanal/cli",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "gcloud-style command-line interface for NASEBANAL APIs, generated from nb-api-specs OpenAPI contracts.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -2,7 +2,7 @@ openapi: 3.0.3
2
2
  info:
3
3
  title: NASEBANAL Assurance API
4
4
  description: "Backend of NASEBANAL Assurance (quality assurance for APIs and web apps, under NASEBANAL Evolution). Authenticates users via Auth0 JWT and Personal Access Tokens (PAT) and integrates with the Account API. External monitoring: register URLs to be probed on an interval, then read availability reports. Test results: report the normalised result of each CI/CD job into a repository (the id nb-specs-api issues), then read its runs and suites. Assurance is a results store keyed by that id: the repository, and every setting of it (the public badge and report, the token of the public links, attachments, the API-version rule), belongs to nb-specs-api, which Assurance asks when a rule needs a setting. 2.0.0 (unreleased) replaced the project by the repository, moved the settings to nb-specs-api and removed the commercial Contracts feature (contracts, deliverables, documents, SLA clause). Every response is wrapped as `{ success, data }` (or `{ success: false, error }`)."
5
- version: 2.0.0
5
+ version: 2.1.0
6
6
  contact:
7
7
  name: NASEBANAL
8
8
  url: https://www.nasebanal.com
@@ -20,6 +20,8 @@ tags:
20
20
  description: User profile endpoints
21
21
  - name: Monitors
22
22
  description: "External monitoring: URLs probed on an interval"
23
+ - name: Probes
24
+ description: "Probes (nb-prober) that check push monitors from inside a private network: registered here, each with its own key"
23
25
  - name: Reports
24
26
  description: Availability reports built from daily rollups and incidents
25
27
  - name: Specs
@@ -131,7 +133,7 @@ paths:
131
133
  - Monitors
132
134
  operationId: createMonitor
133
135
  summary: Create a monitor
134
- description: The URL must be a public http(s) host on port 80, 443, 8080 or 8443; private, loopback, link-local and single-label hosts are refused.
136
+ description: "A `pull` monitor's URL must be a public http(s) host on port 80, 443, 8080 or 8443; private, loopback, link-local and single-label hosts are refused. A `push` monitor is checked by a probe (see `/probes`) from inside the owner's network, so its URL may be a private host: the Worker never requests it, and only its shape is checked (http or https, no credentials, at most 2048 characters). A push monitor needs `probe_id`."
135
137
  requestBody:
136
138
  required: true
137
139
  content:
@@ -296,7 +298,7 @@ paths:
296
298
  - Monitors
297
299
  operationId: checkMonitor
298
300
  summary: Run a check now
299
- description: "Probes the URL immediately and records the outcome. A target that is down still returns 200 with `ok: false` (the check ran). Refused with 429 within 10 seconds of the previous check."
301
+ description: "Probes the URL immediately and records the outcome. A target that is down still returns 200 with `ok: false` (the check ran). Refused with 429 within 10 seconds of the previous check. Refused with 409 `MODE_MISMATCH` for a `push` monitor: the Worker cannot reach its URL, and its probe checks it on its own schedule."
300
302
  responses:
301
303
  "200":
302
304
  description: Check outcome
@@ -331,6 +333,12 @@ paths:
331
333
  $ref: "#/components/responses/Forbidden"
332
334
  "404":
333
335
  $ref: "#/components/responses/NotFound"
336
+ "409":
337
+ description: The monitor is not a pull monitor (`MODE_MISMATCH`)
338
+ content:
339
+ application/json:
340
+ schema:
341
+ $ref: "#/components/schemas/Error"
334
342
  "429":
335
343
  description: Checked moments ago (`RATE_LIMITED`)
336
344
  content:
@@ -446,6 +454,341 @@ paths:
446
454
  $ref: "#/components/responses/Forbidden"
447
455
  "404":
448
456
  $ref: "#/components/responses/NotFound"
457
+ /api/v1/probes:
458
+ get:
459
+ tags:
460
+ - Probes
461
+ operationId: listProbes
462
+ summary: List probes
463
+ description: The probes of the caller's namespace, by name, each with its status, its last heartbeat and how many monitors use it.
464
+ parameters:
465
+ - $ref: "#/components/parameters/ActiveOrganization"
466
+ responses:
467
+ "200":
468
+ description: Probes
469
+ content:
470
+ application/json:
471
+ schema:
472
+ type: object
473
+ required:
474
+ - success
475
+ - data
476
+ properties:
477
+ success:
478
+ type: boolean
479
+ example: true
480
+ data:
481
+ type: object
482
+ required:
483
+ - data
484
+ - total
485
+ - limit
486
+ properties:
487
+ data:
488
+ type: array
489
+ items:
490
+ $ref: "#/components/schemas/Probe"
491
+ total:
492
+ type: integer
493
+ limit:
494
+ type: integer
495
+ description: Maximum probes per namespace
496
+ "401":
497
+ $ref: "#/components/responses/Unauthorized"
498
+ "403":
499
+ $ref: "#/components/responses/Forbidden"
500
+ post:
501
+ tags:
502
+ - Probes
503
+ operationId: createProbe
504
+ summary: Register a probe
505
+ description: "Registers a probe and issues its key, which is returned once. Give the key to nb-prober (`NB_PROBER_KEY`): it identifies the probe, and lets it list its own monitors and report their results, nothing else. 409 `PROBE_NAME_TAKEN` when the namespace already has a probe of that name, 409 `LIMIT_REACHED` at 10 probes."
506
+ parameters:
507
+ - $ref: "#/components/parameters/ActiveOrganization"
508
+ requestBody:
509
+ required: true
510
+ content:
511
+ application/json:
512
+ schema:
513
+ $ref: "#/components/schemas/ProbeCreate"
514
+ responses:
515
+ "201":
516
+ description: The probe and its key (shown once)
517
+ content:
518
+ application/json:
519
+ schema:
520
+ type: object
521
+ required:
522
+ - success
523
+ - data
524
+ properties:
525
+ success:
526
+ type: boolean
527
+ example: true
528
+ data:
529
+ $ref: "#/components/schemas/ProbeCreated"
530
+ "400":
531
+ $ref: "#/components/responses/ValidationError"
532
+ "401":
533
+ $ref: "#/components/responses/Unauthorized"
534
+ "403":
535
+ $ref: "#/components/responses/Forbidden"
536
+ "409":
537
+ description: The name is taken in this namespace (`PROBE_NAME_TAKEN`), or the limit of probes is reached (`LIMIT_REACHED`)
538
+ content:
539
+ application/json:
540
+ schema:
541
+ $ref: "#/components/schemas/Error"
542
+ /api/v1/probes/{id}:
543
+ parameters:
544
+ - name: id
545
+ in: path
546
+ required: true
547
+ schema:
548
+ type: string
549
+ description: Probe id
550
+ get:
551
+ tags:
552
+ - Probes
553
+ operationId: getProbe
554
+ summary: Get a probe
555
+ description: One probe of the caller's namespace, with its status and its last heartbeat.
556
+ parameters:
557
+ - $ref: "#/components/parameters/ActiveOrganization"
558
+ responses:
559
+ "200":
560
+ description: Probe
561
+ content:
562
+ application/json:
563
+ schema:
564
+ type: object
565
+ required:
566
+ - success
567
+ - data
568
+ properties:
569
+ success:
570
+ type: boolean
571
+ example: true
572
+ data:
573
+ $ref: "#/components/schemas/Probe"
574
+ "401":
575
+ $ref: "#/components/responses/Unauthorized"
576
+ "403":
577
+ $ref: "#/components/responses/Forbidden"
578
+ "404":
579
+ $ref: "#/components/responses/NotFound"
580
+ patch:
581
+ tags:
582
+ - Probes
583
+ operationId: updateProbe
584
+ summary: Update a probe
585
+ description: Rename it or change its description. The key and the monitors are not touched.
586
+ parameters:
587
+ - $ref: "#/components/parameters/ActiveOrganization"
588
+ requestBody:
589
+ required: true
590
+ content:
591
+ application/json:
592
+ schema:
593
+ $ref: "#/components/schemas/ProbeUpdate"
594
+ responses:
595
+ "200":
596
+ description: The updated probe
597
+ content:
598
+ application/json:
599
+ schema:
600
+ type: object
601
+ required:
602
+ - success
603
+ - data
604
+ properties:
605
+ success:
606
+ type: boolean
607
+ example: true
608
+ data:
609
+ $ref: "#/components/schemas/Probe"
610
+ "400":
611
+ $ref: "#/components/responses/ValidationError"
612
+ "401":
613
+ $ref: "#/components/responses/Unauthorized"
614
+ "403":
615
+ $ref: "#/components/responses/Forbidden"
616
+ "404":
617
+ $ref: "#/components/responses/NotFound"
618
+ "409":
619
+ description: PROBE_NAME_TAKEN
620
+ content:
621
+ application/json:
622
+ schema:
623
+ $ref: "#/components/schemas/Error"
624
+ delete:
625
+ tags:
626
+ - Probes
627
+ operationId: deleteProbe
628
+ summary: Delete a probe
629
+ description: "Refused with 409 `PROBE_IN_USE` while a monitor uses it: move or delete those monitors first. Its key stops working at once."
630
+ parameters:
631
+ - $ref: "#/components/parameters/ActiveOrganization"
632
+ responses:
633
+ "200":
634
+ description: Deleted
635
+ content:
636
+ application/json:
637
+ schema:
638
+ type: object
639
+ required:
640
+ - success
641
+ - data
642
+ properties:
643
+ success:
644
+ type: boolean
645
+ example: true
646
+ data:
647
+ type: object
648
+ properties:
649
+ id:
650
+ type: string
651
+ deleted:
652
+ type: boolean
653
+ "401":
654
+ $ref: "#/components/responses/Unauthorized"
655
+ "403":
656
+ $ref: "#/components/responses/Forbidden"
657
+ "404":
658
+ $ref: "#/components/responses/NotFound"
659
+ "409":
660
+ description: A monitor still uses the probe (`PROBE_IN_USE`)
661
+ content:
662
+ application/json:
663
+ schema:
664
+ $ref: "#/components/schemas/Error"
665
+ /api/v1/probes/{id}/key:
666
+ parameters:
667
+ - name: id
668
+ in: path
669
+ required: true
670
+ schema:
671
+ type: string
672
+ description: Probe id
673
+ post:
674
+ tags:
675
+ - Probes
676
+ operationId: rotateProbeKey
677
+ summary: Issue a new key
678
+ description: "Replaces the probe's key: the old one stops working at once, the new one is returned once. Use it when a key was lost or may have leaked."
679
+ parameters:
680
+ - $ref: "#/components/parameters/ActiveOrganization"
681
+ responses:
682
+ "200":
683
+ description: The probe and its new key (shown once)
684
+ content:
685
+ application/json:
686
+ schema:
687
+ type: object
688
+ required:
689
+ - success
690
+ - data
691
+ properties:
692
+ success:
693
+ type: boolean
694
+ example: true
695
+ data:
696
+ $ref: "#/components/schemas/ProbeCreated"
697
+ "401":
698
+ $ref: "#/components/responses/Unauthorized"
699
+ "403":
700
+ $ref: "#/components/responses/Forbidden"
701
+ "404":
702
+ $ref: "#/components/responses/NotFound"
703
+ /api/v1/probe/monitors:
704
+ get:
705
+ tags:
706
+ - Probes
707
+ operationId: listProbeMonitors
708
+ summary: List the probe's monitors (heartbeat)
709
+ description: "Called by nb-prober with its key on every pass. Returns the enabled `push` monitors that use this probe, with the settings it needs (URL, method, expected status, keyword, timeout, interval); the uptime is not computed. It is also the heartbeat: it records `last_seen_at` (at most once a minute) and the version sent in `X-Prober-Version`. Only the probe's key is accepted."
710
+ security:
711
+ - ProbeKey: []
712
+ parameters:
713
+ - name: X-Prober-Version
714
+ in: header
715
+ required: false
716
+ schema:
717
+ type: string
718
+ maxLength: 32
719
+ description: The version of nb-prober (recorded as the probe's `version`).
720
+ responses:
721
+ "200":
722
+ description: The probe's monitors
723
+ content:
724
+ application/json:
725
+ schema:
726
+ type: object
727
+ required:
728
+ - success
729
+ - data
730
+ properties:
731
+ success:
732
+ type: boolean
733
+ example: true
734
+ data:
735
+ type: object
736
+ required:
737
+ - data
738
+ - total
739
+ properties:
740
+ data:
741
+ type: array
742
+ items:
743
+ $ref: "#/components/schemas/Monitor"
744
+ total:
745
+ type: integer
746
+ "401":
747
+ $ref: "#/components/responses/Unauthorized"
748
+ /api/v1/probe/monitors/{id}/results:
749
+ parameters:
750
+ - name: id
751
+ in: path
752
+ required: true
753
+ schema:
754
+ type: string
755
+ description: Monitor id
756
+ post:
757
+ tags:
758
+ - Probes
759
+ operationId: reportProbeResults
760
+ summary: Report check outcomes
761
+ description: "nb-prober reports what it measured for one of its monitors. Recorded exactly like a Worker check: monitor state, incident, daily uptime. Idempotent per `checked_at`: a resend is counted in `duplicates`. Items are applied oldest first. An item older than the monitor's latest check is stored for the history and the daily uptime but changes neither the monitor's state nor its incidents (a backfill must not rewrite the present). 200 even when some items are rejected; look at `rejected`. 404 for a monitor that is not this probe's. Only the probe's key is accepted."
762
+ security:
763
+ - ProbeKey: []
764
+ requestBody:
765
+ required: true
766
+ content:
767
+ application/json:
768
+ schema:
769
+ $ref: "#/components/schemas/MonitorResultsReport"
770
+ responses:
771
+ "200":
772
+ description: Outcome of the batch
773
+ content:
774
+ application/json:
775
+ schema:
776
+ type: object
777
+ required:
778
+ - success
779
+ - data
780
+ properties:
781
+ success:
782
+ type: boolean
783
+ example: true
784
+ data:
785
+ $ref: "#/components/schemas/MonitorResultsAck"
786
+ "400":
787
+ $ref: "#/components/responses/ValidationError"
788
+ "401":
789
+ $ref: "#/components/responses/Unauthorized"
790
+ "404":
791
+ $ref: "#/components/responses/NotFound"
449
792
  /api/v1/report:
450
793
  get:
451
794
  tags:
@@ -1311,6 +1654,11 @@ components:
1311
1654
  scheme: bearer
1312
1655
  bearerFormat: JWT or PAT
1313
1656
  description: Use either an Auth0 JWT token or a Personal Access Token (PAT) starting with `nbpat_`.
1657
+ ProbeKey:
1658
+ type: http
1659
+ scheme: bearer
1660
+ bearerFormat: nbp_ key
1661
+ description: A probe's key (`nbp_...`), issued by `POST /probes`. It is accepted only by the two operations that say so (list the probe's monitors, report their results) and by nothing else.
1314
1662
  schemas:
1315
1663
  User:
1316
1664
  type: object
@@ -1382,8 +1730,9 @@ components:
1382
1730
  - connection_failed
1383
1731
  - unexpected_status
1384
1732
  - keyword_not_found
1733
+ - no_report
1385
1734
  - null
1386
- description: Why a check failed; null when it passed
1735
+ description: "Why a check failed; null when it passed. `no_report` is written by the server only: a push monitor whose probe has sent nothing for its interval plus grace period is recorded as down with it. A report that sends it is refused."
1387
1736
  MonitorSettings:
1388
1737
  type: object
1389
1738
  properties:
@@ -1437,6 +1786,19 @@ components:
1437
1786
  type: string
1438
1787
  nullable: true
1439
1788
  description: The repository the spec is tied to (required when creating one, together with spec_id; nb-specs-api says which one the spec is tied to). Its uptime counts toward that spec's quality gates.
1789
+ mode:
1790
+ allOf:
1791
+ - $ref: "#/components/schemas/MonitorMode"
1792
+ description: "Create-only. Changing it in an update is refused (400): the history of a pull and of a push monitor would mean two different things. Delete the monitor and make a new one."
1793
+ probe_id:
1794
+ type: string
1795
+ nullable: true
1796
+ description: "The probe that checks this monitor: the id of a probe of the same namespace (see `/probes`). Required for a push monitor, null for a pull monitor. 422 `PROBE_NOT_FOUND` when the id is not a probe of the caller's namespace."
1797
+ grace_minutes:
1798
+ type: integer
1799
+ minimum: 1
1800
+ maximum: 1440
1801
+ description: "Push monitors only. A monitor with no report for `interval_minutes` plus this many minutes is recorded as down with the error `no_report`. Default: `interval_minutes`. null on a pull monitor."
1440
1802
  description:
1441
1803
  type: string
1442
1804
  nullable: true
@@ -1525,6 +1887,16 @@ components:
1525
1887
  type: string
1526
1888
  nullable: true
1527
1889
  description: The repository the spec is tied to (required when creating one, together with spec_id; nb-specs-api says which one the spec is tied to). Its uptime counts toward that spec's quality gates.
1890
+ mode:
1891
+ $ref: "#/components/schemas/MonitorMode"
1892
+ probe_id:
1893
+ type: string
1894
+ nullable: true
1895
+ description: "The probe that checks this monitor: the id of a probe of the same namespace (see `/probes`). Required for a push monitor, null for a pull monitor. 422 `PROBE_NOT_FOUND` when the id is not a probe of the caller's namespace."
1896
+ grace_minutes:
1897
+ type: integer
1898
+ nullable: true
1899
+ description: "Push monitors only. A monitor with no report for `interval_minutes` plus this many minutes is recorded as down with the error `no_report`. Default: `interval_minutes`. null on a pull monitor."
1528
1900
  description:
1529
1901
  type: string
1530
1902
  nullable: true
@@ -1538,6 +1910,182 @@ components:
1538
1910
  type: number
1539
1911
  nullable: true
1540
1912
  description: Percent, null before the first check
1913
+ MonitorMode:
1914
+ type: string
1915
+ enum:
1916
+ - pull
1917
+ - push
1918
+ default: pull
1919
+ description: "pull: the Worker requests the URL on the interval (public hosts only). push: a probe inside the owner's network checks the URL and reports the outcome; the Worker never requests the URL."
1920
+ MonitorResultItem:
1921
+ type: object
1922
+ required:
1923
+ - checked_at
1924
+ - ok
1925
+ - response_ms
1926
+ properties:
1927
+ checked_at:
1928
+ type: string
1929
+ format: date-time
1930
+ description: When the probe made the check (the probe's clock, UTC). At most 5 minutes ahead of, and 7 days behind, the server's time.
1931
+ ok:
1932
+ type: boolean
1933
+ status_code:
1934
+ type: integer
1935
+ nullable: true
1936
+ minimum: 100
1937
+ maximum: 599
1938
+ response_ms:
1939
+ type: integer
1940
+ minimum: 0
1941
+ maximum: 600000
1942
+ error:
1943
+ type: string
1944
+ nullable: true
1945
+ enum:
1946
+ - timeout
1947
+ - connection_failed
1948
+ - unexpected_status
1949
+ - keyword_not_found
1950
+ - null
1951
+ description: Required when `ok` is false, null when it is true. `no_report` is refused.
1952
+ MonitorResultsReport:
1953
+ type: object
1954
+ required:
1955
+ - results
1956
+ properties:
1957
+ results:
1958
+ type: array
1959
+ minItems: 1
1960
+ maxItems: 100
1961
+ description: The outcomes, 1 to 100 per request, in any order.
1962
+ items:
1963
+ $ref: "#/components/schemas/MonitorResultItem"
1964
+ MonitorResultsAck:
1965
+ type: object
1966
+ required:
1967
+ - accepted
1968
+ - duplicates
1969
+ - rejected
1970
+ properties:
1971
+ accepted:
1972
+ type: integer
1973
+ description: Items newly stored.
1974
+ duplicates:
1975
+ type: integer
1976
+ description: Items whose `checked_at` was already stored; ignored.
1977
+ rejected:
1978
+ type: array
1979
+ description: Items refused, by position in the request (0-based).
1980
+ items:
1981
+ type: object
1982
+ required:
1983
+ - index
1984
+ - reason
1985
+ properties:
1986
+ index:
1987
+ type: integer
1988
+ reason:
1989
+ type: string
1990
+ enum:
1991
+ - too_old
1992
+ - in_future
1993
+ - invalid_error
1994
+ description: "`too_old`: more than 7 days behind. `in_future`: more than 5 minutes ahead. `invalid_error`: `error` is missing on a failure, set on a success, or `no_report`."
1995
+ monitor:
1996
+ $ref: "#/components/schemas/Monitor"
1997
+ ProbeStatus:
1998
+ type: string
1999
+ enum:
2000
+ - pending
2001
+ - online
2002
+ - offline
2003
+ description: "pending: never seen. online: seen within the last 2 minutes. offline: not seen for more than 2 minutes."
2004
+ Probe:
2005
+ type: object
2006
+ properties:
2007
+ id:
2008
+ type: string
2009
+ name:
2010
+ type: string
2011
+ minLength: 1
2012
+ maxLength: 64
2013
+ pattern: ^[a-z0-9][a-z0-9._-]*$
2014
+ description: The probe's name, chosen by the owner (such as `office-tokyo`). Unique within the namespace. A monitor refers to the probe by `id`, so renaming is safe.
2015
+ description:
2016
+ type: string
2017
+ nullable: true
2018
+ maxLength: 500
2019
+ organization_id:
2020
+ type: integer
2021
+ nullable: true
2022
+ example: null
2023
+ status:
2024
+ $ref: "#/components/schemas/ProbeStatus"
2025
+ last_seen_at:
2026
+ type: string
2027
+ format: date-time
2028
+ nullable: true
2029
+ description: When the probe last asked for its monitors (a heartbeat). Written at most once a minute.
2030
+ offline_since:
2031
+ type: string
2032
+ format: date-time
2033
+ nullable: true
2034
+ description: When the server noticed the probe had gone silent (at most a minute after it crossed the 2-minute line); null while it is online or pending.
2035
+ version:
2036
+ type: string
2037
+ nullable: true
2038
+ description: The version of nb-prober as it last reported it (`X-Prober-Version`); null before the first heartbeat.
2039
+ key_prefix:
2040
+ type: string
2041
+ description: The first characters of the current key, to tell keys apart in the list; never enough to use it.
2042
+ monitor_count:
2043
+ type: integer
2044
+ description: How many monitors use this probe.
2045
+ created_at:
2046
+ type: string
2047
+ format: date-time
2048
+ updated_at:
2049
+ type: string
2050
+ format: date-time
2051
+ ProbeCreate:
2052
+ type: object
2053
+ required:
2054
+ - name
2055
+ properties:
2056
+ name:
2057
+ type: string
2058
+ minLength: 1
2059
+ maxLength: 64
2060
+ pattern: ^[a-z0-9][a-z0-9._-]*$
2061
+ description:
2062
+ type: string
2063
+ nullable: true
2064
+ maxLength: 500
2065
+ ProbeUpdate:
2066
+ type: object
2067
+ minProperties: 1
2068
+ properties:
2069
+ name:
2070
+ type: string
2071
+ minLength: 1
2072
+ maxLength: 64
2073
+ pattern: ^[a-z0-9][a-z0-9._-]*$
2074
+ description:
2075
+ type: string
2076
+ nullable: true
2077
+ maxLength: 500
2078
+ ProbeCreated:
2079
+ type: object
2080
+ required:
2081
+ - probe
2082
+ - key
2083
+ properties:
2084
+ probe:
2085
+ $ref: "#/components/schemas/Probe"
2086
+ key:
2087
+ type: string
2088
+ description: "The probe's key, `nbp_<probe id>_<secret>`. Shown only in this response: only a hash is stored, so a lost key is replaced with `POST /probes/{id}/key`."
1541
2089
  CheckResult:
1542
2090
  type: object
1543
2091
  properties: