@haakco/hostingctl 1.0.551 → 1.0.563

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
@@ -33946,6 +33946,22 @@ function hostingDeploymentDeploy(options) {
33946
33946
  }));
33947
33947
  }
33948
33948
  /**
33949
+ * {@link /c/:company/hosting/environments/:environmentUuid/applications/:workloadUuid/releases/:releaseUuid/redeploy}
33950
+ */
33951
+ function hostingDeploymentRedeploy(options) {
33952
+ const { client: request = client, ...config } = options;
33953
+ return withUnwrap(request({
33954
+ method: "POST",
33955
+ url: "/c/{company}/hosting/environments/{environmentUuid}/applications/{workloadUuid}/releases/{releaseUuid}/redeploy",
33956
+ security: [{
33957
+ type: "http",
33958
+ scheme: "bearer"
33959
+ }],
33960
+ ...config,
33961
+ throwOnError: config.throwOnError ?? true
33962
+ }));
33963
+ }
33964
+ /**
33949
33965
  * {@link /hosting/releases/:releaseUuid/bundle}
33950
33966
  */
33951
33967
  function hostingReleasesBundle(options) {
@@ -35042,6 +35058,70 @@ function hostingStorageDestroy(options) {
35042
35058
  }));
35043
35059
  }
35044
35060
  /**
35061
+ * {@link /c/:company/hosting/storage/native}
35062
+ */
35063
+ function hostingStorageStoreNative(options) {
35064
+ const { client: request = client, ...config } = options;
35065
+ return withUnwrap(request({
35066
+ method: "POST",
35067
+ url: "/c/{company}/hosting/storage/native",
35068
+ security: [{
35069
+ type: "http",
35070
+ scheme: "bearer"
35071
+ }],
35072
+ ...config,
35073
+ throwOnError: config.throwOnError ?? true
35074
+ }));
35075
+ }
35076
+ /**
35077
+ * {@link /c/:company/hosting/storage/:bucketUuid/allocation/reduce}
35078
+ */
35079
+ function hostingStorageAllocationReduce(options) {
35080
+ const { client: request = client, ...config } = options;
35081
+ return withUnwrap(request({
35082
+ method: "POST",
35083
+ url: "/c/{company}/hosting/storage/{bucketUuid}/allocation/reduce",
35084
+ security: [{
35085
+ type: "http",
35086
+ scheme: "bearer"
35087
+ }],
35088
+ ...config,
35089
+ throwOnError: config.throwOnError ?? true
35090
+ }));
35091
+ }
35092
+ /**
35093
+ * {@link /c/:company/hosting/storage/:bucketUuid/billing-mode/native}
35094
+ */
35095
+ function hostingStorageBillingModeNative(options) {
35096
+ const { client: request = client, ...config } = options;
35097
+ return withUnwrap(request({
35098
+ method: "POST",
35099
+ url: "/c/{company}/hosting/storage/{bucketUuid}/billing-mode/native",
35100
+ security: [{
35101
+ type: "http",
35102
+ scheme: "bearer"
35103
+ }],
35104
+ ...config,
35105
+ throwOnError: config.throwOnError ?? true
35106
+ }));
35107
+ }
35108
+ /**
35109
+ * {@link /c/:company/hosting/storage/:bucketUuid/billing-mode/allocated}
35110
+ */
35111
+ function hostingStorageBillingModeAllocated(options) {
35112
+ const { client: request = client, ...config } = options;
35113
+ return withUnwrap(request({
35114
+ method: "POST",
35115
+ url: "/c/{company}/hosting/storage/{bucketUuid}/billing-mode/allocated",
35116
+ security: [{
35117
+ type: "http",
35118
+ scheme: "bearer"
35119
+ }],
35120
+ ...config,
35121
+ throwOnError: config.throwOnError ?? true
35122
+ }));
35123
+ }
35124
+ /**
35045
35125
  * {@link /c/:company/hosting/storage/:bucketUuid/bindings/:environmentUuid}
35046
35126
  */
35047
35127
  function hostingStorageBindingsStore(options) {
@@ -36390,7 +36470,7 @@ function platformHostingRealmStore(options) {
36390
36470
  /**
36391
36471
  * {@link /platform/diagnostics}
36392
36472
  */
36393
- function platformPlatformDiagnostics(options = {}) {
36473
+ function platformDiagnostics(options = {}) {
36394
36474
  const { client: request = client, ...config } = options;
36395
36475
  return withUnwrap(request({
36396
36476
  method: "GET",
@@ -39083,6 +39163,7 @@ var APPLICATION_USAGE = [
39083
39163
  " hostingctl application source-ssh-rotate-key <connection-uuid> --company <slug>",
39084
39164
  " hostingctl application source-ssh-revoke <connection-uuid> --company <slug>",
39085
39165
  " hostingctl application deploy <environment-uuid> <workload-uuid> <release-uuid> --company <slug>",
39166
+ " hostingctl application redeploy <environment-uuid> <workload-uuid> <release-uuid> --company <slug>",
39086
39167
  " hostingctl application runs <environment-uuid> <workload-uuid> --company <slug>",
39087
39168
  " hostingctl application run-log <environment-uuid> <workload-uuid> <run-name> --company <slug>",
39088
39169
  " hostingctl application schedule-run <environment-uuid> <workload-uuid> <schedule-key> --company <slug>",
@@ -39101,6 +39182,7 @@ var APPLICATION_USAGE = [
39101
39182
  " source-upload Stage a ZIP of the project, review what it measured, then build from it.",
39102
39183
  " source-ssh-* Add, inspect, confirm, verify, rotate and retire a Git-over-SSH source.",
39103
39184
  " deploy Make an existing release the one the application runs.",
39185
+ " redeploy Rebuild an earlier release forward from the exact source it recorded; the attempt becomes a candidate.",
39104
39186
  " runs|run-log The process run history, and one run's own output.",
39105
39187
  " schedule-run Run a declared schedule now, beside the schedule's own runs.",
39106
39188
  " runtime Stop, start or restart the application's desired runtime.",
@@ -41401,6 +41483,7 @@ async function journey(context) {
41401
41483
  async function dispatched$2(context, action, path, extra) {
41402
41484
  if (action === "build") return await build(context, path, extra);
41403
41485
  if (action === "deploy") return await deploy(context, path, extra);
41486
+ if (action === "redeploy") return await redeploy(context, path, extra);
41404
41487
  if (action !== void 0 && SOURCE_UPLOAD_ACTIONS.has(action)) return await applicationSourceUploads(context, action, path, extra);
41405
41488
  if (action === "run-log") return await runLog(path, extra);
41406
41489
  if (action === "schedule-run" || action === "schedule-suspend" || action === "schedule-resume") return await scheduleAction(context, action, path, extra);
@@ -41457,6 +41540,15 @@ async function deploy(context, path, extra) {
41457
41540
  releaseUuid
41458
41541
  } })).data);
41459
41542
  }
41543
+ /** `redeploy <env> <workload> <release>`: rebuild an earlier release forward and leave it as a candidate. */
41544
+ async function redeploy(context, path, extra) {
41545
+ const [releaseUuid, ...rest] = extra;
41546
+ if (releaseUuid === void 0 || rest.length > 0) throw new UsageError(APPLICATION_USAGE);
41547
+ return await confirmableWrite(context, `Rebuild release ${releaseUuid} of application ${path.workloadUuid} forward from the source it recorded. The attempt becomes a candidate; it does not deploy itself.`, async () => (await hostingDeploymentRedeploy({ path: {
41548
+ ...path,
41549
+ releaseUuid
41550
+ } })).data);
41551
+ }
41460
41552
  /** `run-log <env> <workload> <run-name>`: one process run's captured output, or its unavailability. */
41461
41553
  async function runLog(path, extra) {
41462
41554
  const [runName, ...rest] = extra;
@@ -44875,7 +44967,7 @@ var diagnostics = {
44875
44967
  flags: [],
44876
44968
  subcommands: [],
44877
44969
  async run() {
44878
- return (await platformPlatformDiagnostics({})).data;
44970
+ return (await platformDiagnostics({})).data;
44879
44971
  },
44880
44972
  human(report) {
44881
44973
  const doctor = report.doctor;
@@ -56498,7 +56590,11 @@ var billingRunLineDataSchema = object({
56498
56590
  taxPointOn: string()
56499
56591
  });
56500
56592
  var billingRunDifferenceDataSchema = object({
56501
- reason: _enum(["unresolved_package", "missing_rate"]).describe("Why a rated line could not be priced. A difference is a refusal, not a zero. The vocabulary is closed because each case is a distinct thing an operator has to fix: a package the record cannot name, a package with no price, and a price that moved after the run captured its inputs. Anything else is a new case with a new decision behind it.\n| |\n|---|\n| `unresolved_package` <br/> A paid period whose package is `null` (bespoke) or `unknown` (reconstructed before the ledger recorded packages). |\n| `missing_rate` <br/> A paid period whose package has no price window covering the service time. |").describe("Why a rated line could not be priced. A difference is a refusal, not a zero. The vocabulary is closed because each case is a distinct thing an operator has to fix: a package the record cannot name, a package with no price, and a price that moved after the run captured its inputs. Anything else is a new case with a new decision behind it.\n| |\n|---|\n| `unresolved_package` <br/> A paid period whose package is `null` (bespoke) or `unknown` (reconstructed before the ledger recorded packages). |\n| `missing_rate` <br/> A paid period whose package has no price window covering the service time. |"),
56593
+ reason: _enum([
56594
+ "unresolved_package",
56595
+ "missing_rate",
56596
+ "missing_measurement"
56597
+ ]).describe("Why a rated line could not be priced. A difference is a refusal, not a zero. The vocabulary is closed because each case is a distinct thing an operator has to fix: a package the record cannot name, a package with no price, a price that moved after the run captured its inputs, and measured usage nobody proved. Anything else is a new case with a new decision behind it.\n| |\n|---|\n| `unresolved_package` <br/> A paid period whose package is `null` (bespoke) or `unknown` (reconstructed before the ledger recorded packages). |\n| `missing_rate` <br/> A paid period whose package has no price window covering the service time. |\n| `missing_measurement` <br/> Measured usage with no proved measurement for part of the service time, so what it held is unknown. |").describe("Why a rated line could not be priced. A difference is a refusal, not a zero. The vocabulary is closed because each case is a distinct thing an operator has to fix: a package the record cannot name, a package with no price, a price that moved after the run captured its inputs, and measured usage nobody proved. Anything else is a new case with a new decision behind it.\n| |\n|---|\n| `unresolved_package` <br/> A paid period whose package is `null` (bespoke) or `unknown` (reconstructed before the ledger recorded packages). |\n| `missing_rate` <br/> A paid period whose package has no price window covering the service time. |\n| `missing_measurement` <br/> Measured usage with no proved measurement for part of the service time, so what it held is unknown. |"),
56502
56598
  purchasePeriodUuid: string(),
56503
56599
  environmentUuid: string(),
56504
56600
  packageKey: string().nullable(),
@@ -59741,6 +59837,114 @@ object({
59741
59837
  capability: hostingObjectCacheCapabilityDataSchema,
59742
59838
  status: hostingEnvironmentStatusDataSchema
59743
59839
  });
59840
+ var hostingOperationCalibrationDataSchema = object({
59841
+ status: string().describe("ready, no_evidence or unavailable."),
59842
+ workflowKey: string().describe("The workflow key this calibration belongs to; one per operation kind."),
59843
+ evaluatedRuns: int().describe("Completed runs the evaluation counted, or 0 when there is no evaluation."),
59844
+ baselineSeconds: int().nullable().describe("The evaluation's own baseline duration in seconds, or null when it reported none."),
59845
+ meanAbsoluteErrorSeconds: int().nullable().describe("Mean absolute prediction error in seconds, from the evaluation's primary metric. \"How far off was the forecast, on average\" — an absolute number so a reader can weigh it\nagainst the duration it is about. `null` when the evaluation reported no metric."),
59846
+ intervalCoveragePercent: int().nullable().describe("Share of held-out runs whose forecast interval contained the observed duration, when the\nevaluation published an interval. `null` when it published none, which is different from 0%."),
59847
+ evaluatedFolds: int().describe("Held-out runs the evaluation folded over, or 0 when it reported none."),
59848
+ provenance: string(),
59849
+ observedAt: string(),
59850
+ note: string().describe("Plain-language reason and, for unavailable, the smallest next action.")
59851
+ });
59852
+ var hostingOperationComparisonDataSchema = object({
59853
+ dimension: string().describe("`cluster`, `workload_mix` or `application_revision`."),
59854
+ value: string().describe("The snapshot value, or '' when the runs in this cohort recorded none."),
59855
+ samples: int(),
59856
+ medianSeconds: int(),
59857
+ p90Seconds: int()
59858
+ });
59859
+ var hostingOperationForecastDataSchema = object({
59860
+ status: string(),
59861
+ evidenceCount: int().describe("Completed operations the range was computed from."),
59862
+ provenance: string().describe("Where the evidence came from, e.g. \"hosting operation projection\"."),
59863
+ observedAt: string(),
59864
+ likelyMinSeconds: int().nullable().describe("Seconds from now to the likely completion, or null when there is no supported range."),
59865
+ likelyMaxSeconds: int().nullable(),
59866
+ typicalTotalSeconds: int().nullable().describe("The median total duration of the evidence, in seconds, or null when there is none."),
59867
+ note: string().describe("Plain-language reason, never a promise.")
59868
+ });
59869
+ var hostingOperationKindEnumSchema = _enum([
59870
+ "reconcile",
59871
+ "build",
59872
+ "update",
59873
+ "restore",
59874
+ "backup"
59875
+ ]).describe("The lifecycle operations whose timing Hosting records. Each case is a family whose own owner already records when it started, what it was in and how it ended; `HostingOperationSourceImport` only projects those recorded instants into the shared timing tables. No case exists for a family without stage evidence of its own, and nothing here is a workflow engine: a case names work another owner already performed. - `reconcile` — the reconcile journal's named stages (`HostingDiagnosticsJournal`), which is what provisioning, updates and rollouts all converge through. - `build` — one `HostingBuild` attempt: queued, then run to an artifact. - `update` — one `HostingRelease` activation: prepared, then applied and made active. - `restore` — one `HostingApplicationRecovery` review/reset/restore, with its recorded phases. - `backup` — one observed backup run per track, as the existing backup readers saw it. The readers are cluster reads, so the projection is written where the platform already observes out of band; the operator's read never calls the cluster.\n");
59876
+ var hostingOperationPhaseStatisticDataSchema = object({
59877
+ stepKey: string(),
59878
+ samples: int(),
59879
+ medianSeconds: int(),
59880
+ p90Seconds: int(),
59881
+ contributionPercent: int().describe("Share of the median total, 0-100."),
59882
+ failures: int().describe("Stage runs that ended failed, over the same window."),
59883
+ waits: int().describe("Stage runs that ended as a readiness wait rather than a failure.")
59884
+ });
59885
+ object({
59886
+ kind: string(),
59887
+ status: string().describe("ready, cold_start, sparse, stale, partial, unavailable or error."),
59888
+ samples: int(),
59889
+ minimumSamples: int(),
59890
+ generatedAt: string(),
59891
+ window: int().describe("Finished runs the window covers, whatever they ended as."),
59892
+ medianTotalSeconds: int(),
59893
+ p90TotalSeconds: int(),
59894
+ medianQueueSeconds: int().describe("Median wait between the desired-state change and the run's own start, over the same window. A separate interval, not a component of `medianTotalSeconds`: the wait precedes the run, so\nsubtracting it from a total that begins at the run's start would report a run that waited\nlonger than it ran as having done no work."),
59895
+ failures: int().describe("Runs in the window that ended failed."),
59896
+ cancellations: int().describe("Runs in the window that ended cancelled."),
59897
+ successRatePercent: int().describe("The share of finished runs that ended each way, in whole percent, over the window above. Rates rather than raw counts, because \"two failures\" means nothing without the population\nit came from. The denominator is `window` — every run that reached an end — so the three\noutcome rates sum to 100 (rounding aside)."),
59898
+ failureRatePercent: int(),
59899
+ cancellationRatePercent: int(),
59900
+ retryRatePercent: int().describe("Retried runs as a share of the window, in whole percent. A run that needed a second attempt is work the platform had to do twice; the share says how\noften that happens without inflating the duration evidence."),
59901
+ retries: int().describe("Retries beyond each run's first attempt, summed over the window."),
59902
+ dominantPhase: string().describe("The stage with the largest share of the median total, or '' when there is none."),
59903
+ phases: array(hostingOperationPhaseStatisticDataSchema),
59904
+ comparisons: array(hostingOperationComparisonDataSchema).describe("Completed runs of this kind grouped by the bounded snapshot each one recorded, above the sample minimum. The \"did that release, recipe or cluster change make the path slower\" answer, published only for cohorts\nwith enough evidence to compare. A cohort below the minimum is withheld and counted in\n`withheldCohorts` rather than shown with a median nobody should act on."),
59905
+ withheldCohorts: int(),
59906
+ calibration: hostingOperationCalibrationDataSchema,
59907
+ forecast: hostingOperationForecastDataSchema
59908
+ });
59909
+ var hostingOperationSummaryDataSchema = object({
59910
+ sourceRef: string().describe("The operation's own identity: the delivery's correlation identifier, which is a ULID on\nthis platform. A string, not a uuid, because that is what the platform's identifiers are."),
59911
+ kind: string(),
59912
+ status: string(),
59913
+ environment: string(),
59914
+ environmentName: string(),
59915
+ companyName: string().describe("Resolved from Hosting data after authorization; never copied to an external service."),
59916
+ cluster: string(),
59917
+ generation: int(),
59918
+ attempt: int(),
59919
+ startedAt: string(),
59920
+ elapsedSeconds: int().describe("Seconds the operation has been running, or how long it took if it has finished."),
59921
+ currentStep: string(),
59922
+ currentStepStartedAt: string(),
59923
+ currentStepElapsedSeconds: int().describe("Seconds the current stage has been running, or 0 when the operation is not in one."),
59924
+ failedStep: string().describe("The stage that failed, or '' when none did."),
59925
+ errorClass: string().describe("A bounded exception class, never a message, a path or a provider body."),
59926
+ finishedAt: string()
59927
+ });
59928
+ object({
59929
+ operation: hostingOperationSummaryDataSchema,
59930
+ steps: array(object({
59931
+ stepKey: string(),
59932
+ attempt: int(),
59933
+ status: string(),
59934
+ dependency: string(),
59935
+ startedAt: string(),
59936
+ finishedAt: string(),
59937
+ durationMs: int().nullable(),
59938
+ errorClass: string()
59939
+ })),
59940
+ forecast: hostingOperationForecastDataSchema
59941
+ });
59942
+ var hostingOperationsDataSchema = object({
59943
+ current: array(hostingOperationSummaryDataSchema),
59944
+ late: array(hostingOperationSummaryDataSchema),
59945
+ recent: array(hostingOperationSummaryDataSchema),
59946
+ lateAfterSeconds: int().describe("The stage duration that counts as late, so the screen and the query cannot disagree.")
59947
+ });
59744
59948
  var hostingPackageDataSchema = object({
59745
59949
  slug: string(),
59746
59950
  name: string(),
@@ -60267,6 +60471,8 @@ var hostingStorageBucketDataSchema = object({
60267
60471
  uuid: string(),
60268
60472
  name: string(),
60269
60473
  bucket: string(),
60474
+ billingMode: string().describe("`native` bills measured usage; `allocated` bills the whole purchased allocation."),
60475
+ billingModeLabel: string().describe("The client-facing name of that basis, so no surface has to invent its own wording."),
60270
60476
  capacityBytes: int(),
60271
60477
  includedDownloadBytes: int(),
60272
60478
  status: string(),
@@ -60357,6 +60563,7 @@ var hostingStorageQuoteDataSchema = object({
60357
60563
  blockBytes: int().describe("Decimal bytes in one sold block: 10,000,000,000."),
60358
60564
  currentBlocks: int(),
60359
60565
  targetBlocks: int(),
60566
+ commercialGeneration: int().describe("How many commercial changes the bucket had been through when this was priced. A confirmation carrying an older\ngeneration is refused, so a quote cannot be replayed after an intervening change has returned the bucket to\nthe same block count."),
60360
60567
  addedBlocks: int(),
60361
60568
  storageUnit: billingAmountsDataSchema.describe("One block, for one month, at the current month's tax point."),
60362
60569
  addedMonthly: billingAmountsDataSchema.describe("The increase, for the next full billing month."),
@@ -60600,6 +60807,7 @@ object({
60600
60807
  unready: diagnosticsUnreadyEnvironmentsDataSchema,
60601
60808
  incompleteProfiles: diagnosticsIncompleteProfilesDataSchema,
60602
60809
  failingBackups: diagnosticsFailingBackupsDataSchema.describe("The backup tracks that are not succeeding, and the environments this installation could not read. Beside readiness for the same reason `incompleteProfiles` is: a broken backup leaves its environment\nfully ready, so nothing in `unready` can see it — measured 2026-10-20, when every file backup on Home\nstaging failed for fifteen hours and the only surface that showed it was a panel nobody opened, and\n2026-10-29, when a database dump that stopped succeeding had no platform-level surface at all. Each row\nnames the track it is about and carries the failure's class, never its message, so an access problem is\ndistinguishable from a refused read without carrying a host, a path or a body."),
60810
+ operations: hostingOperationsDataSchema.describe("What is running, what is late and what recently finished, read from Hosting's own timing\nprojection. Beside readiness because the two answer different questions: readiness says whether an\nenvironment converged, and this says what the reconcile that was supposed to converge it is\ndoing right now, in which stage, and for how long. It is deliberately the last answer to lose\nits dependencies — it reads nothing outside this application — so a surface an operator opens\nduring an outage still answers."),
60603
60811
  failedStages: array(string()),
60604
60812
  failedStagesSource: string().describe("Where those lines came from, or why this installation has none to give.")
60605
60813
  });
@@ -60809,6 +61017,7 @@ var redeemMailboxRecoveryRequestSchema = object({
60809
61017
  password: string(),
60810
61018
  password_confirmation: string()
60811
61019
  }).describe("Completing one mailbox password reset with the capability token from the link.\n\nThe token is taken in the POST body, never in a URL a scanner could follow, and it authorizes only\nthis one mailbox password change. The new password uses the same policy owner as every other\npassword (`Password::defaults()`) and must be confirmed.");
61020
+ var reduceHostingStorageAllocationRequestSchema = object({ capacityGb: int().min(10).max(1e5) }).describe("A request to hold a smaller allocation for one bucket.\n\nCapacity is asked for in the unit a client reads — decimal gigabytes in whole 10 GB blocks — and is checked by the\nallocation owner against the bucket's own recorded usage. This is deliberately not the purchase route: reducing is\nnot a negative purchase, it is a resize that must fit what is already stored.");
60812
61021
  var refundBillingCollectionReceiptRequestSchema = object({
60813
61022
  reason: string().max(250),
60814
61023
  reversedAt: datetime()
@@ -61366,6 +61575,7 @@ var storeHostingStorageBindingRequestSchema = object({
61366
61575
  }).describe("Binding a purchased bucket to one environment, natively or as a managed directory.\n\nThe path is the dangerous part, so its rule is owned by `StorageMountPath` rather than written as\nbranching inside this declaration; a path that is not absolute, contains a traversal segment, is the\nfilesystem root or lands on a reserved system/managed location is refused before any write. Only the\nmount path is a directory inside the application tree, so it is validated here rather than by a\nbranching rule inside the controller.");
61367
61576
  var storeHostingStorageBucketRequestSchema = object({
61368
61577
  name: string().min(1).max(64).regex(/^[\pL\pN][\pL\pN ._-]*$/),
61578
+ mode: _enum(["native", "allocated"]).optional(),
61369
61579
  quote: object({
61370
61580
  bucketUuid: string().nullish(),
61371
61581
  bucketName: string().nullish(),
@@ -61374,6 +61584,7 @@ var storeHostingStorageBucketRequestSchema = object({
61374
61584
  blockBytes: number(),
61375
61585
  currentBlocks: number(),
61376
61586
  targetBlocks: number(),
61587
+ commercialGeneration: number(),
61377
61588
  addedBlocks: number(),
61378
61589
  storageUnit: object({
61379
61590
  netCents: number(),
@@ -61409,11 +61620,15 @@ var storeHostingStorageBucketRequestSchema = object({
61409
61620
  generatedAt: string(),
61410
61621
  reviewToken: string()
61411
61622
  })
61412
- }).describe("One storage purchase.\n\nThe capacity is not a field of its own: it is the quote's own target, and the quote is what the client confirms. The\nname is the client's label for the bucket they are buying, so it is asked for at the confirmation rather than bound\ninto the quote.");
61623
+ }).describe("One storage purchase.\n\nTwo products share this endpoint because they are the same purchase with different prices. An **allocated** bucket\nbuys blocks, so the capacity is not a field of its own: it is the quote's own target, and the quote is what the\nclient confirms. A **native** bucket buys nothing up front — it pays for what it stores — so there is no quote to\nconfirm and instead the caller may supply its own idempotency key.\n\nThe name is the client's label for the bucket they are buying, so it is asked for at the confirmation rather than\nbound into the quote.");
61413
61624
  var storeHostingStorageObjectGrantRequestSchema = object({
61414
61625
  key: string().max(1024).regex(/^[^\x00-\x1F\x7F]+$/),
61415
61626
  direction: _enum(["download", "upload"])
61416
61627
  }).describe("Asking for one short-lived signed URL for one object.\n\nThe direction decides the verb: a download signs a GET and an upload signs a PUT, so a browser or the CLI\ncan move the bytes itself. The key is the client's own path inside their bucket and is validated as a key,\nnot as a filesystem path — control characters are refused because they would break signing and logging.");
61628
+ var storeNativeHostingStorageBucketRequestSchema = object({
61629
+ name: string().min(1).max(64).regex(/^[\pL\pN][\pL\pN ._-]*$/).describe("The client's own label, so they can tell two purchases apart."),
61630
+ purchaseKey: uuid().nullish().describe("There is no token to replay, so the caller's own key is what makes a retry return the bucket it already\ncreated instead of buying a second one.")
61631
+ }).describe("One purchase of storage that pays for what it stores.\n\nIts own request rather than a mode flag on the allocation purchase, because the two answers have different shapes: an\nallocation purchase confirms a priced quote, and this one carries no quote at all. Keeping them apart means a\ngenerated client can tell which body an endpoint takes instead of being handed an object whose required fields\ndepend on another field.");
61417
61632
  var storePlatformAlertRecipientRequestSchema = object({ email: email().max(254) }).describe("Add one system-admin address to the platform alert recipient list.\n\nSyntax is the request's (`email:rfc|max:254`); normalization to the canonical value is the\nexisting `emails` owner's, never a second normalizer here. The route's `can:` middleware owns the\npermission check, so authorization is not repeated.");
61418
61633
  var storePlatformCompanyRequestSchema = object({
61419
61634
  name: string().max(255),
@@ -61665,6 +61880,7 @@ var updateHostingStorageCapacityRequestSchema = object({ quote: object({
61665
61880
  blockBytes: number(),
61666
61881
  currentBlocks: number(),
61667
61882
  targetBlocks: number(),
61883
+ commercialGeneration: number(),
61668
61884
  addedBlocks: number(),
61669
61885
  storageUnit: object({
61670
61886
  netCents: number(),
@@ -61771,11 +61987,10 @@ var authSendVerificationNotificationStatus200Schema = messageDataSchema;
61771
61987
  var authSendVerificationNotificationStatus202Schema = messageDataSchema;
61772
61988
  object({ message: string().describe("Error overview.") });
61773
61989
  union([authSendVerificationNotificationStatus200Schema, authSendVerificationNotificationStatus202Schema]);
61774
- _enum(["OK"]);
61775
61990
  union([
61776
- _enum(["Malformed notification."]),
61777
- _enum(["Notification was not accepted."]),
61778
- _enum(["Notification could not be recorded."])
61991
+ messageDataSchema,
61992
+ messageDataSchema,
61993
+ messageDataSchema
61779
61994
  ]);
61780
61995
  string().describe("The document kind: invoice or credit_note.");
61781
61996
  string().describe("The document UUID the render grant names.");
@@ -61895,7 +62110,7 @@ storeBillingPaymentMethodRequestSchema.optional().describe("Start authorizing a
61895
62110
  union([
61896
62111
  object({ message: string().describe("Error overview.") }),
61897
62112
  object({ message: string().describe("Error overview.") }),
61898
- string()
62113
+ messageDataSchema
61899
62114
  ]);
61900
62115
  union([
61901
62116
  object({ message: string().describe("Error overview.") }),
@@ -63507,6 +63722,12 @@ union([
63507
63722
  messageDataSchema,
63508
63723
  hostingRefusalDataSchema
63509
63724
  ]);
63725
+ union([
63726
+ object({ message: string().describe("Error overview.") }),
63727
+ object({ message: string().describe("Error overview.") }),
63728
+ messageDataSchema,
63729
+ hostingRefusalDataSchema
63730
+ ]);
63510
63731
  union([
63511
63732
  unknown(),
63512
63733
  object({ message: string().describe("Error overview.").meta({ examples: ["This bundle URL is not valid."] }) }),
@@ -63926,7 +64147,7 @@ union([
63926
64147
  hostingStorageStoreStatus403Schema,
63927
64148
  hostingStorageStoreStatus422Schema
63928
64149
  ]);
63929
- storeHostingStorageBucketRequestSchema.describe("One storage purchase.\n\nThe capacity is not a field of its own: it is the quote's own target, and the quote is what the client confirms. The\nname is the client's label for the bucket they are buying, so it is asked for at the confirmation rather than bound\ninto the quote.");
64150
+ storeHostingStorageBucketRequestSchema.describe("One storage purchase.\n\nTwo products share this endpoint because they are the same purchase with different prices. An **allocated** bucket\nbuys blocks, so the capacity is not a field of its own: it is the quote's own target, and the quote is what the\nclient confirms. A **native** bucket buys nothing up front — it pays for what it stores — so there is no quote to\nconfirm and instead the caller may supply its own idempotency key.\n\nThe name is the client's label for the bucket they are buying, so it is asked for at the confirmation rather than\nbound into the quote.");
63930
64151
  union([object({ message: string().describe("Error overview.") }), object({ message: string().describe("Error overview.") })]);
63931
64152
  union([
63932
64153
  object({ message: string().describe("Error overview.") }),
@@ -63935,6 +64156,47 @@ union([
63935
64156
  ]);
63936
64157
  updateHostingStorageCapacityRequestSchema.describe("Adding capacity to an existing purchase.\n\nOnly an increase is accepted: a client buys more space, and a decrease would have to remove objects or invent a\npartial refund, neither of which this product offers. The target capacity is the quote's own, and a quote for less\nthan the bucket holds is refused by the purchase service rather than silently accepting it.");
63937
64158
  union([object({ message: string().describe("Error overview.") }), object({ message: string().describe("Error overview.") })]);
64159
+ var hostingStorageStoreNativeStatus200Schema = hostingStorageBucketDataSchema;
64160
+ var hostingStorageStoreNativeStatus201Schema = hostingStorageBucketDataSchema;
64161
+ var hostingStorageStoreNativeStatus401Schema = object({ message: string().describe("Error overview.") });
64162
+ var hostingStorageStoreNativeStatus403Schema = object({ message: string().describe("Error overview.") });
64163
+ var hostingStorageStoreNativeStatus422Schema = messageDataSchema;
64164
+ union([hostingStorageStoreNativeStatus200Schema, hostingStorageStoreNativeStatus201Schema]);
64165
+ union([
64166
+ hostingStorageStoreNativeStatus401Schema,
64167
+ hostingStorageStoreNativeStatus403Schema,
64168
+ hostingStorageStoreNativeStatus422Schema
64169
+ ]);
64170
+ storeNativeHostingStorageBucketRequestSchema.describe("One purchase of storage that pays for what it stores.\n\nIts own request rather than a mode flag on the allocation purchase, because the two answers have different shapes: an\nallocation purchase confirms a priced quote, and this one carries no quote at all. Keeping them apart means a\ngenerated client can tell which body an endpoint takes instead of being handed an object whose required fields\ndepend on another field.");
64171
+ union([
64172
+ object({ message: string().describe("Error overview.") }),
64173
+ object({ message: string().describe("Error overview.") }),
64174
+ messageDataSchema
64175
+ ]);
64176
+ reduceHostingStorageAllocationRequestSchema.describe("A request to hold a smaller allocation for one bucket.\n\nCapacity is asked for in the unit a client reads — decimal gigabytes in whole 10 GB blocks — and is checked by the\nallocation owner against the bucket's own recorded usage. This is deliberately not the purchase route: reducing is\nnot a negative purchase, it is a resize that must fit what is already stored.");
64177
+ var hostingStorageBillingModeNativeStatus200Schema = hostingStorageBucketDataSchema;
64178
+ var hostingStorageBillingModeNativeStatus201Schema = hostingStorageBucketDataSchema;
64179
+ var hostingStorageBillingModeNativeStatus401Schema = object({ message: string().describe("Error overview.") });
64180
+ var hostingStorageBillingModeNativeStatus403Schema = object({ message: string().describe("Error overview.") });
64181
+ var hostingStorageBillingModeNativeStatus422Schema = messageDataSchema;
64182
+ union([hostingStorageBillingModeNativeStatus200Schema, hostingStorageBillingModeNativeStatus201Schema]);
64183
+ union([
64184
+ hostingStorageBillingModeNativeStatus401Schema,
64185
+ hostingStorageBillingModeNativeStatus403Schema,
64186
+ hostingStorageBillingModeNativeStatus422Schema
64187
+ ]);
64188
+ var hostingStorageBillingModeAllocatedStatus200Schema = hostingStorageBucketDataSchema;
64189
+ var hostingStorageBillingModeAllocatedStatus201Schema = hostingStorageBucketDataSchema;
64190
+ var hostingStorageBillingModeAllocatedStatus401Schema = object({ message: string().describe("Error overview.") });
64191
+ var hostingStorageBillingModeAllocatedStatus403Schema = object({ message: string().describe("Error overview.") });
64192
+ var hostingStorageBillingModeAllocatedStatus422Schema = messageDataSchema;
64193
+ union([hostingStorageBillingModeAllocatedStatus200Schema, hostingStorageBillingModeAllocatedStatus201Schema]);
64194
+ union([
64195
+ hostingStorageBillingModeAllocatedStatus401Schema,
64196
+ hostingStorageBillingModeAllocatedStatus403Schema,
64197
+ hostingStorageBillingModeAllocatedStatus422Schema
64198
+ ]);
64199
+ updateHostingStorageCapacityRequestSchema.describe("Adding capacity to an existing purchase.\n\nOnly an increase is accepted: a client buys more space, and a decrease would have to remove objects or invent a\npartial refund, neither of which this product offers. The target capacity is the quote's own, and a quote for less\nthan the bucket holds is refused by the purchase service rather than silently accepting it.");
63938
64200
  union([
63939
64201
  object({ message: string().describe("Error overview.") }),
63940
64202
  object({ message: string().describe("Error overview.") }),
@@ -63991,6 +64253,7 @@ union([
63991
64253
  storeHostingStorageObjectGrantRequestSchema.describe("Asking for one short-lived signed URL for one object.\n\nThe direction decides the verb: a download signs a GET and an upload signs a PUT, so a browser or the CLI\ncan move the bytes itself. The key is the client's own path inside their bucket and is validated as a key,\nnot as a filesystem path — control characters are refused because they would break signing and logging.");
63992
64254
  int().min(10).max(1e5);
63993
64255
  uuid().nullish();
64256
+ boolean().optional().describe("Asking to price the allocation a usage-billed bucket would move to, rather than an increase to one it\nalready holds. The intent changes which refusals apply, so it is asked for rather than guessed.");
63994
64257
  union([
63995
64258
  object({ message: string().describe("Error overview.") }),
63996
64259
  object({ message: string().describe("Error overview.") }),
@@ -64527,6 +64790,20 @@ union([
64527
64790
  errors: record$1(string(), array(string())).describe("A detailed description of each field that failed validation.")
64528
64791
  })
64529
64792
  ]);
64793
+ hostingOperationKindEnumSchema.optional().describe("The lifecycle operations whose timing Hosting records. Each case is a family whose own owner already records when it started, what it was in and how it ended; `HostingOperationSourceImport` only projects those recorded instants into the shared timing tables. No case exists for a family without stage evidence of its own, and nothing here is a workflow engine: a case names work another owner already performed. - `reconcile` — the reconcile journal's named stages (`HostingDiagnosticsJournal`), which is what provisioning, updates and rollouts all converge through. - `build` — one `HostingBuild` attempt: queued, then run to an artifact. - `update` — one `HostingRelease` activation: prepared, then applied and made active. - `restore` — one `HostingApplicationRecovery` review/reset/restore, with its recorded phases. - `backup` — one observed backup run per track, as the existing backup readers saw it. The readers are cluster reads, so the projection is written where the platform already observes out of band; the operator's read never calls the cluster.\n");
64794
+ union([
64795
+ object({ message: string().describe("Error overview.") }),
64796
+ messageDataSchema,
64797
+ object({
64798
+ message: string().describe("Errors overview."),
64799
+ errors: record$1(string(), array(string())).describe("A detailed description of each field that failed validation.")
64800
+ })
64801
+ ]);
64802
+ union([
64803
+ object({ message: string().describe("Error overview.") }),
64804
+ messageDataSchema,
64805
+ messageDataSchema
64806
+ ]);
64530
64807
  string().regex(/^[0-9]{4}-(0[1-9]|1[0-2])$/).nullish();
64531
64808
  union([
64532
64809
  object({ message: string().describe("Error overview.") }),
@@ -69232,14 +69509,19 @@ function userText(user) {
69232
69509
  var STORAGE_USAGE = [
69233
69510
  "Usage: hostingctl storage list --company <slug>",
69234
69511
  " hostingctl storage show <bucket-uuid> --company <slug>",
69235
- " hostingctl storage quote --company <slug> --size <gb> [bucket-uuid]",
69512
+ " hostingctl storage quote --company <slug> --size <gb> [bucket-uuid] [--conversion]",
69236
69513
  " hostingctl storage downloads --company <slug> [--period YYYY-MM]",
69237
69514
  " hostingctl storage ceiling --company <slug>",
69238
69515
  " hostingctl storage ceiling --company <slug> (--set <rand>|--remove) [--confirm]",
69239
69516
  " hostingctl storage add --company <slug> --name <name> --size <gb>",
69240
69517
  " --quote-file <quote.json>",
69518
+ " hostingctl storage add --company <slug> --name <name> --mode native",
69241
69519
  " hostingctl storage grow <bucket-uuid> --company <slug> --size <gb>",
69242
69520
  " --quote-file <quote.json>",
69521
+ " hostingctl storage resize <bucket-uuid> --company <slug> --size <gb>",
69522
+ " hostingctl storage mode <bucket-uuid> --company <slug> --native",
69523
+ " hostingctl storage mode <bucket-uuid> --company <slug> --allocated --size <gb>",
69524
+ " --quote-file <quote.json>",
69243
69525
  " hostingctl storage rotate <bucket-uuid> --company <slug>",
69244
69526
  " hostingctl storage retire <bucket-uuid> --company <slug>",
69245
69527
  " hostingctl storage objects <bucket-uuid> --company <slug> [--prefix <key-prefix>]",
@@ -69252,14 +69534,19 @@ var STORAGE_USAGE = [
69252
69534
  "",
69253
69535
  " list Every bucket the company bought, its capacity, its usage and its bindings.",
69254
69536
  " show One bucket: the endpoint, bucket name and region to configure, and what it holds.",
69255
- " quote What a capacity costs, and the token a purchase or an increase is confirmed at it with.",
69537
+ " quote What a capacity costs, and the token a purchase, an increase or a conversion is confirmed at",
69538
+ " it with. --conversion prices the allocation a usage-billed bucket would move to.",
69256
69539
  " downloads One month of measured downloads: the external and platform bytes, the allowance, the",
69257
69540
  " chargeable blocks, the ceiling and what it absorbed.",
69258
69541
  " ceiling The most this company may be charged for download overage in a month. --set records a",
69259
69542
  " ceiling in rand, and --remove records that none applies.",
69260
69543
  " add Buy storage at a reviewed price. Capacity is sold in whole 10 GB blocks, from 10 to",
69261
- " 100000 GB.",
69544
+ " 100000 GB. --mode native buys a bucket that pays for what it stores instead, with no",
69545
+ " capacity and no price to confirm.",
69262
69546
  " grow Buy more capacity for a bucket at a reviewed price. Capacity is never reduced here.",
69547
+ " resize Hold a smaller allocation, cleared against what the bucket already stores.",
69548
+ " mode Which basis the bucket is billed on: --native charges for what it stores and",
69549
+ " --allocated reserves an allocation at a reviewed conversion price.",
69263
69550
  " rotate Issue a new access key; the secret is printed once and never again.",
69264
69551
  " retire Stop the bucket's access at the gateway. Every object is kept.",
69265
69552
  " objects One page of keys and sizes; --prefix narrows it to a key prefix.",
@@ -69269,10 +69556,10 @@ var STORAGE_USAGE = [
69269
69556
  " unbind Stop an environment reaching the bucket. The objects are unchanged.",
69270
69557
  "",
69271
69558
  "The bucket endpoint, name and region are what an S3 client is configured with; keys are issued by",
69272
- "`storage rotate` and the secret is shown in that one answer. A purchase and an increase are confirmed",
69273
- "at a price the client was shown: `storage quote --size <gb> --json > quote.json` saves it, and",
69274
- "`--quote-file quote.json` sends that same price back rather than accepting a newer one. Every write",
69275
- "needs --confirm; --dry-run describes the change without sending it."
69559
+ "`storage rotate` and the secret is shown in that one answer. A purchase, an increase and a conversion to",
69560
+ "an allocation are confirmed at a price the client was shown: `storage quote --size <gb> --json >",
69561
+ "quote.json` saves it, and `--quote-file quote.json` sends that same price back rather than accepting a",
69562
+ "newer one. Every write needs --confirm; --dry-run describes the change without sending it."
69276
69563
  ].join("\n");
69277
69564
  var STORAGE_METADATA = {
69278
69565
  name: "storage",
@@ -69284,10 +69571,15 @@ var STORAGE_METADATA = {
69284
69571
  takesValue: true,
69285
69572
  description: "The client's own label for the purchase, so two buckets can be told apart."
69286
69573
  },
69574
+ {
69575
+ name: "--mode",
69576
+ takesValue: true,
69577
+ description: "What `add` buys: native pays for what it stores and confirms no price, allocated reserves capacity at a reviewed price."
69578
+ },
69287
69579
  {
69288
69580
  name: "--size",
69289
69581
  takesValue: true,
69290
- description: "Capacity bought, in whole GB of at least 10 and in 10 GB blocks."
69582
+ description: "Capacity bought, reserved or reduced, in whole GB: at least 10, and in 10 GB blocks."
69291
69583
  },
69292
69584
  {
69293
69585
  name: "--prefix",
@@ -69322,7 +69614,7 @@ var STORAGE_METADATA = {
69322
69614
  {
69323
69615
  name: "--quote-file",
69324
69616
  takesValue: true,
69325
- description: "The saved answer of `storage quote --json`, whose price and token confirm a purchase or an increase."
69617
+ description: "The saved answer of `storage quote --json`, whose price and token confirm a purchase, an increase or a conversion."
69326
69618
  },
69327
69619
  {
69328
69620
  name: "--period",
@@ -69342,7 +69634,17 @@ var STORAGE_METADATA = {
69342
69634
  {
69343
69635
  name: "--native",
69344
69636
  takesValue: false,
69345
- description: "Record that the environment uses the S3 endpoint itself, so no mount is composed."
69637
+ description: "Record that the environment uses the S3 endpoint itself so no mount is composed, or that the bucket pays for what it stores."
69638
+ },
69639
+ {
69640
+ name: "--allocated",
69641
+ takesValue: false,
69642
+ description: "Record that the bucket reserves an allocation instead, at the price of a saved conversion quote."
69643
+ },
69644
+ {
69645
+ name: "--conversion",
69646
+ takesValue: false,
69647
+ description: "Price the allocation a usage-billed bucket would move to, rather than an increase to one it already holds."
69346
69648
  }
69347
69649
  ],
69348
69650
  subcommands: [
@@ -69353,6 +69655,8 @@ var STORAGE_METADATA = {
69353
69655
  "ceiling",
69354
69656
  "add",
69355
69657
  "grow",
69658
+ "resize",
69659
+ "mode",
69356
69660
  "rotate",
69357
69661
  "retire",
69358
69662
  "objects",
@@ -69449,69 +69753,92 @@ function ceilingCents(context) {
69449
69753
  return cents;
69450
69754
  }
69451
69755
  //#endregion
69452
- //#region src/commands/storage-downloads.ts
69756
+ //#region src/commands/storage-quote-file.ts
69757
+ /** Decimal bytes in one sold gigabyte: the unit a quote's block count is stated in. */
69758
+ var DECIMAL_BYTES_PER_GB = 1e9;
69453
69759
  /**
69454
- * What a company's downloads were billed, and the ceiling it sets on that bill.
69760
+ * The reviewed quote a confirmed purchase, increase or conversion is sent at.
69455
69761
  *
69456
- * Both halves are here because they are one promise: the accounting reports what the measured bytes were worth and
69457
- * what the ceiling saved, and `ceiling` is where a client changes that ceiling. As with every other storage write,
69458
- * setting or removing one goes through the shared gate: `--dry-run` describes it and sends nothing, and `--confirm`
69459
- * sends it.
69762
+ * The file is the answer `storage quote --json` printed, which is the only shape this reads: an
69763
+ * envelope naming the answer as a quote, holding the API's own quote DTO. The DTO is validated
69764
+ * through the generated schema rather than restated here, so the file cannot drift from the contract.
69460
69765
  *
69461
- * The two promises a ceiling can make are kept apart. Absent, the measured overage is charged in full; zero is a
69462
- * ceiling of its own, where every chargeable block is absorbed. A CLI that collapsed them would silently give away
69463
- * the product or silently switch the cap off, so removal sends `null` and never `0`.
69766
+ * Everything checked here is a local fact — the file is readable JSON in that shape, it prices the
69767
+ * capacity and bucket this run asked for, it answers the question this run asked, and it carries a
69768
+ * token at all. The company, the token's expiry and the commercial terms stay the API's: it is the
69769
+ * authority that can refuse a stale or foreign quote, and this loader must not pretend to be.
69464
69770
  */
69465
- /** `storage downloads`: one month of measured downloads for the whole company. */
69466
- async function downloads(context, tail) {
69467
- refuseExtra(tail);
69468
- const period = trimmedFlag(context, "--period");
69469
- return {
69470
- kind: "downloads",
69471
- downloads: (await hostingStorageDownloadsShow({
69472
- path: { company: await requireCompany(context.flags) },
69473
- query: { ...period === "" ? {} : { period } }
69474
- })).data
69475
- };
69771
+ function readSavedQuote(file, target) {
69772
+ const quote = quoteFrom(parsed(readBoundedImportFile(file, "storage quote"), file), file);
69773
+ assertSameTarget(quote, target, file);
69774
+ return quote;
69775
+ }
69776
+ /** The commands that produce a quote file and confirm it, in the order a client runs them. */
69777
+ function quoteSteps(company, target, name) {
69778
+ return [quoteCommand(company, target), confirmCommand(company, target, name)];
69779
+ }
69780
+ /** The command that saves the price this target is confirmed at, with the one flag that asked for it. */
69781
+ function quoteCommand(company, target) {
69782
+ return `hostingctl storage quote --company ${company} --size ${String(target.capacityGb)}${target.bucketUuid === null ? "" : ` ${target.bucketUuid}`}${target.conversion === true ? " --conversion" : ""} --json > quote.json`;
69783
+ }
69784
+ /** The command that sends that saved price back, for the one write this target names. */
69785
+ function confirmCommand(company, target, name) {
69786
+ const size = String(target.capacityGb);
69787
+ const confirm = "--quote-file quote.json --confirm";
69788
+ if (target.bucketUuid === null) return `hostingctl storage add --company ${company} --name ${name ?? "<name>"} --size ${size} ${confirm}`;
69789
+ if (target.conversion === true) return `hostingctl storage mode ${target.bucketUuid} --company ${company} --allocated --size ${size} ${confirm}`;
69790
+ return `hostingctl storage grow ${target.bucketUuid} --company ${company} --size ${size} ${confirm}`;
69476
69791
  }
69477
69792
  /**
69478
- * `storage ceiling`: the most this company may be charged for download overage in a month.
69793
+ * The quote a confirmed write sends, echoed whole, or a refusal that names the two commands which produce one.
69479
69794
  *
69480
- * With neither flag it is a read, because a client checks a promise far more often than they change one. `--set`
69481
- * takes the amount in rand and `--remove` takes nothing, and the two together are refused rather than ordered: they
69482
- * are two answers about one ceiling.
69795
+ * The API authenticates the quote it issued, so the write sends back the artifact the client read: the
69796
+ * amounts, the period, the currency and the capacity are the quote's own fields, and the confirmation token
69797
+ * travels inside it. Nothing is derived from the flags here, and nothing is re-read: a confirmed write never
69798
+ * asks for a fresh quote, so the retry that follows a refusal sends the same reviewed price.
69483
69799
  */
69484
- async function ceiling(context, tail) {
69485
- refuseExtra(tail);
69486
- const company = await requireCompany(context.flags);
69487
- const setting = context.flags.has("--set");
69488
- const removing = context.flags.has("--remove");
69489
- if (setting && removing) throw new UsageError(`Pass one of --set or --remove, not both.\n\n${STORAGE_USAGE}`);
69490
- if (!setting && !removing) return {
69491
- kind: "ceiling",
69492
- ceiling: (await hostingStorageDownloadCeilingShow({ path: { company } })).data
69493
- };
69494
- const cents = setting ? ceilingCents(context) : null;
69495
- return await confirmableWrite(context, ceilingDescription(company, cents), async () => {
69496
- return {
69497
- kind: "ceiling",
69498
- ceiling: (await hostingStorageDownloadCeilingUpdate({
69499
- path: { company },
69500
- body: { ceilingCents: cents }
69501
- })).data
69502
- };
69503
- });
69800
+ function confirmedQuote(quote, company, target, name) {
69801
+ if (quote === null) throw new UsageError([
69802
+ "Confirming a storage write needs the quote it is confirmed at: pass --quote-file <path>.",
69803
+ "",
69804
+ ...quoteSteps(company, target, name)
69805
+ ].join("\n"));
69806
+ return quote;
69807
+ }
69808
+ /** The file's text as JSON, with a refusal that names the path rather than printing its contents. */
69809
+ function parsed(contents, file) {
69810
+ let value;
69811
+ try {
69812
+ value = JSON.parse(contents);
69813
+ } catch {
69814
+ throw new UsageError(`The storage quote file [${file}] is not valid JSON.`);
69815
+ }
69816
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new UsageError(`The storage quote file [${file}] must contain the one JSON object \`storage quote --json\` prints.`);
69817
+ return value;
69818
+ }
69819
+ /** The quote inside the answer `storage quote --json` printed, validated by the API's own schema. */
69820
+ function quoteFrom(saved, file) {
69821
+ const quote = saved.kind === "quote" ? saved.quote : void 0;
69822
+ if (quote === void 0) throw new UsageError(`The storage quote file [${file}] is not a saved quote: it must be the answer \`storage quote --json\` printed.`);
69823
+ const checked = hostingStorageQuoteDataSchema.safeParse(quote);
69824
+ if (!checked.success) {
69825
+ const [issue] = checked.error.issues;
69826
+ throw new UsageError(`The storage quote file [${file}] is not a quote this CLI saved (${issue === void 0 ? "" : `${issue.path.join(".") || "quote"}: ${issue.message}`}). Ask for a fresh one.`);
69827
+ }
69828
+ return checked.data;
69504
69829
  }
69505
69830
  /**
69506
- * What a ceiling change would do, in the words of the two promises it can make.
69831
+ * Whether the quote prices this run: the capacity asked for, and the one bucket an increase is for.
69507
69832
  *
69508
- * The amount is stated in rand because a description is written before anything is read, so it has no currency code
69509
- * to print; the answer, which carries one, is rendered by `ceilingText`.
69833
+ * A quote for another capacity or another bucket would buy something else, so it is refused here
69834
+ * rather than confirmed and then refused by the API.
69510
69835
  */
69511
- function ceilingDescription(company, cents) {
69512
- if (cents === null) return `Remove the download overage ceiling for ${company}: measured overage above the included allowance is then charged in full.`;
69513
- if (cents === 0) return `Set the download overage ceiling for ${company} to ${randAmount(0)} a month, which is a ceiling of its own: no overage is allowed above the included allowance and every chargeable block is absorbed.`;
69514
- return `Set the download overage ceiling for ${company} to ${randAmount(cents)} a month, including VAT. Overage above it is absorbed by Hosting rather than charged.`;
69836
+ function assertSameTarget(quote, target, file) {
69837
+ const pricedGb = quote.targetBlocks * quote.blockBytes / DECIMAL_BYTES_PER_GB;
69838
+ if (pricedGb !== target.capacityGb) throw new UsageError(`The quote in [${file}] prices ${String(pricedGb)} GB, not the ${String(target.capacityGb)} GB this command asks for. Ask for a quote at this size.`);
69839
+ if (quote.bucketUuid !== target.bucketUuid) throw new UsageError(`The quote in [${file}] prices ${quote.bucketUuid === null ? "a new bucket" : `bucket ${quote.bucketUuid}`}, not the ${target.bucketUuid === null ? "a new bucket" : `bucket ${target.bucketUuid}`} this command asks for.`);
69840
+ if (target.conversion === true && quote.currentBlocks > 0) throw new UsageError(`The quote in [${file}] enlarges an allocation of ${String(quote.currentBlocks)} block(s), so it is not the price of switching this bucket to a reserved allocation. Ask for one with --conversion.`);
69841
+ if (quote.reviewToken === "") throw new UsageError(`The quote in [${file}] carries no confirmation token, so nothing can be confirmed with it. Ask for a fresh one.`);
69515
69842
  }
69516
69843
  //#endregion
69517
69844
  //#region src/commands/storage-downloads-text.ts
@@ -69628,13 +69955,14 @@ function storageChangeText(change) {
69628
69955
  /** Every bucket on one line each, so a list of purchases reads as a ledger. */
69629
69956
  function bucketsText(buckets) {
69630
69957
  if (buckets.length === 0) return "This company has bought no object storage.";
69631
- return buckets.map((bucket) => ` ${bucket.name} ${bucket.uuid} ${bucket.status} ${readableBytes(bucket.capacityBytes)} of storage, ${usageLine(bucket.usage)} ${String(bucket.bindings.length)} binding(s)`).join("\n");
69958
+ return buckets.map((bucket) => ` ${bucket.name} ${bucket.uuid} ${bucket.status} ${bucket.billingModeLabel} ${readableBytes(bucket.capacityBytes)} of storage, ${usageLine(bucket.usage)} ${String(bucket.bindings.length)} binding(s)`).join("\n");
69632
69959
  }
69633
69960
  /**
69634
69961
  * One bucket: how to connect to it, what it is allowed to hold, what it holds and who reaches it.
69635
69962
  *
69636
69963
  * The access key is reported as its hint, which is what the platform keeps. The secret exists only in the
69637
- * answer to the rotation that issued it.
69964
+ * answer to the rotation that issued it. The billing basis is reported in the API's own label, because what a
69965
+ * bucket pays for is the platform's vocabulary rather than something each surface should word for itself.
69638
69966
  */
69639
69967
  function bucketText(bucket) {
69640
69968
  const connection = bucket.connection;
@@ -69644,6 +69972,7 @@ function bucketText(bucket) {
69644
69972
  ` endpoint ${connection.endpoint}`,
69645
69973
  ` region ${connection.region}`,
69646
69974
  ` addressing ${connection.pathStyle ? "path-style" : "virtual-hosted-style"}`,
69975
+ ` billing ${bucket.billingModeLabel}`,
69647
69976
  ` capacity ${readableBytes(bucket.capacityBytes)}`,
69648
69977
  ` included download ${readableBytes(bucket.includedDownloadBytes)} a month`,
69649
69978
  ` hard quota ${bucket.hardQuotaEnforced ? "enforced by the gateway" : "not enforced"}`,
@@ -69713,8 +70042,9 @@ function quoteText(quote) {
69713
70042
  ` download ${formatMoney(quote.transferUnit.grossCents, quote.currency)} a block above ${readableBytes(quote.includedDownloadBytes)} included a month`,
69714
70043
  ` priced ${quote.productKey} at ${quote.generatedAt}`,
69715
70044
  "",
69716
- "Save this answer with --json and pass it back with --quote-file to confirm a purchase or an increase",
69717
- "at this price. Asking again prices afresh; the quote in this answer is what confirms it."
70045
+ "Save this answer with --json and pass it back with --quote-file to confirm a purchase, an increase or a",
70046
+ "conversion to an allocation at this price. Asking again prices afresh; the quote in this answer is what",
70047
+ "confirms it."
69718
70048
  ].join("\n");
69719
70049
  }
69720
70050
  /**
@@ -69759,101 +70089,268 @@ function issuedText(issued) {
69759
70089
  ].join("\n");
69760
70090
  }
69761
70091
  //#endregion
69762
- //#region src/commands/storage-quote-file.ts
69763
- /** Decimal bytes in one sold gigabyte: the unit a quote's block count is stated in. */
69764
- var DECIMAL_BYTES_PER_GB = 1e9;
70092
+ //#region src/commands/storage-review.ts
70093
+ /** `storage quote`: the price of one capacity, read from the API's price book rather than computed here. */
70094
+ async function quotedPrice(company, target) {
70095
+ return (await hostingStorageQuoteShow({
70096
+ path: { company },
70097
+ query: {
70098
+ capacityGb: target.capacityGb,
70099
+ ...target.bucketUuid === null ? {} : { bucket: target.bucketUuid },
70100
+ ...target.conversion === true ? { conversion: true } : {}
70101
+ }
70102
+ })).data;
70103
+ }
69765
70104
  /**
69766
- * The reviewed quote a confirmed purchase or increase is sent at.
70105
+ * The quote a run is reviewed against: the saved file when one was given, a fresh read for a dry run, and nothing
70106
+ * otherwise.
69767
70107
  *
69768
- * The file is the answer `storage quote --json` printed, which is the only shape this reads: an
69769
- * envelope naming the answer as a quote, holding the API's own quote DTO. The DTO is validated
69770
- * through the generated schema rather than restated here, so the file cannot drift from the contract.
70108
+ * A confirmed write never asks for a new price. The token a client confirms with is the one from the price they were
70109
+ * shown, so a retry after a refusal sends that same token instead of accepting a newer figure nobody reviewed.
70110
+ */
70111
+ async function reviewedQuote(context, company, target) {
70112
+ const file = trimmedFlag(context, "--quote-file");
70113
+ if (file !== "") return {
70114
+ quote: readSavedQuote(file, target),
70115
+ saved: true
70116
+ };
70117
+ if (!context.flags.has("--dry-run")) return null;
70118
+ return {
70119
+ quote: await quotedPrice(company, target),
70120
+ saved: false
70121
+ };
70122
+ }
70123
+ /**
70124
+ * The product `add` buys, from the one flag that names it.
69771
70125
  *
69772
- * Everything checked here is a local fact — the file is readable JSON in that shape, it prices the
69773
- * capacity and bucket this run asked for, and it carries a token at all. The company, the token's
69774
- * expiry and the commercial terms stay the API's: it is the authority that can refuse a stale or
69775
- * foreign quote, and this loader must not pretend to be.
70126
+ * Null means the client named none, which is the quote-priced allocation this command has always bought. Anything
70127
+ * else is refused here rather than sent, because the API would answer a usage error where a spelling mistake is.
69776
70128
  */
69777
- function readSavedQuote(file, target) {
69778
- const quote = quoteFrom(parsed(readBoundedImportFile(file, "storage quote"), file), file);
69779
- assertSameTarget(quote, target, file);
69780
- return quote;
70129
+ function requestedMode(context) {
70130
+ const mode = trimmedFlag(context, "--mode");
70131
+ if (mode === "") return null;
70132
+ if (mode !== "native" && mode !== "allocated") throw new UsageError(`--mode is native or allocated (got "${mode}").\n\n${STORAGE_USAGE}`);
70133
+ return mode;
69781
70134
  }
69782
- /** The commands that produce a quote file and confirm it, in the order a client runs them. */
69783
- function quoteSteps(company, target, name) {
69784
- const size = String(target.capacityGb);
69785
- return [target.bucketUuid === null ? `hostingctl storage quote --company ${company} --size ${size} --json > quote.json` : `hostingctl storage quote --company ${company} --size ${size} ${target.bucketUuid} --json > quote.json`, target.bucketUuid === null ? `hostingctl storage add --company ${company} --name ${name ?? "<name>"} --size ${size} --quote-file quote.json --confirm` : `hostingctl storage grow --company ${company} ${target.bucketUuid} --size ${size} --quote-file quote.json --confirm`];
70135
+ /**
70136
+ * Refuse the flags that only price a reserved allocation, for the writes that buy none.
70137
+ *
70138
+ * A capacity or a saved quote passed to a usage-billed write would be dropped silently, and the client would get an
70139
+ * unpriced change where they asked for a priced one.
70140
+ */
70141
+ function refusePricedFlags(context, subject) {
70142
+ if (!context.flags.has("--size") && trimmedFlag(context, "--quote-file") === "") return;
70143
+ throw new UsageError(`${subject} takes no capacity, so --size and --quote-file do not apply to it.\n\n${STORAGE_USAGE}`);
70144
+ }
70145
+ /** What a purchase would do, at the price it was quoted at when one was read. */
70146
+ function purchaseDescription(company, name, target, review) {
70147
+ return [`Buy ${String(target.capacityGb)} GB of object storage named "${name}" for ${company}. The bucket is provisioning until reconciliation completes.`, ...pricedLines(company, target, name, review)].join("\n");
70148
+ }
70149
+ /** The same for an increase, which the API refuses to turn into a decrease. */
70150
+ function increaseDescription(path, target, review) {
70151
+ return [`Grow ${describeBucket(path)} to ${String(target.capacityGb)} GB. Capacity is only ever added here, and the objects are unchanged.`, ...pricedLines(path.company, target, null, review)].join("\n");
70152
+ }
70153
+ /** What a purchase that pays for what it stores would do: no capacity, no price, and a bill that follows usage. */
70154
+ function nativePurchaseDescription(company, name) {
70155
+ return `Buy object storage named "${name}" for ${company} that pays for what it stores. It buys no capacity and confirms no price: the monthly bill follows what the platform measures, and reconciliation provisions the bucket after it is recorded.`;
70156
+ }
70157
+ /** What a conversion to a reserved allocation would do, at the price it was quoted at when one was read. */
70158
+ function conversionDescription(path, target, review) {
70159
+ return [`Bill ${describeBucket(path)} for a reserved allocation of ${String(target.capacityGb)} GB instead of for what it stores. The allocation has to hold what the bucket already stores, and the objects and issued keys are unchanged.`, ...pricedLines(path.company, target, null, review)].join("\n");
69786
70160
  }
69787
70161
  /**
69788
- * The quote a confirmed write sends, echoed whole, or a refusal that names the two commands which produce one.
70162
+ * The price a write would land at, or the two commands that produce a quote when none was read.
69789
70163
  *
69790
- * The API authenticates the quote it issued, so the write sends back the artifact the client read: the
69791
- * amounts, the period, the currency and the capacity are the quote's own fields, and the confirmation token
69792
- * travels inside it. Nothing is derived from the flags here, and nothing is re-read: a confirmed write never
69793
- * asks for a fresh quote, so the retry that follows a refusal sends the same reviewed price.
70164
+ * A price read during a dry run is shown with the commands that save it, because a confirmed write has to send a
70165
+ * price the client still holds. Nothing is sent here: this only says what confirming would need.
69794
70166
  */
69795
- function confirmedQuote(quote, company, target, name) {
69796
- if (quote === null) throw new UsageError([
69797
- "Confirming a storage write needs the quote it is confirmed at: pass --quote-file <path>.",
69798
- "",
70167
+ function pricedLines(company, target, name, review) {
70168
+ if (review === null) return ["Confirm it at a reviewed price:", ...quoteSteps(company, target, name)];
70169
+ if (review.saved) return [quotePriceLine(review.quote), "Confirming sends this saved quote's token, so the price is not asked for again."];
70170
+ return [
70171
+ quotePriceLine(review.quote),
70172
+ "To confirm at this price, save it and pass it back:",
69799
70173
  ...quoteSteps(company, target, name)
69800
- ].join("\n"));
69801
- return quote;
70174
+ ];
69802
70175
  }
69803
- /** The file's text as JSON, with a refusal that names the path rather than printing its contents. */
69804
- function parsed(contents, file) {
69805
- let value;
69806
- try {
69807
- value = JSON.parse(contents);
69808
- } catch {
69809
- throw new UsageError(`The storage quote file [${file}] is not valid JSON.`);
69810
- }
69811
- if (typeof value !== "object" || value === null || Array.isArray(value)) throw new UsageError(`The storage quote file [${file}] must contain the one JSON object \`storage quote --json\` prints.`);
69812
- return value;
70176
+ //#endregion
70177
+ //#region src/commands/storage-basis.ts
70178
+ /**
70179
+ * Which basis a bucket's storage is billed on, and how much of an allocation it keeps.
70180
+ *
70181
+ * A bucket pays on exactly one basis at a time, and the two conversions are not symmetrical. Moving to usage billing
70182
+ * costs nothing to request and has no price to confirm, but the API refuses it while a managed mount still reaches
70183
+ * the bucket: a directory that kept reading while the basis changed would be a mount nobody is billing. Moving to a
70184
+ * reserved allocation is a priced decision, so it is confirmed at a saved conversion quote exactly as a purchase is.
70185
+ *
70186
+ * Reducing an allocation is neither conversion: it is a resize, cleared by the API against the bucket's own recorded
70187
+ * usage rather than trimmed here.
70188
+ */
70189
+ /**
70190
+ * `storage mode <uuid>`: which basis the bucket's storage is billed on.
70191
+ *
70192
+ * Each conversion has its own route, so the form of the answer is the same as the form of the question.
70193
+ */
70194
+ async function billingMode(context, tail) {
70195
+ const path = await bucketPath(context, tail);
70196
+ const native = context.flags.has("--native");
70197
+ if (native === context.flags.has("--allocated")) throw new UsageError(`mode needs exactly one of --native or --allocated.\n\n${STORAGE_USAGE}`);
70198
+ return native ? await toNative(context, path) : await toAllocated(context, path);
69813
70199
  }
69814
- /** The quote inside the answer `storage quote --json` printed, validated by the API's own schema. */
69815
- function quoteFrom(saved, file) {
69816
- const quote = saved.kind === "quote" ? saved.quote : void 0;
69817
- if (quote === void 0) throw new UsageError(`The storage quote file [${file}] is not a saved quote: it must be the answer \`storage quote --json\` printed.`);
69818
- const checked = hostingStorageQuoteDataSchema.safeParse(quote);
69819
- if (!checked.success) {
69820
- const [issue] = checked.error.issues;
69821
- throw new UsageError(`The storage quote file [${file}] is not a quote this CLI saved (${issue === void 0 ? "" : `${issue.path.join(".") || "quote"}: ${issue.message}`}). Ask for a fresh one.`);
69822
- }
69823
- return checked.data;
70200
+ /** The free conversion: from the instant it lands the bill follows what the bucket stores. */
70201
+ async function toNative(context, path) {
70202
+ refusePricedFlags(context, "A bucket that pays for what it stores");
70203
+ return await confirmableWrite(context, `Bill ${describeBucket(path)} for what it stores instead of for a reserved allocation. Every managed mount has to be detached first, and the objects and issued keys are unchanged.`, async () => {
70204
+ return {
70205
+ kind: "bucket",
70206
+ bucket: (await hostingStorageBillingModeNative({ path })).data
70207
+ };
70208
+ });
70209
+ }
70210
+ /** The priced conversion: an allocation that has to hold what the bucket already stores. */
70211
+ async function toAllocated(context, path) {
70212
+ const target = {
70213
+ capacityGb: requiredSizeGb(context),
70214
+ bucketUuid: path.bucketUuid,
70215
+ conversion: true
70216
+ };
70217
+ const reviewed = await reviewedQuote(context, path.company, target);
70218
+ return await confirmableWrite(context, conversionDescription(path, target, reviewed), async () => {
70219
+ return {
70220
+ kind: "bucket",
70221
+ bucket: (await hostingStorageBillingModeAllocated({
70222
+ path,
70223
+ body: { quote: confirmedQuote(reviewed?.quote ?? null, path.company, target, null) }
70224
+ })).data
70225
+ };
70226
+ });
69824
70227
  }
69825
70228
  /**
69826
- * Whether the quote prices this run: the capacity asked for, and the one bucket an increase is for.
70229
+ * `storage resize <uuid> --size <gb>`: hold a smaller allocation.
69827
70230
  *
69828
- * A quote for another capacity or another bucket would buy something else, so it is refused here
69829
- * rather than confirmed and then refused by the API.
70231
+ * Reducing is not a negative purchase: the API clears the target against the bucket's own recorded usage, so a
70232
+ * capacity that would not hold what is already stored is refused there rather than trimmed here. A bucket that pays
70233
+ * for what it stores holds no allocation, and the API refuses to reduce one.
69830
70234
  */
69831
- function assertSameTarget(quote, target, file) {
69832
- const pricedGb = quote.targetBlocks * quote.blockBytes / DECIMAL_BYTES_PER_GB;
69833
- if (pricedGb !== target.capacityGb) throw new UsageError(`The quote in [${file}] prices ${String(pricedGb)} GB, not the ${String(target.capacityGb)} GB this command asks for. Ask for a quote at this size.`);
69834
- if (quote.bucketUuid !== target.bucketUuid) throw new UsageError(`The quote in [${file}] prices ${quote.bucketUuid === null ? "a new bucket" : `bucket ${quote.bucketUuid}`}, not the ${target.bucketUuid === null ? "a new bucket" : `bucket ${target.bucketUuid}`} this command asks for.`);
69835
- if (quote.reviewToken === "") throw new UsageError(`The quote in [${file}] carries no confirmation token, so nothing can be confirmed with it. Ask for a fresh one.`);
70235
+ async function resize(context, tail) {
70236
+ const path = await bucketPath(context, tail);
70237
+ const capacityGb = requiredSizeGb(context);
70238
+ return await confirmableWrite(context, `Reduce the allocation ${describeBucket(path)} holds to ${String(capacityGb)} GB. The API checks the target against what the bucket already stores, so a smaller capacity than that is refused; the objects and issued keys are unchanged.`, async () => {
70239
+ return {
70240
+ kind: "bucket",
70241
+ bucket: (await hostingStorageAllocationReduce({
70242
+ path,
70243
+ body: { capacityGb }
70244
+ })).data
70245
+ };
70246
+ });
69836
70247
  }
69837
70248
  //#endregion
69838
- //#region src/commands/storage-writes.ts
69839
- /** `storage quote`: the price of one capacity, read from the API's price book rather than computed here. */
69840
- async function quotedPrice(company, capacityGb, bucketUuid) {
69841
- return (await hostingStorageQuoteShow({
69842
- path: { company },
69843
- query: bucketUuid === null ? { capacityGb } : {
69844
- capacityGb,
69845
- bucket: bucketUuid
69846
- }
69847
- })).data;
70249
+ //#region src/commands/storage-downloads.ts
70250
+ /**
70251
+ * What a company's downloads were billed, and the ceiling it sets on that bill.
70252
+ *
70253
+ * Both halves are here because they are one promise: the accounting reports what the measured bytes were worth and
70254
+ * what the ceiling saved, and `ceiling` is where a client changes that ceiling. As with every other storage write,
70255
+ * setting or removing one goes through the shared gate: `--dry-run` describes it and sends nothing, and `--confirm`
70256
+ * sends it.
70257
+ *
70258
+ * The two promises a ceiling can make are kept apart. Absent, the measured overage is charged in full; zero is a
70259
+ * ceiling of its own, where every chargeable block is absorbed. A CLI that collapsed them would silently give away
70260
+ * the product or silently switch the cap off, so removal sends `null` and never `0`.
70261
+ */
70262
+ /** `storage downloads`: one month of measured downloads for the whole company. */
70263
+ async function downloads(context, tail) {
70264
+ refuseExtra(tail);
70265
+ const period = trimmedFlag(context, "--period");
70266
+ return {
70267
+ kind: "downloads",
70268
+ downloads: (await hostingStorageDownloadsShow({
70269
+ path: { company: await requireCompany(context.flags) },
70270
+ query: { ...period === "" ? {} : { period } }
70271
+ })).data
70272
+ };
70273
+ }
70274
+ /**
70275
+ * `storage ceiling`: the most this company may be charged for download overage in a month.
70276
+ *
70277
+ * With neither flag it is a read, because a client checks a promise far more often than they change one. `--set`
70278
+ * takes the amount in rand and `--remove` takes nothing, and the two together are refused rather than ordered: they
70279
+ * are two answers about one ceiling.
70280
+ */
70281
+ async function ceiling(context, tail) {
70282
+ refuseExtra(tail);
70283
+ const company = await requireCompany(context.flags);
70284
+ const setting = context.flags.has("--set");
70285
+ const removing = context.flags.has("--remove");
70286
+ if (setting && removing) throw new UsageError(`Pass one of --set or --remove, not both.\n\n${STORAGE_USAGE}`);
70287
+ if (!setting && !removing) return {
70288
+ kind: "ceiling",
70289
+ ceiling: (await hostingStorageDownloadCeilingShow({ path: { company } })).data
70290
+ };
70291
+ const cents = setting ? ceilingCents(context) : null;
70292
+ return await confirmableWrite(context, ceilingDescription(company, cents), async () => {
70293
+ return {
70294
+ kind: "ceiling",
70295
+ ceiling: (await hostingStorageDownloadCeilingUpdate({
70296
+ path: { company },
70297
+ body: { ceilingCents: cents }
70298
+ })).data
70299
+ };
70300
+ });
70301
+ }
70302
+ /**
70303
+ * What a ceiling change would do, in the words of the two promises it can make.
70304
+ *
70305
+ * The amount is stated in rand because a description is written before anything is read, so it has no currency code
70306
+ * to print; the answer, which carries one, is rendered by `ceilingText`.
70307
+ */
70308
+ function ceilingDescription(company, cents) {
70309
+ if (cents === null) return `Remove the download overage ceiling for ${company}: measured overage above the included allowance is then charged in full.`;
70310
+ if (cents === 0) return `Set the download overage ceiling for ${company} to ${randAmount(0)} a month, which is a ceiling of its own: no overage is allowed above the included allowance and every chargeable block is absorbed.`;
70311
+ return `Set the download overage ceiling for ${company} to ${randAmount(cents)} a month, including VAT. Overage above it is absorbed by Hosting rather than charged.`;
69848
70312
  }
69849
- /** `storage add`: buy a bucket. The API records the purchase and reconciles it after the commit. */
70313
+ //#endregion
70314
+ //#region src/commands/storage-purchase.ts
70315
+ /**
70316
+ * Buying capacity: a new bucket, or more of one that already exists.
70317
+ *
70318
+ * The two products buy differently. An allocation is confirmed at a price the client was shown, so its confirmation
70319
+ * sends the token from a saved `storage quote --json` answer rather than asking for a second price it would then
70320
+ * accept unseen. A bucket that pays for what it stores buys no capacity, so it confirms no price at all and its
70321
+ * route carries a name and nothing else.
70322
+ *
70323
+ * Both are desired-state writes: the API records the intent, answers the row it recorded, and the reconcile job does
70324
+ * the provider and gateway work afterwards.
70325
+ *
70326
+ * The price review they share, the conversions that also cost money and the allocation reduction live beside this in
70327
+ * `storage-review` and `storage-basis`; the writes that address a live bucket live in `storage-writes`.
70328
+ */
70329
+ /**
70330
+ * `storage add`: buy a bucket.
70331
+ *
70332
+ * Two products answer here, each at its own route because they confirm different things. `--mode native` buys a
70333
+ * bucket that pays for what it stores, so it sends a name and no quote; the quote-priced allocation is what every
70334
+ * other invocation buys, and it is confirmed at a saved price.
70335
+ */
69850
70336
  async function add(context, tail) {
69851
70337
  refuseExtra(tail);
69852
70338
  const name = requiredName(context);
69853
- const capacityGb = requiredSizeGb(context);
69854
70339
  const company = await requireCompany(context.flags);
70340
+ if (requestedMode(context) === "native") {
70341
+ refusePricedFlags(context, "A purchase that pays for what it stores");
70342
+ return await confirmableWrite(context, nativePurchaseDescription(company, name), async () => {
70343
+ return {
70344
+ kind: "bucket",
70345
+ bucket: (await hostingStorageStoreNative({
70346
+ path: { company },
70347
+ body: { name }
70348
+ })).data
70349
+ };
70350
+ });
70351
+ }
69855
70352
  const target = {
69856
- capacityGb,
70353
+ capacityGb: requiredSizeGb(context),
69857
70354
  bucketUuid: null
69858
70355
  };
69859
70356
  const reviewed = await reviewedQuote(context, company, target);
@@ -69888,6 +70385,19 @@ async function grow(context, tail) {
69888
70385
  };
69889
70386
  });
69890
70387
  }
70388
+ //#endregion
70389
+ //#region src/commands/storage-writes.ts
70390
+ /**
70391
+ * The writes that address a bucket that already exists: its key, its retirement and its bindings.
70392
+ *
70393
+ * Every write here goes through `confirmableWrite` — a dry run describes the change and sends nothing, and the change
70394
+ * needs `--confirm`. None of them is priced, so none of them reads or confirms a quote: what a bucket costs is
70395
+ * decided by the purchase, the basis change and the resize, which live beside this in `storage-purchase` and
70396
+ * `storage-basis`.
70397
+ *
70398
+ * `rotate` is the only command in the whole CLI that prints a secret, and it prints it in that single answer because
70399
+ * the platform cannot return it again. Everything else here reports the key's hint and never the key.
70400
+ */
69891
70401
  /**
69892
70402
  * `storage rotate <uuid>`: the one answer that carries a secret.
69893
70403
  *
@@ -69948,49 +70458,6 @@ async function unbind(context, tail) {
69948
70458
  };
69949
70459
  });
69950
70460
  }
69951
- /**
69952
- * The quote a run is reviewed against: the saved file when one was given, a fresh read for a dry run, and
69953
- * nothing otherwise.
69954
- *
69955
- * A confirmed write never asks for a new price. The token a client confirms with is the one from the price
69956
- * they were shown, so a retry after a refusal sends that same token instead of accepting a newer figure
69957
- * nobody reviewed.
69958
- */
69959
- async function reviewedQuote(context, company, target) {
69960
- const file = trimmedFlag(context, "--quote-file");
69961
- if (file !== "") return {
69962
- quote: readSavedQuote(file, target),
69963
- saved: true
69964
- };
69965
- if (!context.flags.has("--dry-run")) return null;
69966
- return {
69967
- quote: await quotedPrice(company, target.capacityGb, target.bucketUuid),
69968
- saved: false
69969
- };
69970
- }
69971
- /** What a purchase would do, at the price it was quoted at when one was read. */
69972
- function purchaseDescription(company, name, target, review) {
69973
- return [`Buy ${String(target.capacityGb)} GB of object storage named "${name}" for ${company}. The bucket is provisioning until reconciliation completes.`, ...pricedLines(company, target, name, review)].join("\n");
69974
- }
69975
- /** The same for an increase, which the API refuses to turn into a decrease. */
69976
- function increaseDescription(path, target, review) {
69977
- return [`Grow ${describeBucket(path)} to ${String(target.capacityGb)} GB. Capacity is only ever added here, and the objects are unchanged.`, ...pricedLines(path.company, target, null, review)].join("\n");
69978
- }
69979
- /**
69980
- * The price a write would land at, or the two commands that produce a quote when none was read.
69981
- *
69982
- * A price read during a dry run is shown with the commands that save it, because a confirmed write has to send
69983
- * a price the client still holds. Nothing is sent here: this only says what confirming would need.
69984
- */
69985
- function pricedLines(company, target, name, review) {
69986
- if (review === null) return ["Confirm it at a reviewed price:", ...quoteSteps(company, target, name)];
69987
- if (review.saved) return [quotePriceLine(review.quote), "Confirming sends this saved quote's token, so the price is not asked for again."];
69988
- return [
69989
- quotePriceLine(review.quote),
69990
- "To confirm at this price, save it and pass it back:",
69991
- ...quoteSteps(company, target, name)
69992
- ];
69993
- }
69994
70461
  //#endregion
69995
70462
  //#region src/commands/storage.ts
69996
70463
  /**
@@ -70000,6 +70467,9 @@ function pricedLines(company, target, name, review) {
70000
70467
  * reconcile job does the provider and gateway work. So `add` and `grow` report the row they recorded rather
70001
70468
  * than a bucket that is already reachable, and `show` is how a client checks what reconciliation reached.
70002
70469
  *
70470
+ * A bucket is billed on exactly one basis. `storage mode` moves it between them and `storage resize` lowers a
70471
+ * reserved allocation, while the buckets themselves report the basis as the label the API prints for it.
70472
+ *
70003
70473
  * `rotate` is the only command that prints a secret, and it prints it in that single answer, because the
70004
70474
  * platform cannot return it again. Everything else reports the key's hint and never the key.
70005
70475
  *
@@ -70024,6 +70494,8 @@ async function dispatch$1(context) {
70024
70494
  case "ceiling": return await ceiling(context, tail);
70025
70495
  case "add": return await add(context, tail);
70026
70496
  case "grow": return await grow(context, tail);
70497
+ case "resize": return await resize(context, tail);
70498
+ case "mode": return await billingMode(context, tail);
70027
70499
  case "rotate": return await rotate(context, tail);
70028
70500
  case "retire": return await retire(context, tail);
70029
70501
  case "objects": return await objects(context, tail);
@@ -70050,17 +70522,24 @@ async function show(context, tail) {
70050
70522
  };
70051
70523
  }
70052
70524
  /**
70053
- * `storage quote`: what one capacity costs, for a new bucket or for enlarging one.
70525
+ * `storage quote`: what one capacity costs, for a new bucket, for enlarging one, or for the allocation a
70526
+ * usage-billed bucket would move to.
70054
70527
  *
70055
70528
  * Nothing is bought by asking, so there is no `--confirm`: the answer is the price, and saving it is what
70056
- * lets a purchase be confirmed at it.
70529
+ * lets a purchase, an increase or a conversion be confirmed at it.
70057
70530
  */
70058
70531
  async function quote(context, tail) {
70059
70532
  const bucketUuid = optionalBucketUuid(tail);
70060
70533
  const capacityGb = requiredSizeGb(context);
70534
+ const conversion = context.flags.has("--conversion");
70535
+ if (conversion && bucketUuid === null) throw new UsageError(`--conversion prices the allocation one bucket would move to, so it needs the bucket.\n\n${STORAGE_USAGE}`);
70061
70536
  return {
70062
70537
  kind: "quote",
70063
- quote: await quotedPrice(await requireCompany(context.flags), capacityGb, bucketUuid)
70538
+ quote: await quotedPrice(await requireCompany(context.flags), {
70539
+ capacityGb,
70540
+ bucketUuid,
70541
+ conversion
70542
+ })
70064
70543
  };
70065
70544
  }
70066
70545
  /** `storage objects <uuid>`: one bounded page of keys and sizes, optionally under a prefix. */
@@ -70810,7 +71289,7 @@ function writeUpdateState(state, env = process.env) {
70810
71289
  }
70811
71290
  //#endregion
70812
71291
  //#region src/version.ts
70813
- var VERSION = "1.0.551";
71292
+ var VERSION = "1.0.563";
70814
71293
  //#endregion
70815
71294
  //#region src/commands/update.ts
70816
71295
  /**
@@ -70885,7 +71364,7 @@ var update = {
70885
71364
  }, process.env);
70886
71365
  return {
70887
71366
  ...known,
70888
- current: after ?? "1.0.551",
71367
+ current: after ?? "1.0.563",
70889
71368
  latest: after ?? latest,
70890
71369
  upToDate: after !== null && (latest === null || !isNewerVersion(latest, after)),
70891
71370
  action: "run",
@@ -71162,7 +71641,7 @@ async function printUpdateNotice(options) {
71162
71641
  }, env, { waitMs: NOTICE_LOCK_WAIT_MS });
71163
71642
  } catch {}
71164
71643
  if (latest === null) return;
71165
- if (!isNewerVersion(latest, "1.0.551")) return;
71644
+ if (!isNewerVersion(latest, "1.0.563")) return;
71166
71645
  process.stderr.write(`A newer hostingctl is published: ${latest} (this copy is ${VERSION}). Run \`hostingctl update\` to update.\n`);
71167
71646
  }
71168
71647
  /** Whether an environment variable is set to something, which is how CI and the opt-out are read. */