@haakco/hostingctl 1.0.384 → 1.0.403

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
@@ -909,13 +909,44 @@ function createTransport(target) {
909
909
  };
910
910
  };
911
911
  }
912
+ /** The target the current command was configured with, so a call that legitimately takes minutes can borrow a budget. */
913
+ var activeTarget = null;
912
914
  /** Point the generated client at one target. Called once, before any command runs. */
913
915
  function configureApi(target) {
916
+ activeTarget = target;
914
917
  client.setConfig({
915
918
  baseURL: target.baseURL,
916
919
  transport: createTransport(target)
917
920
  });
918
921
  }
922
+ /**
923
+ * Run one call with a longer request budget than the default.
924
+ *
925
+ * The default bounds a conversational round trip at a minute. An import upload is not one: it streams a site's files
926
+ * and the API stages the entire archive — expanding every entry and normalizing the database — before it answers, so
927
+ * its duration follows the archive rather than the connection. The first real customer backup is 1.6 GiB across 74,150
928
+ * entries, and the default reported that request as unanswered while the server was still working on it. The ordinary
929
+ * budget is restored afterwards, so every later call in the process keeps the tighter limit.
930
+ */
931
+ async function withRequestBudget(timeoutMs, run) {
932
+ if (activeTarget === null) return await run();
933
+ const previous = activeTarget;
934
+ client.setConfig({
935
+ baseURL: previous.baseURL,
936
+ transport: createTransport({
937
+ ...previous,
938
+ timeoutMs
939
+ })
940
+ });
941
+ try {
942
+ return await run();
943
+ } finally {
944
+ client.setConfig({
945
+ baseURL: previous.baseURL,
946
+ transport: createTransport(previous)
947
+ });
948
+ }
949
+ }
919
950
  //#endregion
920
951
  //#region src/platform.ts
921
952
  /** Whether this platform is Windows. */
@@ -10047,6 +10078,7 @@ var ACCESS_USAGE = [
10047
10078
  " logins Recent logins, as the platform read them from the environment.",
10048
10079
  " recover Reconcile this environment's access from its recorded intent.",
10049
10080
  " user add <uuid> --username <login> --name <name> --public-key-file <path> [--key-name <name>]",
10081
+ " [--read-only <on|off>]",
10050
10082
  " user remove <uuid> --access-user <uuid>",
10051
10083
  "",
10052
10084
  "Every write needs --confirm; --dry-run describes the change without sending it."
@@ -10282,12 +10314,14 @@ async function user$1(context, path, action) {
10282
10314
  const name = context.flags.get("--name");
10283
10315
  if (username === void 0 || name === void 0) throw new UsageError(ACCESS_USAGE);
10284
10316
  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({
10317
+ const readOnly = context.flags.has("--read-only") ? onOff$5(context, "--read-only", ACCESS_USAGE) : false;
10318
+ return await confirmableWrite(context, `Add access user ${username} to ${path.environmentUuid} with key ${keyName}${readOnly ? ", read-only" : ""}.`, async () => (await hostingAccessStore({
10286
10319
  path,
10287
10320
  body: {
10288
10321
  desiredGeneration,
10289
10322
  username,
10290
10323
  name,
10324
+ readOnly,
10291
10325
  key: {
10292
10326
  name: keyName,
10293
10327
  publicKey
@@ -10812,38 +10846,14 @@ function required$2(context, flag) {
10812
10846
  return value;
10813
10847
  }
10814
10848
  //#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
10849
  //#region src/commands/application-upload.ts
10841
10850
  var USAGE$40 = [
10842
10851
  "Usage: hostingctl application import-upload <environment-uuid> <application-uuid> --company <slug>",
10843
- " --database <path-to.sql> [--archive <path-to.zip> | --directory <dir>]",
10852
+ " --database <path-to.sql> --archive <path-to.zip|path-to.jpa> | --directory <dir>",
10844
10853
  "",
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.",
10854
+ " --database The site's SQL dump. Required unless --archive is an Akeeba backup, which carries its",
10855
+ " own database dump inside the archive.",
10856
+ " --archive The site's files as one ZIP, or an Akeeba backup (.jpa or .jps).",
10847
10857
  " --directory The site's files as a directory. The files are sent one part each, with a JSON manifest",
10848
10858
  " of their relative POSIX paths, because a manifest the runtime could clip would describe",
10849
10859
  " files that never arrived.",
@@ -10853,36 +10863,50 @@ var USAGE$40 = [
10853
10863
  "what would be uploaded without reading it."
10854
10864
  ].join("\n");
10855
10865
  /** `application import-upload`, which stages a client site for review. */
10866
+ /** How long one import upload may take before the CLI calls it unanswered. */
10867
+ var UPLOAD_REQUEST_BUDGET_MS = 9e5;
10856
10868
  async function applicationUpload(context, path, rest) {
10857
10869
  if (rest.length > 0) throw new UsageError(USAGE$40);
10858
- const database = requiredFlag$2(context, "--database", USAGE$40);
10870
+ const database = context.flags.get("--database")?.trim() ?? "";
10859
10871
  const archive = context.flags.get("--archive")?.trim() ?? "";
10860
10872
  const directory = context.flags.get("--directory")?.trim() ?? "";
10861
10873
  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");
10874
+ 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}`);
10875
+ const databaseBytes = database === "" ? 0 : await sizeOf(database, "database");
10863
10876
  const files = directory === "" ? [] : await manifestOf(directory);
10864
10877
  const fileBytes = directory === "" ? 0 : await totalSize(files);
10865
10878
  return {
10866
10879
  kind: "import-write",
10867
10880
  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`,
10881
+ database === "" ? "Stage a site import from an Akeeba backup that carries its own database" : `Stage a site import: ${describe(databaseBytes)} of SQL`,
10882
+ archive === "" ? "" : `, ${describe(await sizeOf(archive, "archive"))} of files as an archive`,
10870
10883
  directory === "" ? "" : `, ${String(files.length)} file(s) totalling ${describe(fileBytes)}`,
10871
10884
  ". The import is staged for review; nothing is applied yet."
10872
10885
  ].join(""), async () => {
10873
- return (await hostingWordpressImportStore({
10886
+ const body = {
10887
+ database: database === "" ? null : await partOf(database),
10888
+ archive: archive === "" ? null : await partOf(archive),
10889
+ directory: files.length === 0 ? null : await Promise.all(files.map(async (one) => await partOf(one.absolute))),
10890
+ directoryPaths: files.length === 0 ? null : JSON.stringify(files.map((one) => one.relative))
10891
+ };
10892
+ return await withRequestBudget(UPLOAD_REQUEST_BUDGET_MS, async () => (await hostingWordpressImportStore({
10874
10893
  path,
10875
- body: {
10876
- database: await partOf(database),
10877
- archive: archive === "" ? null : await partOf(archive),
10878
- directory: files.length === 0 ? null : await Promise.all(files.map(async (one) => await partOf(one.absolute))),
10879
- directoryPaths: files.length === 0 ? null : JSON.stringify(files.map((one) => one.relative))
10880
- }
10881
- })).data;
10894
+ body
10895
+ })).data);
10882
10896
  })
10883
10897
  };
10884
10898
  }
10885
10899
  /**
10900
+ * Whether a chosen archive is an Akeeba backup, which carries the site's database inside it.
10901
+ *
10902
+ * The API decides what a container is from its own bytes; this only decides whether a separate dump is
10903
+ * required before anything is sent, and the name is all the command line has to go on.
10904
+ */
10905
+ function isAkeebaArchive(archive) {
10906
+ const name = archive.toLowerCase();
10907
+ return name.endsWith(".jpa") || name.endsWith(".jps");
10908
+ }
10909
+ /**
10886
10910
  * One part, carrying its own filename.
10887
10911
  *
10888
10912
  * 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 +11043,13 @@ function applicationImportText(report) {
11019
11043
  if (!outcome.sent) return `Would: ${outcome.description}\nNothing was sent (--dry-run).`;
11020
11044
  const value = outcome.result;
11021
11045
  if (typeof value.message === "string") return `${outcome.description}\n${value.message}`;
11022
- return `${outcome.description}\n${recoveryLines(outcome.result)}`;
11046
+ return typeof value.inputLocation === "string" ? `${outcome.description}\n${importLines(outcome.result)}` : `${outcome.description}\n${recoveryLines(outcome.result)}`;
11023
11047
  }
11024
11048
  if (report.kind === "url-repair") return recoveryLines(report.recovery);
11025
- const { staged } = report;
11049
+ return importLines(report.staged);
11050
+ }
11051
+ /** One staged import as a few readable lines: what it would bring, and what it leaves out and why. */
11052
+ function importLines(staged) {
11026
11053
  return [
11027
11054
  ` import ${staged.uuid} ${String(staged.status)} from ${staged.inputLocation}`,
11028
11055
  ` ${String(staged.fileCount)} files, ${String(Math.round(staged.bundleBytes / 1024))} KiB bundle, ${String(Math.round(staged.databaseBytes / 1024))} KiB database`,
@@ -12080,6 +12107,31 @@ function optionalFlag(context, flag) {
12080
12107
  return value === "" ? null : value;
12081
12108
  }
12082
12109
  //#endregion
12110
+ //#region src/commands/arguments.ts
12111
+ /**
12112
+ * The one uuid a positional argument list must hold, or a usage refusal.
12113
+ *
12114
+ * Every command that takes a uuid has the same requirement — exactly one, present — so the rule and its wording
12115
+ * live here rather than in each command. `usage` is the caller's own syntax, appended so the refusal is
12116
+ * actionable rather than a bare "bad arguments".
12117
+ */
12118
+ function oneUuid$7(rest, usage) {
12119
+ const [uuid, ...extra] = rest;
12120
+ if (uuid === void 0 || uuid === "" || extra.length > 0) throw new UsageError(usage);
12121
+ return uuid;
12122
+ }
12123
+ /**
12124
+ * One flag's value, refused before any request rather than sent blank.
12125
+ *
12126
+ * A required flag that arrives empty would be refused by the API anyway, but refusing here names the flag and
12127
+ * the command's own syntax, so the operator fixes the invocation instead of reading a validation body.
12128
+ */
12129
+ function requiredFlag$2(context, flag, usage) {
12130
+ const value = context.flags.get(flag)?.trim() ?? "";
12131
+ if (value === "") throw new UsageError(`${flag} is required.\n\n${usage}`);
12132
+ return value;
12133
+ }
12134
+ //#endregion
12083
12135
  //#region src/commands/backup-destination-metadata.ts
12084
12136
  /**
12085
12137
  * `backup-destination` — the company's own backup bucket.
@@ -25704,6 +25756,18 @@ var emailExpectedDnsRecordDataSchema = object({
25704
25756
  values: array(string()),
25705
25757
  zoneHostname: string().nullable()
25706
25758
  });
25759
+ var emailRecipientRouteStateDataSchema = object({
25760
+ state: _enum([
25761
+ "configured",
25762
+ "adopted",
25763
+ "external",
25764
+ "local",
25765
+ "foreign",
25766
+ "unobserved"
25767
+ ]).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. |"),
25768
+ target: string().nullable(),
25769
+ observedAt: string()
25770
+ });
25707
25771
  var emailDomainSummaryDataSchema = object({
25708
25772
  uuid: string(),
25709
25773
  domainUuid: string(),
@@ -25714,7 +25778,8 @@ var emailDomainSummaryDataSchema = object({
25714
25778
  desiredGeneration: int(),
25715
25779
  releasedAt: string().nullable(),
25716
25780
  checks: array(emailDomainObservedCheckDataSchema),
25717
- expectedDnsRecords: array(emailExpectedDnsRecordDataSchema)
25781
+ expectedDnsRecords: array(emailExpectedDnsRecordDataSchema),
25782
+ recipientRoute: union([emailRecipientRouteStateDataSchema, _null()])
25718
25783
  });
25719
25784
  var emailEnrollmentAvailabilityDataSchema = object({
25720
25785
  available: boolean(),
@@ -29033,11 +29098,11 @@ var storeEmailSendingHoldRequestSchema = object({
29033
29098
  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.");
29034
29099
  object({ token: string() });
29035
29100
  var storeHostingApplicationImportRequestSchema = object({
29036
- database: _instanceof(File),
29101
+ database: _instanceof(File).nullish(),
29037
29102
  archive: _instanceof(File).nullish(),
29038
29103
  directory: array(_instanceof(File)).nullish(),
29039
29104
  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.")
29040
- }).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.");
29105
+ }).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.");
29041
29106
  var storeHostingBackupDestinationRequestSchema = object({
29042
29107
  endpoint: url().max(255),
29043
29108
  bucket: string().max(255).regex(/^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/),
@@ -31344,7 +31409,7 @@ union([
31344
31409
  messageDataSchema,
31345
31410
  messageDataSchema
31346
31411
  ]);
31347
- 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.");
31412
+ 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.");
31348
31413
  var hostingWordpressUrlRepairPreviewStatus200Schema = hostingApplicationRecoveryDataSchema;
31349
31414
  var hostingWordpressUrlRepairPreviewStatus201Schema = hostingApplicationRecoveryDataSchema;
31350
31415
  var hostingWordpressUrlRepairPreviewStatus401Schema = object({ message: string().describe("Error overview.") });
@@ -36956,7 +37021,7 @@ function writeUpdateState(state, env = process.env) {
36956
37021
  }
36957
37022
  //#endregion
36958
37023
  //#region src/version.ts
36959
- var VERSION = "1.0.384";
37024
+ var VERSION = "1.0.403";
36960
37025
  //#endregion
36961
37026
  //#region src/commands/update.ts
36962
37027
  /**
@@ -37031,7 +37096,7 @@ var update = {
37031
37096
  }, process.env);
37032
37097
  return {
37033
37098
  ...known,
37034
- current: after ?? "1.0.384",
37099
+ current: after ?? "1.0.403",
37035
37100
  latest: after ?? latest,
37036
37101
  upToDate: after !== null && (latest === null || !isNewerVersion(latest, after)),
37037
37102
  action: "run",
@@ -37306,7 +37371,7 @@ async function printUpdateNotice(options) {
37306
37371
  }, env, { waitMs: NOTICE_LOCK_WAIT_MS });
37307
37372
  } catch {}
37308
37373
  if (latest === null) return;
37309
- if (!isNewerVersion(latest, "1.0.384")) return;
37374
+ if (!isNewerVersion(latest, "1.0.403")) return;
37310
37375
  process.stderr.write(`A newer hostingctl is published: ${latest} (this copy is ${VERSION}). Run \`hostingctl update\` to update.\n`);
37311
37376
  }
37312
37377
  /** Whether an environment variable is set to something, which is how CI and the opt-out are read. */