@haakco/hostingctl 1.0.807 → 1.0.808

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
@@ -34378,6 +34378,22 @@ function hostingEnvironmentRetry(options) {
34378
34378
  }));
34379
34379
  }
34380
34380
  /**
34381
+ * {@link /c/:company/hosting/environments/:environmentUuid/budget}
34382
+ */
34383
+ function hostingEnvironmentsBudget(options) {
34384
+ const { client: request = client, ...config } = options;
34385
+ return withUnwrap(request({
34386
+ method: "GET",
34387
+ url: "/c/{company}/hosting/environments/{environmentUuid}/budget",
34388
+ security: [{
34389
+ type: "http",
34390
+ scheme: "bearer"
34391
+ }],
34392
+ ...config,
34393
+ throwOnError: config.throwOnError ?? true
34394
+ }));
34395
+ }
34396
+ /**
34381
34397
  * @summary 200 rather than 201: this records desired state on an environment that already exists, and the
34382
34398
  * reconciler — not this call — makes the cache serve. The body reports each application's outcome,
34383
34399
  * so "the switch is on" and "every application is caching" are never confused
@@ -43183,10 +43199,63 @@ function applicationBuildText(report) {
43183
43199
  if (report.kind === "build-wait") return buildWaitText(report);
43184
43200
  return report.kind === "build-write" ? writeText$6(report) : logText(report.log);
43185
43201
  }
43202
+ // src/commands/application-cache-rules.ts
43203
+ /** The `cache-set` flags that replace an application's ordered cache rules. */
43204
+ var CACHE_RULE_FLAGS = [{
43205
+ name: "--template",
43206
+ takesValue: true,
43207
+ description: "Replace the cache rules with a starter set: wordpress, static_build or application_headers."
43208
+ }, {
43209
+ name: "--rules-file",
43210
+ takesValue: true,
43211
+ description: "Replace the cache rules with the JSON array of rules this file holds."
43212
+ }];
43213
+ /**
43214
+ * Add the rule replacement `cache-set` was asked for: a starter template by name, or the ordered rules a
43215
+ * JSON file holds. The API validates both exactly as it does the panel's, so nothing here widens what may
43216
+ * be stored.
43217
+ */
43218
+ function addCacheRules(context, body, usage) {
43219
+ const template = context.flags.get("--template")?.trim() ?? "";
43220
+ const rulesFile = context.flags.get("--rules-file")?.trim() ?? "";
43221
+ if (template !== "" && rulesFile !== "") throw new UsageError(`cache-set takes --template or --rules-file, not both.\n\n${usage}`);
43222
+ if (template !== "") body.template = template;
43223
+ if (rulesFile !== "") body.rules = rulesFrom(rulesFile);
43224
+ }
43225
+ /** The ordered rules a `--rules-file` holds: a JSON array the API validates rule by rule. */
43226
+ function rulesFrom(file) {
43227
+ let parsed;
43228
+ try {
43229
+ parsed = JSON.parse(readFileSync(file, "utf8"));
43230
+ } catch (error) {
43231
+ throw new UsageError(`--rules-file ${file} is not readable JSON: ${error.message}`);
43232
+ }
43233
+ if (!Array.isArray(parsed)) throw new UsageError(`--rules-file ${file} must hold a JSON array of rules.`);
43234
+ return parsed;
43235
+ }
43236
+ /**
43237
+ * The named fields laid over the application's current settings.
43238
+ *
43239
+ * The API's update replaces the whole setting: an absent `enabled` is false and absent rules are none. So a
43240
+ * `cache-set` that named only `--fresh` used to switch the cache off and drop its rules (2026-11-13, on a
43241
+ * production WordPress site). Every unnamed field is now sent with the value it already has; a template or a
43242
+ * reset supplies its own rules, so the current ones are not sent beside it.
43243
+ */
43244
+ function overCurrent(current, named) {
43245
+ const replacesRules = "template" in named || "reset" in named;
43246
+ return {
43247
+ enabled: current.enabled,
43248
+ freshSeconds: current.freshSeconds,
43249
+ backgroundSeconds: current.backgroundSeconds,
43250
+ browserMaxAgeSeconds: current.browserMaxAgeSeconds,
43251
+ ...replacesRules ? {} : { rules: current.rules },
43252
+ ...named
43253
+ };
43254
+ }
43186
43255
  // src/commands/application-cache.ts
43187
43256
  var USAGE$50 = [
43188
43257
  "Usage: hostingctl application cache <environment-uuid> <application-uuid> --company <slug>",
43189
- " hostingctl application cache-set <environment-uuid> <application-uuid> --company <slug> [--enabled <on|off>] [--fresh <s>] [--background <s>] [--browser <s>] [--reset <on|off>]",
43258
+ " hostingctl application cache-set <environment-uuid> <application-uuid> --company <slug> [--enabled <on|off>] [--fresh <s>] [--background <s>] [--browser <s>] [--reset <on|off>] [--template <id> | --rules-file <rules.json>]",
43190
43259
  " hostingctl application cache-purge <environment-uuid> <application-uuid> --company <slug>",
43191
43260
  " hostingctl application routes <environment-uuid> --company <slug>",
43192
43261
  " hostingctl application route-add <environment-uuid> --company <slug> --source <uuid> --target <uuid> --path <path> [--domain <uuid>] [--canonical <on|off>]",
@@ -43194,7 +43263,9 @@ var USAGE$50 = [
43194
43263
  " hostingctl application route-remove <environment-uuid> <route-uuid> --company <slug>",
43195
43264
  "",
43196
43265
  " cache The application's HTTP cache settings as the platform applied them.",
43197
- " cache-set Change one or more of them. Only the fields named are sent.",
43266
+ " cache-set Change one or more of them. Only the fields named are sent. --template replaces the",
43267
+ " rules with a starter set (wordpress, static_build, application_headers); --rules-file",
43268
+ " replaces them with a JSON array of rules ({label, match, path, action, ...}), as the panel sends.",
43198
43269
  " cache-purge Clear the cache now.",
43199
43270
  " routes The environment's path routes between applications.",
43200
43271
  " route-add Route one path from an application to another.",
@@ -43215,10 +43286,13 @@ async function applicationCache(context, action, path, rest) {
43215
43286
  }));
43216
43287
  if (action === "cache-set") {
43217
43288
  const body = cacheBody(context);
43218
- return await written$6(confirmableWrite(context, `Change this application's cache: ${Object.keys(body).join(", ") || "nothing named"}.`, async () => (await hostingApplicationCacheUpdate({
43219
- path,
43220
- body
43221
- })).data));
43289
+ return await written$6(confirmableWrite(context, `Change this application's cache: ${Object.keys(body).join(", ") || "nothing named"}.`, async () => {
43290
+ const current = (await hostingApplicationCacheShow({ path })).data.settings;
43291
+ return (await hostingApplicationCacheUpdate({
43292
+ path,
43293
+ body: overCurrent(current, body)
43294
+ })).data;
43295
+ }));
43222
43296
  }
43223
43297
  if (action === "canonical") {
43224
43298
  const routeUuid = context.flags.get("--route") ?? "";
@@ -43304,6 +43378,7 @@ function cacheBody(context) {
43304
43378
  if (!Number.isInteger(value) || value < 0) throw new UsageError(`${flag} must be a whole number of seconds.\n\n${USAGE$50}`);
43305
43379
  body[field] = value;
43306
43380
  }
43381
+ addCacheRules(context, body, USAGE$50);
43307
43382
  if (Object.keys(body).length === 0) throw new UsageError(`cache-set needs at least one field.\n\n${USAGE$50}`);
43308
43383
  return body;
43309
43384
  }
@@ -44871,7 +44946,8 @@ var APPLICATION_METADATA = {
44871
44946
  description: "The version line `runtime-version` moves the application onto."
44872
44947
  },
44873
44948
  ...CREATE_FLAGS,
44874
- ...COMPONENT_SETTINGS_FLAGS
44949
+ ...COMPONENT_SETTINGS_FLAGS,
44950
+ ...CACHE_RULE_FLAGS
44875
44951
  ],
44876
44952
  subcommands: [
44877
44953
  "public-key",
@@ -52699,6 +52775,40 @@ function environmentAdminText(report) {
52699
52775
  if (report.kind === "database") return databaseText$1(report.database);
52700
52776
  return tuningText(report.tuning);
52701
52777
  }
52778
+ // src/commands/environment-budget.ts
52779
+ var BUDGET_USAGE = [
52780
+ "Usage: hostingctl environment budget <environment-uuid> --company <slug> [--json]",
52781
+ "",
52782
+ " budget What each reservation inside the purchase holds — the shared Pod, each application with Pods of",
52783
+ " its own, each database server — beside what it used over the last two weeks, and a suggested",
52784
+ " size read from two full weeks of measurements.",
52785
+ "",
52786
+ "A reservation without two full weeks of readings says so instead of suggesting anything. Nothing here",
52787
+ "changes a size, so no --confirm is needed."
52788
+ ].join("\n");
52789
+ /** `environment budget <uuid>`: the purchase split into its reservations, each beside its measured use. */
52790
+ async function environmentBudget(context, rest) {
52791
+ const [uuid, ...extra] = rest;
52792
+ if (uuid === void 0 || extra.length > 0) throw new UsageError(BUDGET_USAGE);
52793
+ return (await hostingEnvironmentsBudget({ path: {
52794
+ company: await requireCompany(context.flags),
52795
+ environmentUuid: uuid
52796
+ } })).data;
52797
+ }
52798
+ /** One block per reservation: what it reserves, what it used, and the suggestion in the API's own words. */
52799
+ function budgetText$1(view) {
52800
+ return [`Bought ${view.purchase.cpuRequestMillicores}m CPU and ${view.purchase.memoryRequestMib} MiB memory; use read over ${view.windowDays} days.`, ...view.members.map(memberText)].join("\n");
52801
+ }
52802
+ function memberText(member) {
52803
+ const pods = member.replicas > 1 ? ` (${member.replicas} Pods)` : "";
52804
+ const used = member.used === null ? "not measured" : `${member.used.cpuP95Millicores}m CPU at the 95th percentile, ${member.used.memoryMaxMib} MiB peak`;
52805
+ const sized = member.suggestion.cpuRequestMillicores === null || member.suggestion.memoryMib === null ? "" : ` -> ${member.suggestion.cpuRequestMillicores}m CPU, ${member.suggestion.memoryMib} MiB`;
52806
+ return [
52807
+ ` ${member.name} [${member.kind}]${pods}`,
52808
+ ` reserved ${member.reserved.cpuRequestMillicores}m CPU, ${member.reserved.memoryRequestMib} MiB; used ${used}`,
52809
+ ` ${member.suggestion.outcome}${sized}: ${member.suggestion.reason}`
52810
+ ].join("\n");
52811
+ }
52702
52812
  // src/commands/environment-cache.ts
52703
52813
  /** The starting patterns the API resolves into ordinary rules, as the panel names them. */
52704
52814
  var TEMPLATES = [
@@ -54150,6 +54260,7 @@ var ENVIRONMENT_SUBCOMMANDS = [
54150
54260
  "component-version",
54151
54261
  "references",
54152
54262
  "storage-usage",
54263
+ "budget",
54153
54264
  "storage-journal",
54154
54265
  "runtime-versions",
54155
54266
  "runtime-version-grants",
@@ -54217,6 +54328,7 @@ var ENVIRONMENT_USAGE = [
54217
54328
  " hostingctl environment component-version <uuid> <workload-uuid> <version> --company <slug>",
54218
54329
  " hostingctl environment references <uuid> --company <slug>",
54219
54330
  " hostingctl environment storage-usage <uuid> --company <slug>",
54331
+ " hostingctl environment budget <uuid> --company <slug>",
54220
54332
  " hostingctl environment storage-journal <uuid> --company <slug>",
54221
54333
  " hostingctl environment runtime-versions --company <slug>",
54222
54334
  " hostingctl environment site-insights[-verify|-audit|-fix] <uuid> --company <slug> [--site <site-uuid>]",
@@ -54258,6 +54370,8 @@ var ENVIRONMENT_USAGE = [
54258
54370
  " in `field`, and a credential field is marked rather than valued.",
54259
54371
  " storage-usage What each volume was allocated, what it has written and what room is left, from the",
54260
54372
  " platform's own reading; a volume it could not read says so instead of reporting zero.",
54373
+ " budget Each reservation inside the purchase beside what it used over two weeks, with a suggested",
54374
+ " size; a reservation without two full weeks of readings says so instead of suggesting one.",
54261
54375
  " storage-journal The disposal rows this environment recorded: which claim was captured, how far its",
54262
54376
  " reclaim got, and the reason a pass refused to continue. Recorded rows only, never a",
54263
54377
  " live reading, and nothing in it makes a volume disposable.",
@@ -56015,16 +56129,17 @@ function cacheEnablementText(enablement) {
56015
56129
  }
56016
56130
  // src/commands/environment-text.ts
56017
56131
  /**
56018
- * The two answers that describe what an environment may reference or hold.
56132
+ * The three readings of what an environment may reference, holds on disk, and uses of its purchase.
56019
56133
  *
56020
- * A user-defined guard keeps the parent renderer's branch count where it was — one decision rather than two — and
56134
+ * A user-defined guard keeps the parent renderer's branch count where it was — one decision rather than three — and
56021
56135
  * still narrows the union, so the default branch below keeps its own type.
56022
56136
  */
56023
- function isReferenceOrUsage(report) {
56024
- return "producers" in report || "rows" in report;
56137
+ function isReading(report) {
56138
+ return "producers" in report || "rows" in report || "windowDays" in report;
56025
56139
  }
56026
- /** Render whichever of the two projections this answer is. */
56027
- function referenceOrUsageText(report) {
56140
+ /** Render whichever of the three readings this answer is. */
56141
+ function readingText(report) {
56142
+ if ("windowDays" in report) return budgetText$1(report);
56028
56143
  return "producers" in report ? referenceDirectoryText(report) : storageUsageText(report);
56029
56144
  }
56030
56145
  /** The tagged answers. A cache change carries an outcome rather than a payload, so it renders as a write. */
@@ -56043,7 +56158,7 @@ function taggedReportText(report) {
56043
56158
  function environmentText(report) {
56044
56159
  if ("kind" in report) return taggedReportText(report);
56045
56160
  if ("sent" in report) return writeText$2(report);
56046
- if (isReferenceOrUsage(report)) return referenceOrUsageText(report);
56161
+ if (isReading(report)) return readingText(report);
56047
56162
  if ("configuration" in report) return configurationPreviewText(report);
56048
56163
  if ("canManage" in report && "revision" in report) return configurationPageText(report);
56049
56164
  if ("canManage" in report && "databases" in report) return databasePageText(report);
@@ -65528,6 +65643,11 @@ var hostingBudgetDataSchema = object({
65528
65643
  storageLimitMib: int(),
65529
65644
  toolsCpuLimitMillicores: int().nullable().describe("Deprecated compatibility field. The retired override always reports null.")
65530
65645
  });
65646
+ var hostingBudgetMemberKindEnumSchema = _enum([
65647
+ "shared-pod",
65648
+ "application",
65649
+ "database"
65650
+ ]).describe("What one row of an environment's budget view reserves for: the shared Pod, an application with Pods of its own, or a database server the purchase funds. Closed, because the view lists exactly these three kinds of reservation.\n");
65531
65651
  var hostingFailureCauseEnumSchema = _enum([
65532
65652
  "source-not-reachable",
65533
65653
  "commit-not-found",
@@ -66610,6 +66730,38 @@ object({
66610
66730
  checkedAt: string(),
66611
66731
  routingVerifiedAt: string().nullable()
66612
66732
  });
66733
+ var hostingMeasuredUseDataSchema = object({
66734
+ cpuP95Millicores: int(),
66735
+ cpuMaxMillicores: int(),
66736
+ memoryP95Mib: int(),
66737
+ memoryMaxMib: int(),
66738
+ measuredHours: int()
66739
+ });
66740
+ var hostingRightSizingSuggestionDataSchema = object({
66741
+ outcome: _enum([
66742
+ "smaller",
66743
+ "keep",
66744
+ "larger",
66745
+ "unmeasured"
66746
+ ]).describe("What two weeks of measured use suggest for one reservation. `unmeasured` is not a verdict: it says there were not two full weeks of measurements to suggest from, and the suggestion's reason says what was missing. It is never read as \"the size is right\".\n").describe("What two weeks of measured use suggest for one reservation. `unmeasured` is not a verdict: it says there were not two full weeks of measurements to suggest from, and the suggestion's reason says what was missing. It is never read as \"the size is right\".\n"),
66747
+ reason: string(),
66748
+ cpuRequestMillicores: int().nullable(),
66749
+ memoryMib: int().nullable()
66750
+ });
66751
+ var hostingEnvironmentBudgetMemberDataSchema = object({
66752
+ kind: hostingBudgetMemberKindEnumSchema.describe("What one row of an environment's budget view reserves for: the shared Pod, an application with Pods of its own, or a database server the purchase funds. Closed, because the view lists exactly these three kinds of reservation.\n"),
66753
+ name: string(),
66754
+ workloadUuid: string().nullable(),
66755
+ replicas: int(),
66756
+ reserved: hostingResourceDataSchema,
66757
+ used: union([hostingMeasuredUseDataSchema, _null()]),
66758
+ suggestion: hostingRightSizingSuggestionDataSchema
66759
+ });
66760
+ object({
66761
+ purchase: hostingResourceDataSchema,
66762
+ windowDays: int(),
66763
+ members: array(hostingEnvironmentBudgetMemberDataSchema)
66764
+ });
66613
66765
  var hostingWorkloadRuntimeSecretDataSchema = object({
66614
66766
  key: string(),
66615
66767
  required: boolean(),
@@ -72973,6 +73125,15 @@ object({
72973
73125
  company: string(),
72974
73126
  environmentUuid: string()
72975
73127
  });
73128
+ union([
73129
+ object({ message: string().describe("Error overview.") }),
73130
+ object({ message: string().describe("Error overview.") }),
73131
+ messageDataSchema
73132
+ ]);
73133
+ object({
73134
+ company: string(),
73135
+ environmentUuid: string()
73136
+ });
72976
73137
  union([
72977
73138
  object({ message: string().describe("Error overview.") }),
72978
73139
  object({ message: string().describe("Error overview.") }),
@@ -76474,7 +76635,8 @@ var SIMPLE_SUBCOMMANDS = {
76474
76635
  "runtime-versions": environmentRuntimeVersions,
76475
76636
  "runtime-version-grants": environmentRuntimeVersionGrants,
76476
76637
  storage: environmentStorage,
76477
- "storage-journal": environmentStorageJournal
76638
+ "storage-journal": environmentStorageJournal,
76639
+ budget: environmentBudget
76478
76640
  };
76479
76641
  /** Which feature group answers this subcommand and arguments, or null when the command itself does. */
76480
76642
  function dispatched(context, subcommand, rest) {
@@ -85245,7 +85407,7 @@ function writeUpdateState(state, env = process.env) {
85245
85407
  } catch {}
85246
85408
  }
85247
85409
  // src/version.ts
85248
- var VERSION = "1.0.807";
85410
+ var VERSION = "1.0.808";
85249
85411
  // src/commands/update.ts
85250
85412
  /**
85251
85413
  * `update` — bring this copy of the CLI up to the published version.
@@ -85319,7 +85481,7 @@ var update = {
85319
85481
  }, process.env);
85320
85482
  return {
85321
85483
  ...known,
85322
- current: after ?? "1.0.807",
85484
+ current: after ?? "1.0.808",
85323
85485
  latest: after ?? latest,
85324
85486
  upToDate: after !== null && (latest === null || !isNewerVersion(latest, after)),
85325
85487
  action: "run",
@@ -85600,7 +85762,7 @@ async function printUpdateNotice(options) {
85600
85762
  }, env, { waitMs: NOTICE_LOCK_WAIT_MS });
85601
85763
  } catch {}
85602
85764
  if (latest === null) return;
85603
- if (!isNewerVersion(latest, "1.0.807")) return;
85765
+ if (!isNewerVersion(latest, "1.0.808")) return;
85604
85766
  process.stderr.write(`A newer hostingctl is published: ${latest} (this copy is ${VERSION}). Run \`hostingctl update\` to update.\n`);
85605
85767
  }
85606
85768
  /** Whether an environment variable is set to something, which is how CI and the opt-out are read. */