@haakco/hostingctl 1.0.377 → 1.0.394

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/dist/main.js CHANGED
@@ -10047,6 +10047,7 @@ var ACCESS_USAGE = [
10047
10047
  " logins Recent logins, as the platform read them from the environment.",
10048
10048
  " recover Reconcile this environment's access from its recorded intent.",
10049
10049
  " user add <uuid> --username <login> --name <name> --public-key-file <path> [--key-name <name>]",
10050
+ " [--read-only <on|off>]",
10050
10051
  " user remove <uuid> --access-user <uuid>",
10051
10052
  "",
10052
10053
  "Every write needs --confirm; --dry-run describes the change without sending it."
@@ -10282,12 +10283,14 @@ async function user$1(context, path, action) {
10282
10283
  const name = context.flags.get("--name");
10283
10284
  if (username === void 0 || name === void 0) throw new UsageError(ACCESS_USAGE);
10284
10285
  const keyName = context.flags.get("--key-name") ?? name;
10285
- return await confirmableWrite(context, `Add access user ${username} to ${path.environmentUuid} with key ${keyName}.`, async () => (await hostingAccessStore({
10286
+ const readOnly = context.flags.has("--read-only") ? onOff$5(context, "--read-only", ACCESS_USAGE) : false;
10287
+ return await confirmableWrite(context, `Add access user ${username} to ${path.environmentUuid} with key ${keyName}${readOnly ? ", read-only" : ""}.`, async () => (await hostingAccessStore({
10286
10288
  path,
10287
10289
  body: {
10288
10290
  desiredGeneration,
10289
10291
  username,
10290
10292
  name,
10293
+ readOnly,
10291
10294
  key: {
10292
10295
  name: keyName,
10293
10296
  publicKey
@@ -10812,38 +10815,14 @@ function required$2(context, flag) {
10812
10815
  return value;
10813
10816
  }
10814
10817
  //#endregion
10815
- //#region src/commands/arguments.ts
10816
- /**
10817
- * The one uuid a positional argument list must hold, or a usage refusal.
10818
- *
10819
- * Every command that takes a uuid has the same requirement — exactly one, present — so the rule and its wording
10820
- * live here rather than in each command. `usage` is the caller's own syntax, appended so the refusal is
10821
- * actionable rather than a bare "bad arguments".
10822
- */
10823
- function oneUuid$7(rest, usage) {
10824
- const [uuid, ...extra] = rest;
10825
- if (uuid === void 0 || uuid === "" || extra.length > 0) throw new UsageError(usage);
10826
- return uuid;
10827
- }
10828
- /**
10829
- * One flag's value, refused before any request rather than sent blank.
10830
- *
10831
- * A required flag that arrives empty would be refused by the API anyway, but refusing here names the flag and
10832
- * the command's own syntax, so the operator fixes the invocation instead of reading a validation body.
10833
- */
10834
- function requiredFlag$2(context, flag, usage) {
10835
- const value = context.flags.get(flag)?.trim() ?? "";
10836
- if (value === "") throw new UsageError(`${flag} is required.\n\n${usage}`);
10837
- return value;
10838
- }
10839
- //#endregion
10840
10818
  //#region src/commands/application-upload.ts
10841
10819
  var USAGE$40 = [
10842
10820
  "Usage: hostingctl application import-upload <environment-uuid> <application-uuid> --company <slug>",
10843
- " --database <path-to.sql> [--archive <path-to.zip> | --directory <dir>]",
10821
+ " --database <path-to.sql> --archive <path-to.zip|path-to.jpa> | --directory <dir>",
10844
10822
  "",
10845
- " --database The site's SQL dump. Required: an import without its database is not a site.",
10846
- " --archive The site's files as one ZIP.",
10823
+ " --database The site's SQL dump. Required unless --archive is an Akeeba backup, which carries its",
10824
+ " own database dump inside the archive.",
10825
+ " --archive The site's files as one ZIP, or an Akeeba backup (.jpa or .jps).",
10847
10826
  " --directory The site's files as a directory. The files are sent one part each, with a JSON manifest",
10848
10827
  " of their relative POSIX paths, because a manifest the runtime could clip would describe",
10849
10828
  " files that never arrived.",
@@ -10855,25 +10834,26 @@ var USAGE$40 = [
10855
10834
  /** `application import-upload`, which stages a client site for review. */
10856
10835
  async function applicationUpload(context, path, rest) {
10857
10836
  if (rest.length > 0) throw new UsageError(USAGE$40);
10858
- const database = requiredFlag$2(context, "--database", USAGE$40);
10837
+ const database = context.flags.get("--database")?.trim() ?? "";
10859
10838
  const archive = context.flags.get("--archive")?.trim() ?? "";
10860
10839
  const directory = context.flags.get("--directory")?.trim() ?? "";
10861
10840
  if (archive !== "" && directory !== "") throw new UsageError(`Send the site files as either --archive or --directory, not both.\n\n${USAGE$40}`);
10862
- const databaseBytes = await sizeOf(database, "database");
10841
+ if (database === "" && !isAkeebaArchive(archive)) throw new UsageError(`--database is required unless --archive is an Akeeba backup (.jpa or .jps), which carries the site's database inside the archive. If --archive is an Akeeba backup renamed .zip, rename it so its own database is used.\n\n${USAGE$40}`);
10842
+ const databaseBytes = database === "" ? 0 : await sizeOf(database, "database");
10863
10843
  const files = directory === "" ? [] : await manifestOf(directory);
10864
10844
  const fileBytes = directory === "" ? 0 : await totalSize(files);
10865
10845
  return {
10866
10846
  kind: "import-write",
10867
10847
  outcome: await confirmableWrite(context, [
10868
- `Stage a site import: ${describe(databaseBytes)} of SQL`,
10869
- archive === "" ? "" : `, ${describe(await sizeOf(archive, "archive"))} of files as a ZIP`,
10848
+ database === "" ? "Stage a site import from an Akeeba backup that carries its own database" : `Stage a site import: ${describe(databaseBytes)} of SQL`,
10849
+ archive === "" ? "" : `, ${describe(await sizeOf(archive, "archive"))} of files as an archive`,
10870
10850
  directory === "" ? "" : `, ${String(files.length)} file(s) totalling ${describe(fileBytes)}`,
10871
10851
  ". The import is staged for review; nothing is applied yet."
10872
10852
  ].join(""), async () => {
10873
10853
  return (await hostingWordpressImportStore({
10874
10854
  path,
10875
10855
  body: {
10876
- database: await partOf(database),
10856
+ database: database === "" ? null : await partOf(database),
10877
10857
  archive: archive === "" ? null : await partOf(archive),
10878
10858
  directory: files.length === 0 ? null : await Promise.all(files.map(async (one) => await partOf(one.absolute))),
10879
10859
  directoryPaths: files.length === 0 ? null : JSON.stringify(files.map((one) => one.relative))
@@ -10883,6 +10863,16 @@ async function applicationUpload(context, path, rest) {
10883
10863
  };
10884
10864
  }
10885
10865
  /**
10866
+ * Whether a chosen archive is an Akeeba backup, which carries the site's database inside it.
10867
+ *
10868
+ * The API decides what a container is from its own bytes; this only decides whether a separate dump is
10869
+ * required before anything is sent, and the name is all the command line has to go on.
10870
+ */
10871
+ function isAkeebaArchive(archive) {
10872
+ const name = archive.toLowerCase();
10873
+ return name.endsWith(".jpa") || name.endsWith(".jps");
10874
+ }
10875
+ /**
10886
10876
  * One part, carrying its own filename.
10887
10877
  *
10888
10878
  * The API refuses a database part that is not a `.sql` dump and an archive that is not a `.zip`, and it says
@@ -11019,10 +11009,13 @@ function applicationImportText(report) {
11019
11009
  if (!outcome.sent) return `Would: ${outcome.description}\nNothing was sent (--dry-run).`;
11020
11010
  const value = outcome.result;
11021
11011
  if (typeof value.message === "string") return `${outcome.description}\n${value.message}`;
11022
- return `${outcome.description}\n${recoveryLines(outcome.result)}`;
11012
+ return typeof value.inputLocation === "string" ? `${outcome.description}\n${importLines(outcome.result)}` : `${outcome.description}\n${recoveryLines(outcome.result)}`;
11023
11013
  }
11024
11014
  if (report.kind === "url-repair") return recoveryLines(report.recovery);
11025
- const { staged } = report;
11015
+ return importLines(report.staged);
11016
+ }
11017
+ /** One staged import as a few readable lines: what it would bring, and what it leaves out and why. */
11018
+ function importLines(staged) {
11026
11019
  return [
11027
11020
  ` import ${staged.uuid} ${String(staged.status)} from ${staged.inputLocation}`,
11028
11021
  ` ${String(staged.fileCount)} files, ${String(Math.round(staged.bundleBytes / 1024))} KiB bundle, ${String(Math.round(staged.databaseBytes / 1024))} KiB database`,
@@ -12080,6 +12073,31 @@ function optionalFlag(context, flag) {
12080
12073
  return value === "" ? null : value;
12081
12074
  }
12082
12075
  //#endregion
12076
+ //#region src/commands/arguments.ts
12077
+ /**
12078
+ * The one uuid a positional argument list must hold, or a usage refusal.
12079
+ *
12080
+ * Every command that takes a uuid has the same requirement — exactly one, present — so the rule and its wording
12081
+ * live here rather than in each command. `usage` is the caller's own syntax, appended so the refusal is
12082
+ * actionable rather than a bare "bad arguments".
12083
+ */
12084
+ function oneUuid$7(rest, usage) {
12085
+ const [uuid, ...extra] = rest;
12086
+ if (uuid === void 0 || uuid === "" || extra.length > 0) throw new UsageError(usage);
12087
+ return uuid;
12088
+ }
12089
+ /**
12090
+ * One flag's value, refused before any request rather than sent blank.
12091
+ *
12092
+ * A required flag that arrives empty would be refused by the API anyway, but refusing here names the flag and
12093
+ * the command's own syntax, so the operator fixes the invocation instead of reading a validation body.
12094
+ */
12095
+ function requiredFlag$2(context, flag, usage) {
12096
+ const value = context.flags.get(flag)?.trim() ?? "";
12097
+ if (value === "") throw new UsageError(`${flag} is required.\n\n${usage}`);
12098
+ return value;
12099
+ }
12100
+ //#endregion
12083
12101
  //#region src/commands/backup-destination-metadata.ts
12084
12102
  /**
12085
12103
  * `backup-destination` — the company's own backup bucket.
@@ -25704,6 +25722,18 @@ var emailExpectedDnsRecordDataSchema = object({
25704
25722
  values: array(string()),
25705
25723
  zoneHostname: string().nullable()
25706
25724
  });
25725
+ var emailRecipientRouteStateDataSchema = object({
25726
+ state: _enum([
25727
+ "configured",
25728
+ "adopted",
25729
+ "external",
25730
+ "local",
25731
+ "foreign",
25732
+ "unobserved"
25733
+ ]).describe("What the last reconciliation observed for a claimed name's recipient route. The route decides where mail addressed to this name is delivered: this installation holds the mailboxes, or another provider named by the public MX receives it. A reader needs to tell \"we send * their mail onward\" apart from \"we never looked\", which is why unobserved is a state rather than an absent value.\n| |\n|---|\n| `configured` <br/> The route is present and carries this platform's ownership marker. |\n| `adopted` <br/> The route was written outside this platform but points at the proved public MX, so it was adopted. |\n| `external` <br/> Another provider receives this name's mail and this installation holds no route for it. |\n| `local` <br/> No route, and the public MX is this installation: recipients are delivered locally. |\n| `foreign` <br/> A route exists that this platform neither owns nor can adopt. It is never overwritten. |\n| `unobserved` <br/> No reconciliation has recorded an observation yet. |").describe("What the last reconciliation observed for a claimed name's recipient route. The route decides where mail addressed to this name is delivered: this installation holds the mailboxes, or another provider named by the public MX receives it. A reader needs to tell \"we send * their mail onward\" apart from \"we never looked\", which is why unobserved is a state rather than an absent value.\n| |\n|---|\n| `configured` <br/> The route is present and carries this platform's ownership marker. |\n| `adopted` <br/> The route was written outside this platform but points at the proved public MX, so it was adopted. |\n| `external` <br/> Another provider receives this name's mail and this installation holds no route for it. |\n| `local` <br/> No route, and the public MX is this installation: recipients are delivered locally. |\n| `foreign` <br/> A route exists that this platform neither owns nor can adopt. It is never overwritten. |\n| `unobserved` <br/> No reconciliation has recorded an observation yet. |"),
25734
+ target: string().nullable(),
25735
+ observedAt: string()
25736
+ });
25707
25737
  var emailDomainSummaryDataSchema = object({
25708
25738
  uuid: string(),
25709
25739
  domainUuid: string(),
@@ -25714,7 +25744,8 @@ var emailDomainSummaryDataSchema = object({
25714
25744
  desiredGeneration: int(),
25715
25745
  releasedAt: string().nullable(),
25716
25746
  checks: array(emailDomainObservedCheckDataSchema),
25717
- expectedDnsRecords: array(emailExpectedDnsRecordDataSchema)
25747
+ expectedDnsRecords: array(emailExpectedDnsRecordDataSchema),
25748
+ recipientRoute: union([emailRecipientRouteStateDataSchema, _null()])
25718
25749
  });
25719
25750
  var emailEnrollmentAvailabilityDataSchema = object({
25720
25751
  available: boolean(),
@@ -27514,6 +27545,22 @@ var hostingToolDataSchema = object({
27514
27545
  url: string(),
27515
27546
  permitted: boolean()
27516
27547
  });
27548
+ var hostingServiceIncidentDataSchema = object({
27549
+ kind: _enum(["application_database_connection"]),
27550
+ reason: union([_enum([
27551
+ "credential_refused",
27552
+ "server_unreachable",
27553
+ "query_failed",
27554
+ "server_error",
27555
+ "probe_failed",
27556
+ "no_database_declared",
27557
+ "extension_missing",
27558
+ "unanswered"
27559
+ ]).describe("The closed set of safe reason codes an application observation can carry. These are the codes the application's own stats reading reports, and the only vocabulary an observer or a client message may name. They deliberately describe what was seen rather than why: `credential_refused` means a server evaluated the credential and refused it, while `server_unreachable` means no server answered — two different repairs, and only the first is about a password. A driver message, a host, a database name or a password never becomes one of these. {@see self::outcome()} owns the one decision each code makes, so the confirmation rule cannot drift between the observer that records a fact and the presentation that explains it.\n| |\n|---|\n| `credential_refused` <br/> MySQL error 1044/1045: a server answered and rejected the credential or the grant. |\n| `server_unreachable` <br/> A client-library code (2000+): the connection never reached a database server. |\n| `query_failed` <br/> The connection and the credential were accepted but the probe query did not answer. |\n| `server_error` <br/> A server answered and could not evaluate the question, for example at its connection ceiling. |\n| `probe_failed` <br/> The probe inside the application could not run at all, so acceptance is unknown. |\n| `no_database_declared` <br/> The application tree declares no database, so there is nothing for it to connect to. |\n| `extension_missing` <br/> The runtime has no MySQL client, so the probe could not be made. |\n| `unanswered` <br/> The application did not answer the reading at all. |"), _null()]),
27560
+ summary: string().describe("The impact in plain language, safe to show a client."),
27561
+ openedAt: string().describe("ISO-8601 UTC instant the outage was confirmed."),
27562
+ lastObservedAt: string().describe("ISO-8601 UTC instant the platform last looked at the resource.")
27563
+ });
27517
27564
  var hostingLastReconcileDataSchema = object({
27518
27565
  status: string(),
27519
27566
  generation: int(),
@@ -27578,6 +27625,7 @@ var hostingEnvironmentDataSchema = object({
27578
27625
  databases: array(hostingDatabaseDataSchema),
27579
27626
  tools: array(hostingToolDataSchema),
27580
27627
  status: hostingEnvironmentStatusDataSchema,
27628
+ serviceIncidents: array(hostingServiceIncidentDataSchema),
27581
27629
  lastReconcile: union([hostingLastReconcileDataSchema, _null()]),
27582
27630
  allocation: hostingAllocationDataSchema,
27583
27631
  namespaceAllocation: hostingAllocationDataSchema,
@@ -29016,11 +29064,11 @@ var storeEmailSendingHoldRequestSchema = object({
29016
29064
  var storeEmailServiceCancellationRequestSchema = object({ serviceEndsAt: string() }).describe("A Company Admin recording a cancellation for the company's email service.\n\nThe service-end date is the only input: the service keeps serving until it, and the service owner\nparses and checks that it is a real, future instant, so a past or malformed value is a field error\non `serviceEndsAt` rather than a made-up deletion time.");
29017
29065
  object({ token: string() });
29018
29066
  var storeHostingApplicationImportRequestSchema = object({
29019
- database: _instanceof(File),
29067
+ database: _instanceof(File).nullish(),
29020
29068
  archive: _instanceof(File).nullish(),
29021
29069
  directory: array(_instanceof(File)).nullish(),
29022
29070
  directoryPaths: string().max(4194304).nullish().describe("The manifest is what makes a directory upload placeable, and it is ONE JSON list rather\nthan a parallel form array: ten thousand paths as form fields is ten thousand input\nvariables, which the runtime clips at `max_input_vars` — silently, and from the end — so\na clipped manifest would describe files that never arrived. The landing owner decodes and\nbounds it; this only fixes its type so the boundary cannot drift.")
29023
- }).describe("One client site upload: its SQL dump, and its files as either a ZIP or a directory.\n\nThe shape is all this validates. Every bound — the aggregate, each part, the file count, the path\nlengths, the expansion — is enforced by the intake owner as the upload is materialized, so a\nrefusal names the actual limit and the same numbers are used whichever part tripped it. Validating\nthem twice would be two places to disagree about what \"too large\" means.\n\n`prepareForValidation` runs first and compares the declared body against the API's own runtime\nceiling, because a request PHP refuses outright arrives as an empty request: without this the person\nwould be told a field is missing rather than which setting refused their site.");
29071
+ }).describe("One client site upload: its files as a ZIP, an Akeeba Backup archive, or a directory, and its SQL dump\nunless the archive carries one.\n\nThe shape is all this validates. Every bound — the aggregate, each part, the file count, the path\nlengths, the expansion — is enforced by the intake owner as the upload is materialized, so a\nrefusal names the actual limit and the same numbers are used whichever part tripped it. Validating\nthem twice would be two places to disagree about what \"too large\" means.\n\nThe one conditional rule is the dump: an Akeeba Backup archive is a whole site and carries its own\ndatabase, so requiring a second `.sql` part for it would be asking for something the client does not\nhave. Whether the archive is one is decided by the same owner that identifies the container, from its\nbytes rather than its name. That condition is not expressible in the declared shape — a schema cannot\nsay \"required unless the other part is one of these containers\" — so the shape states the part as\noptional, which is what the endpoint accepts, and the rule itself is enforced after validation where\nthe uploaded bytes are available. A schema that claimed `required` would be describing a request this\nendpoint refuses to make.\n\n`prepareForValidation` runs first and compares the declared body against the API's own runtime\nceiling, because a request PHP refuses outright arrives as an empty request: without this the person\nwould be told a field is missing rather than which setting refused their site.");
29024
29072
  var storeHostingBackupDestinationRequestSchema = object({
29025
29073
  endpoint: url().max(255),
29026
29074
  bucket: string().max(255).regex(/^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/),
@@ -31327,7 +31375,7 @@ union([
31327
31375
  messageDataSchema,
31328
31376
  messageDataSchema
31329
31377
  ]);
31330
- storeHostingApplicationImportRequestSchema.describe("One client site upload: its SQL dump, and its files as either a ZIP or a directory.\n\nThe shape is all this validates. Every bound — the aggregate, each part, the file count, the path\nlengths, the expansion — is enforced by the intake owner as the upload is materialized, so a\nrefusal names the actual limit and the same numbers are used whichever part tripped it. Validating\nthem twice would be two places to disagree about what \"too large\" means.\n\n`prepareForValidation` runs first and compares the declared body against the API's own runtime\nceiling, because a request PHP refuses outright arrives as an empty request: without this the person\nwould be told a field is missing rather than which setting refused their site.");
31378
+ storeHostingApplicationImportRequestSchema.optional().describe("One client site upload: its files as a ZIP, an Akeeba Backup archive, or a directory, and its SQL dump\nunless the archive carries one.\n\nThe shape is all this validates. Every bound — the aggregate, each part, the file count, the path\nlengths, the expansion — is enforced by the intake owner as the upload is materialized, so a\nrefusal names the actual limit and the same numbers are used whichever part tripped it. Validating\nthem twice would be two places to disagree about what \"too large\" means.\n\nThe one conditional rule is the dump: an Akeeba Backup archive is a whole site and carries its own\ndatabase, so requiring a second `.sql` part for it would be asking for something the client does not\nhave. Whether the archive is one is decided by the same owner that identifies the container, from its\nbytes rather than its name. That condition is not expressible in the declared shape — a schema cannot\nsay \"required unless the other part is one of these containers\" — so the shape states the part as\noptional, which is what the endpoint accepts, and the rule itself is enforced after validation where\nthe uploaded bytes are available. A schema that claimed `required` would be describing a request this\nendpoint refuses to make.\n\n`prepareForValidation` runs first and compares the declared body against the API's own runtime\nceiling, because a request PHP refuses outright arrives as an empty request: without this the person\nwould be told a field is missing rather than which setting refused their site.");
31331
31379
  var hostingWordpressUrlRepairPreviewStatus200Schema = hostingApplicationRecoveryDataSchema;
31332
31380
  var hostingWordpressUrlRepairPreviewStatus201Schema = hostingApplicationRecoveryDataSchema;
31333
31381
  var hostingWordpressUrlRepairPreviewStatus401Schema = object({ message: string().describe("Error overview.") });
@@ -36939,7 +36987,7 @@ function writeUpdateState(state, env = process.env) {
36939
36987
  }
36940
36988
  //#endregion
36941
36989
  //#region src/version.ts
36942
- var VERSION = "1.0.377";
36990
+ var VERSION = "1.0.394";
36943
36991
  //#endregion
36944
36992
  //#region src/commands/update.ts
36945
36993
  /**
@@ -37014,7 +37062,7 @@ var update = {
37014
37062
  }, process.env);
37015
37063
  return {
37016
37064
  ...known,
37017
- current: after ?? "1.0.377",
37065
+ current: after ?? "1.0.394",
37018
37066
  latest: after ?? latest,
37019
37067
  upToDate: after !== null && (latest === null || !isNewerVersion(latest, after)),
37020
37068
  action: "run",
@@ -37289,7 +37337,7 @@ async function printUpdateNotice(options) {
37289
37337
  }, env, { waitMs: NOTICE_LOCK_WAIT_MS });
37290
37338
  } catch {}
37291
37339
  if (latest === null) return;
37292
- if (!isNewerVersion(latest, "1.0.377")) return;
37340
+ if (!isNewerVersion(latest, "1.0.394")) return;
37293
37341
  process.stderr.write(`A newer hostingctl is published: ${latest} (this copy is ${VERSION}). Run \`hostingctl update\` to update.\n`);
37294
37342
  }
37295
37343
  /** Whether an environment variable is set to something, which is how CI and the opt-out are read. */