@haakco/hostingctl 1.0.539 → 1.0.549

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -208,7 +208,7 @@ metadata and compared against it in CI. The groups, in one line each:
208
208
  | `purchases` | What a company was sold: the record, its size and its term |
209
209
  | `backup-destination` | The company's own bucket that also receives its backups |
210
210
  | `secret-connection` | An environment's connections to a customer's own secret manager |
211
- | `storage` | Purchased object storage: a capacity's price, the purchase or an increase at that price, the bucket's connection facts, its keys, objects and bindings |
211
+ | `storage` | Purchased object storage: a capacity's price, the purchase or an increase at that price, the bucket's connection facts, its keys, objects and bindings, the downloads measured for a month, and the ceiling that caps the overage bill |
212
212
  | `company` | The company itself, its members and roles, its activity, its logo and favicon, and the invitation journey |
213
213
  | `environment` | Create, read, scale, retry; profile coverage, domains and redirects, databases and exports, configuration and secrets, services, site access, shared runtime and application, tools, tuning, retention, portable export, and the release bundle |
214
214
  | `application` | Create, rename, remove; build and deploy, build logs, runs and run logs, process schedules; recovery review and confirm; the HTTP cache and path routes; source binding; site access; the WordPress import and URL repair; the administrator credential; the component's publishable anonymous key |
package/dist/main.js CHANGED
@@ -35074,6 +35074,38 @@ function hostingStorageBindingsDestroy(options) {
35074
35074
  }));
35075
35075
  }
35076
35076
  /**
35077
+ * {@link /c/:company/hosting/storage-download-ceiling}
35078
+ */
35079
+ function hostingStorageDownloadCeilingShow(options) {
35080
+ const { client: request = client, ...config } = options;
35081
+ return withUnwrap(request({
35082
+ method: "GET",
35083
+ url: "/c/{company}/hosting/storage-download-ceiling",
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-download-ceiling}
35094
+ */
35095
+ function hostingStorageDownloadCeilingUpdate(options) {
35096
+ const { client: request = client, ...config } = options;
35097
+ return withUnwrap(request({
35098
+ method: "PUT",
35099
+ url: "/c/{company}/hosting/storage-download-ceiling",
35100
+ security: [{
35101
+ type: "http",
35102
+ scheme: "bearer"
35103
+ }],
35104
+ ...config,
35105
+ throwOnError: config.throwOnError ?? true
35106
+ }));
35107
+ }
35108
+ /**
35077
35109
  * {@link /c/:company/hosting/storage/:bucketUuid/credentials}
35078
35110
  */
35079
35111
  function hostingStorageCredentialsStore(options) {
@@ -35090,6 +35122,22 @@ function hostingStorageCredentialsStore(options) {
35090
35122
  }));
35091
35123
  }
35092
35124
  /**
35125
+ * {@link /c/:company/hosting/storage-downloads}
35126
+ */
35127
+ function hostingStorageDownloadsShow(options) {
35128
+ const { client: request = client, ...config } = options;
35129
+ return withUnwrap(request({
35130
+ method: "GET",
35131
+ url: "/c/{company}/hosting/storage-downloads",
35132
+ security: [{
35133
+ type: "http",
35134
+ scheme: "bearer"
35135
+ }],
35136
+ ...config,
35137
+ throwOnError: config.throwOnError ?? true
35138
+ }));
35139
+ }
35140
+ /**
35093
35141
  * {@link /c/:company/hosting/storage/:bucketUuid/objects}
35094
35142
  */
35095
35143
  function hostingStorageObjectsIndex(options) {
@@ -41443,6 +41491,24 @@ function requiredFlag$3(context, flag, usage) {
41443
41491
  if (value === "") throw new UsageError(`${flag} is required.\n\n${usage}`);
41444
41492
  return value;
41445
41493
  }
41494
+ /**
41495
+ * A plain decimal with at most two places, as the integer minor units it spells.
41496
+ *
41497
+ * The digits are joined rather than the value multiplied as a float: `Number("1.255") * 100` is just under
41498
+ * 125.5, so `Math.round` would return 125 cents and drop a third decimal nobody agreed to. Null means the
41499
+ * text is not a decimal this scale can hold exactly, so the caller refuses it instead of rounding it.
41500
+ *
41501
+ * It lives here rather than beside either caller because more than one command group takes an amount: billing
41502
+ * takes one for a price or a settlement, and storage takes one for a download ceiling. A second copy is where
41503
+ * the two would start disagreeing about the third decimal.
41504
+ */
41505
+ function minorUnits(raw) {
41506
+ const parts = /^(\d+)(?:\.(\d{1,2}))?$/.exec(raw);
41507
+ if (parts === null) return null;
41508
+ const [, whole = "", fraction = ""] = parts;
41509
+ const units = Number.parseInt(`${whole}${fraction.padEnd(2, "0")}`, 10);
41510
+ return Number.isSafeInteger(units) ? units : null;
41511
+ }
41446
41512
  //#endregion
41447
41513
  //#region src/commands/backup-destination-metadata.ts
41448
41514
  /**
@@ -41671,6 +41737,16 @@ function formatMoney(cents, currency) {
41671
41737
  const fraction = (magnitude % 100).toString().padStart(2, "0");
41672
41738
  return `${currency} ${cents < 0 ? "-" : ""}${String(whole).replace(/\B(?=(\d{3})+(?!\d))/g, " ")}.${fraction}`;
41673
41739
  }
41740
+ /**
41741
+ * Cents as the rand amount a description states, for money the API has not denominated yet.
41742
+ *
41743
+ * A description is written before anything is read, so it has no currency code to print: the platform bills in rand,
41744
+ * and an amount stated in the unit the caller typed is the honest form. An answer that carries a currency uses
41745
+ * [`formatMoney`] instead.
41746
+ */
41747
+ function randAmount(cents) {
41748
+ return `${(cents / 100).toFixed(2)} rand`;
41749
+ }
41674
41750
  //#endregion
41675
41751
  //#region src/commands/billing-text-documents.ts
41676
41752
  /**
@@ -41987,20 +42063,6 @@ function requiredFlag$2(context, flag) {
41987
42063
  if (value.trim() === "") throw new UsageError(`${flag} is required.\n\n${BILLING_USAGE}`);
41988
42064
  return value.trim();
41989
42065
  }
41990
- /**
41991
- * A plain decimal with at most two places, as the integer minor units it spells.
41992
- *
41993
- * The digits are joined rather than the value multiplied as a float: `Number("1.255") * 100` is just under
41994
- * 125.5, so `Math.round` would return 125 cents and drop a third decimal nobody agreed to. Null means the
41995
- * text is not a decimal this scale can hold exactly, so the caller refuses it instead of rounding it.
41996
- */
41997
- function minorUnits(raw) {
41998
- const parts = /^(\d+)(?:\.(\d{1,2}))?$/.exec(raw);
41999
- if (parts === null) return null;
42000
- const [, whole = "", fraction = ""] = parts;
42001
- const units = Number.parseInt(`${whole}${fraction.padEnd(2, "0")}`, 10);
42002
- return Number.isSafeInteger(units) ? units : null;
42003
- }
42004
42066
  /** Rand to cents, refusing anything that is not a positive amount of money. */
42005
42067
  function randToCents$1(context, flag) {
42006
42068
  const raw = requiredFlag$2(context, flag);
@@ -42033,7 +42095,7 @@ async function startRate(context) {
42033
42095
  const company = optional$5(context, "--company");
42034
42096
  return {
42035
42097
  kind: "write",
42036
- outcome: await confirmableWrite(context, `Start a ${chosen} rate${packageKey === null ? "" : ` for ${packageKey}`} of ${(amountCents / 100).toFixed(2)} rand${company === null ? " for every company" : ` for ${company}`} from ${effectiveFrom}.`, async () => platformBillingRateStore({ body: {
42098
+ outcome: await confirmableWrite(context, `Start a ${chosen} rate${packageKey === null ? "" : ` for ${packageKey}`} of ${randAmount(amountCents)}${company === null ? " for every company" : ` for ${company}`} from ${effectiveFrom}.`, async () => platformBillingRateStore({ body: {
42037
42099
  product: chosen,
42038
42100
  packageKey,
42039
42101
  amountCents,
@@ -42408,7 +42470,7 @@ async function reconcileCharged(context, company, attemptUuid, note) {
42408
42470
  const receivedAt = requiredFlag$2(context, "--received-at");
42409
42471
  return {
42410
42472
  kind: "collectionReceipt",
42411
- outcome: await confirmableWrite(context, `Record that attempt ${attemptUuid} for ${company} settled ${(amountCents / 100).toFixed(2)} rand on ${receivedAt}, provider transaction ${transaction}, noting: ${note}. This records a settlement the provider already made; it sends no charge.`, async () => platformBillingCollectionReconcileCharged({
42473
+ outcome: await confirmableWrite(context, `Record that attempt ${attemptUuid} for ${company} settled ${randAmount(amountCents)} on ${receivedAt}, provider transaction ${transaction}, noting: ${note}. This records a settlement the provider already made; it sends no charge.`, async () => platformBillingCollectionReconcileCharged({
42412
42474
  path: {
42413
42475
  company,
42414
42476
  attemptUuid
@@ -42442,7 +42504,7 @@ async function collectionReceipt(context) {
42442
42504
  const note = requiredFlag$2(context, "--note");
42443
42505
  return {
42444
42506
  kind: "collectionReceipt",
42445
- outcome: await confirmableWrite(context, `Record ${(amountCents / 100).toFixed(2)} rand received outside Hosting against invoice ${invoiceUuid} for ${company} on ${receivedAt}, provider transaction ${transaction}, noting: ${note}. This states what a person verified: it sends no charge and manufactures no gateway evidence.`, async () => platformBillingCollectionRecordReceipt({
42507
+ outcome: await confirmableWrite(context, `Record ${randAmount(amountCents)} received outside Hosting against invoice ${invoiceUuid} for ${company} on ${receivedAt}, provider transaction ${transaction}, noting: ${note}. This states what a person verified: it sends no charge and manufactures no gateway evidence.`, async () => platformBillingCollectionRecordReceipt({
42446
42508
  path: {
42447
42509
  company,
42448
42510
  invoiceUuid
@@ -56467,6 +56529,7 @@ object({
56467
56529
  netCents: int(),
56468
56530
  vatCents: int(),
56469
56531
  grossCents: int(),
56532
+ absorbedCents: int(),
56470
56533
  issuable: boolean(),
56471
56534
  lines: array(billingRunLineDataSchema),
56472
56535
  differences: array(billingRunDifferenceDataSchema),
@@ -60215,6 +60278,12 @@ var hostingStorageBucketDataSchema = object({
60215
60278
  retiredAt: string().nullable()
60216
60279
  });
60217
60280
  object({ items: array(hostingStorageBucketDataSchema) });
60281
+ object({
60282
+ ceilingCents: int().nullable(),
60283
+ effectiveFrom: string().nullable(),
60284
+ currency: string()
60285
+ });
60286
+ var hostingStorageCeilingRequestSchema = object({ ceilingCents: int().min(0).max(1e8).nullable() }).describe("Setting the most a company may be charged for S3 download overage in a month.\n\nThe amount includes VAT, like every other storage price, and zero is a real choice: it means the client allows no\noverage at all. `ceilingCents: null` is how the ceiling is removed, which is a different promise from zero and must\nnot be expressible by omission — a body without the key is refused rather than read as \"remove it\".");
60218
60287
  object({ items: array(object({
60219
60288
  uuid: string(),
60220
60289
  accessKeyHint: string(),
@@ -60223,6 +60292,36 @@ object({ items: array(object({
60223
60292
  activatedAt: string().nullable(),
60224
60293
  revokedAt: string().nullable()
60225
60294
  })) });
60295
+ var hostingStorageDownloadBucketDataSchema = object({
60296
+ bucketUuid: string(),
60297
+ bucketName: string(),
60298
+ state: string(),
60299
+ sealedThrough: string().nullable(),
60300
+ externalBytes: int(),
60301
+ platformBytes: int(),
60302
+ includedBytes: int(),
60303
+ chargeableBytes: int(),
60304
+ chargeableBlocks: int()
60305
+ });
60306
+ var hostingStorageDownloadsDataSchema = object({
60307
+ localPeriod: string(),
60308
+ windowFrom: string(),
60309
+ windowTo: string(),
60310
+ currency: string(),
60311
+ measured: boolean(),
60312
+ priced: boolean(),
60313
+ platformReadsDistinguishable: boolean(),
60314
+ ceilingCents: int().nullable(),
60315
+ externalBytes: int(),
60316
+ platformBytes: int(),
60317
+ includedBytes: int(),
60318
+ chargeableBytes: int(),
60319
+ chargeableBlocks: int(),
60320
+ uncappedCents: int(),
60321
+ chargedCents: int(),
60322
+ absorbedCents: int(),
60323
+ buckets: array(hostingStorageDownloadBucketDataSchema)
60324
+ });
60226
60325
  object({
60227
60326
  uuid: string(),
60228
60327
  accessKeyId: string(),
@@ -60522,6 +60621,25 @@ object({
60522
60621
  routing: array(platformDomainRoutingObservationDataSchema),
60523
60622
  transfer: union([domainTransferDataSchema, _null()])
60524
60623
  });
60624
+ var platformStorageAccountingRowDataSchema = object({
60625
+ companySlug: string(),
60626
+ companyName: string(),
60627
+ usage: hostingStorageDownloadsDataSchema
60628
+ });
60629
+ object({
60630
+ localPeriod: string(),
60631
+ windowFrom: string(),
60632
+ windowTo: string(),
60633
+ currency: string(),
60634
+ platformReadsDistinguishable: boolean(),
60635
+ externalBytes: int(),
60636
+ platformBytes: int(),
60637
+ chargedCents: int(),
60638
+ absorbedCents: int(),
60639
+ measuredCompanies: int(),
60640
+ unmeasuredCompanies: int(),
60641
+ companies: array(platformStorageAccountingRowDataSchema)
60642
+ });
60525
60643
  var platformUserCompanyDataSchema = object({
60526
60644
  slug: string(),
60527
60645
  name: string(),
@@ -63828,7 +63946,24 @@ union([
63828
63946
  object({ message: string().describe("Error overview.") }),
63829
63947
  messageDataSchema
63830
63948
  ]);
63949
+ hostingStorageCeilingRequestSchema.describe("Setting the most a company may be charged for S3 download overage in a month.\n\nThe amount includes VAT, like every other storage price, and zero is a real choice: it means the client allows no\noverage at all. `ceilingCents: null` is how the ceiling is removed, which is a different promise from zero and must\nnot be expressible by omission — a body without the key is refused rather than read as \"remove it\".");
63831
63950
  union([object({ message: string().describe("Error overview.") }), object({ message: string().describe("Error overview.") })]);
63951
+ union([
63952
+ object({ message: string().describe("Error overview.") }),
63953
+ object({ message: string().describe("Error overview.") }),
63954
+ messageDataSchema
63955
+ ]);
63956
+ union([object({ message: string().describe("Error overview.") }), object({ message: string().describe("Error overview.") })]);
63957
+ string().regex(/^[0-9]{4}-(0[1-9]|1[0-2])$/).nullish();
63958
+ union([
63959
+ object({ message: string().describe("Error overview.") }),
63960
+ object({ message: string().describe("Error overview.") }),
63961
+ object({ message: string().describe("Error overview.") }),
63962
+ object({
63963
+ message: string().describe("Errors overview."),
63964
+ errors: record$1(string(), array(string())).describe("A detailed description of each field that failed validation.")
63965
+ })
63966
+ ]);
63832
63967
  string().optional().describe("Only list keys beginning with this prefix.");
63833
63968
  string().optional().describe("The nextToken from a previous page.");
63834
63969
  int().optional().describe("Keys to return in this page (bounded by the platform maximum).");
@@ -64390,6 +64525,15 @@ union([
64390
64525
  errors: record$1(string(), array(string())).describe("A detailed description of each field that failed validation.")
64391
64526
  })
64392
64527
  ]);
64528
+ string().regex(/^[0-9]{4}-(0[1-9]|1[0-2])$/).nullish();
64529
+ union([
64530
+ object({ message: string().describe("Error overview.") }),
64531
+ object({ message: string().describe("Error overview.") }),
64532
+ object({
64533
+ message: string().describe("Errors overview."),
64534
+ errors: record$1(string(), array(string())).describe("A detailed description of each field that failed validation.")
64535
+ })
64536
+ ]);
64393
64537
  union([
64394
64538
  object({ message: string().describe("Error overview.") }),
64395
64539
  messageDataSchema,
@@ -69087,6 +69231,9 @@ var STORAGE_USAGE = [
69087
69231
  "Usage: hostingctl storage list --company <slug>",
69088
69232
  " hostingctl storage show <bucket-uuid> --company <slug>",
69089
69233
  " hostingctl storage quote --company <slug> --size <gb> [bucket-uuid]",
69234
+ " hostingctl storage downloads --company <slug> [--period YYYY-MM]",
69235
+ " hostingctl storage ceiling --company <slug>",
69236
+ " hostingctl storage ceiling --company <slug> (--set <rand>|--remove) [--confirm]",
69090
69237
  " hostingctl storage add --company <slug> --name <name> --size <gb>",
69091
69238
  " --quote-file <quote.json>",
69092
69239
  " hostingctl storage grow <bucket-uuid> --company <slug> --size <gb>",
@@ -69104,6 +69251,10 @@ var STORAGE_USAGE = [
69104
69251
  " list Every bucket the company bought, its capacity, its usage and its bindings.",
69105
69252
  " show One bucket: the endpoint, bucket name and region to configure, and what it holds.",
69106
69253
  " quote What a capacity costs, and the token a purchase or an increase is confirmed at it with.",
69254
+ " downloads One month of measured downloads: the external and platform bytes, the allowance, the",
69255
+ " chargeable blocks, the ceiling and what it absorbed.",
69256
+ " ceiling The most this company may be charged for download overage in a month. --set records a",
69257
+ " ceiling in rand, and --remove records that none applies.",
69107
69258
  " add Buy storage at a reviewed price. Capacity is sold in whole 10 GB blocks, from 10 to",
69108
69259
  " 100000 GB.",
69109
69260
  " grow Buy more capacity for a bucket at a reviewed price. Capacity is never reduced here.",
@@ -69171,6 +69322,21 @@ var STORAGE_METADATA = {
69171
69322
  takesValue: true,
69172
69323
  description: "The saved answer of `storage quote --json`, whose price and token confirm a purchase or an increase."
69173
69324
  },
69325
+ {
69326
+ name: "--period",
69327
+ takesValue: true,
69328
+ description: "The local month the downloads are reported for, as YYYY-MM; the current month when it is left out."
69329
+ },
69330
+ {
69331
+ name: "--set",
69332
+ takesValue: true,
69333
+ description: "The most download overage may cost in a month, in rand including VAT; zero allows no overage at all."
69334
+ },
69335
+ {
69336
+ name: "--remove",
69337
+ takesValue: false,
69338
+ description: "Record that no download overage ceiling applies, so measured overage is charged in full."
69339
+ },
69174
69340
  {
69175
69341
  name: "--native",
69176
69342
  takesValue: false,
@@ -69181,6 +69347,8 @@ var STORAGE_METADATA = {
69181
69347
  "list",
69182
69348
  "show",
69183
69349
  "quote",
69350
+ "downloads",
69351
+ "ceiling",
69184
69352
  "add",
69185
69353
  "grow",
69186
69354
  "rotate",
@@ -69265,6 +69433,162 @@ function trimmedFlag(context, flag) {
69265
69433
  function describeBucket(path) {
69266
69434
  return `bucket ${path.bucketUuid} (${path.company})`;
69267
69435
  }
69436
+ /**
69437
+ * The ceiling `--set` names, in cents.
69438
+ *
69439
+ * Billing's own decimal parse is reused rather than written a second time, because `Number("1.255") * 100` is where
69440
+ * an amount gains or loses a cent. Zero is accepted here and refused by `randToCents`: a ceiling of zero is a real
69441
+ * promise — no overage above the allowance is charged — while an invoice for nothing is not an amount at all.
69442
+ */
69443
+ function ceilingCents(context) {
69444
+ const raw = requiredFlag$3(context, "--set", STORAGE_USAGE);
69445
+ const cents = minorUnits(raw);
69446
+ if (cents === null) throw new UsageError(`--set must be an amount of rand with at most two decimal places, e.g. 250.00 (got ${raw}).\n\n${STORAGE_USAGE}`);
69447
+ return cents;
69448
+ }
69449
+ //#endregion
69450
+ //#region src/commands/storage-downloads.ts
69451
+ /**
69452
+ * What a company's downloads were billed, and the ceiling it sets on that bill.
69453
+ *
69454
+ * Both halves are here because they are one promise: the accounting reports what the measured bytes were worth and
69455
+ * what the ceiling saved, and `ceiling` is where a client changes that ceiling. As with every other storage write,
69456
+ * setting or removing one goes through the shared gate: `--dry-run` describes it and sends nothing, and `--confirm`
69457
+ * sends it.
69458
+ *
69459
+ * The two promises a ceiling can make are kept apart. Absent, the measured overage is charged in full; zero is a
69460
+ * ceiling of its own, where every chargeable block is absorbed. A CLI that collapsed them would silently give away
69461
+ * the product or silently switch the cap off, so removal sends `null` and never `0`.
69462
+ */
69463
+ /** `storage downloads`: one month of measured downloads for the whole company. */
69464
+ async function downloads(context, tail) {
69465
+ refuseExtra(tail);
69466
+ const period = trimmedFlag(context, "--period");
69467
+ return {
69468
+ kind: "downloads",
69469
+ downloads: (await hostingStorageDownloadsShow({
69470
+ path: { company: await requireCompany(context.flags) },
69471
+ query: { ...period === "" ? {} : { period } }
69472
+ })).data
69473
+ };
69474
+ }
69475
+ /**
69476
+ * `storage ceiling`: the most this company may be charged for download overage in a month.
69477
+ *
69478
+ * With neither flag it is a read, because a client checks a promise far more often than they change one. `--set`
69479
+ * takes the amount in rand and `--remove` takes nothing, and the two together are refused rather than ordered: they
69480
+ * are two answers about one ceiling.
69481
+ */
69482
+ async function ceiling(context, tail) {
69483
+ refuseExtra(tail);
69484
+ const company = await requireCompany(context.flags);
69485
+ const setting = context.flags.has("--set");
69486
+ const removing = context.flags.has("--remove");
69487
+ if (setting && removing) throw new UsageError(`Pass one of --set or --remove, not both.\n\n${STORAGE_USAGE}`);
69488
+ if (!setting && !removing) return {
69489
+ kind: "ceiling",
69490
+ ceiling: (await hostingStorageDownloadCeilingShow({ path: { company } })).data
69491
+ };
69492
+ const cents = setting ? ceilingCents(context) : null;
69493
+ return await confirmableWrite(context, ceilingDescription(company, cents), async () => {
69494
+ return {
69495
+ kind: "ceiling",
69496
+ ceiling: (await hostingStorageDownloadCeilingUpdate({
69497
+ path: { company },
69498
+ body: { ceilingCents: cents }
69499
+ })).data
69500
+ };
69501
+ });
69502
+ }
69503
+ /**
69504
+ * What a ceiling change would do, in the words of the two promises it can make.
69505
+ *
69506
+ * The amount is stated in rand because a description is written before anything is read, so it has no currency code
69507
+ * to print; the answer, which carries one, is rendered by `ceilingText`.
69508
+ */
69509
+ function ceilingDescription(company, cents) {
69510
+ if (cents === null) return `Remove the download overage ceiling for ${company}: measured overage above the included allowance is then charged in full.`;
69511
+ 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.`;
69512
+ 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.`;
69513
+ }
69514
+ //#endregion
69515
+ //#region src/commands/storage-downloads-text.ts
69516
+ /**
69517
+ * How the download accounting answers a person.
69518
+ *
69519
+ * Every figure is the API's own, and the three facts a client cannot derive are printed rather than inferred:
69520
+ *
69521
+ * - a month that is not fully measured is called partial, because its bytes are what was read so far and not the
69522
+ * month's whole bill;
69523
+ * - `platformBytes` is what the platform read itself, so a deployment that cannot tell platform reads from external
69524
+ * ones says that instead of printing a zero it did not measure;
69525
+ * - the money is three numbers — what the bytes were worth, what was charged, and what the ceiling absorbed — so a
69526
+ * capped bill can be reconciled against the client's own usage.
69527
+ *
69528
+ * The ceiling is printed in the three states the contract keeps apart: absent (overage is charged in full), zero (no
69529
+ * overage is allowed and every block is absorbed), and an amount (overage above it is absorbed).
69530
+ */
69531
+ /** One month of downloads: what was read, what the allowance covered and what the ceiling saved. */
69532
+ function downloadsText(downloads) {
69533
+ return [
69534
+ ` period ${downloads.localPeriod}, ${downloads.windowFrom} to ${downloads.windowTo}`,
69535
+ ` measured ${measuredLine(downloads)}`,
69536
+ ` external ${readableBytes(downloads.externalBytes)}`,
69537
+ ` platform ${platformFigure(downloads.platformBytes, downloads.platformReadsDistinguishable)}`,
69538
+ ` included ${readableBytes(downloads.includedBytes)} a month, across ${String(downloads.buckets.length)} bucket(s)`,
69539
+ ` chargeable ${String(downloads.chargeableBlocks)} block(s) above the allowance, from ${readableBytes(downloads.chargeableBytes)}`,
69540
+ ` ceiling ${ceilingFigure(downloads.ceilingCents, downloads.currency)}`,
69541
+ ` uncapped ${formatMoney(downloads.uncappedCents, downloads.currency)} for the measured bytes`,
69542
+ ` charged ${formatMoney(downloads.chargedCents, downloads.currency)} after the ceiling`,
69543
+ ` absorbed ${formatMoney(downloads.absorbedCents, downloads.currency)} carried by Hosting`,
69544
+ "",
69545
+ ...bucketLines(downloads.buckets, downloads.platformReadsDistinguishable)
69546
+ ].join("\n");
69547
+ }
69548
+ /** The ceiling a company has now, or the fact that overage is charged in full. */
69549
+ function ceilingText(ceiling) {
69550
+ return [
69551
+ ` ceiling ${ceilingFigure(ceiling.ceilingCents, ceiling.currency)}`,
69552
+ ` currency ${ceiling.currency}`,
69553
+ ...ceiling.effectiveFrom === null ? [] : [` effective from ${ceiling.effectiveFrom}`],
69554
+ "",
69555
+ "A ceiling is spent in bucket order, and the row recorded at the end of a month governs that month: changing it",
69556
+ "now cannot rewrite a month already closed."
69557
+ ].join("\n");
69558
+ }
69559
+ /** Whether the month was measured, and what a partial reading means for the figures beside it. */
69560
+ function measuredLine(downloads) {
69561
+ if (!downloads.measured) return "no: at least one bucket's month is not fully proved, so these are the figures measured so far";
69562
+ if (!downloads.priced) return "yes, though it is not priced yet, so the charge below is only what the measured bytes imply";
69563
+ return "yes: every bucket's month is proved and priced";
69564
+ }
69565
+ /**
69566
+ * What the platform read itself, or the fact that this deployment cannot tell such a read from an external one.
69567
+ *
69568
+ * An indistinct reading is an unanswered question rather than a measured zero, and printing `0 B` would claim the
69569
+ * platform read nothing at all. The distinction is a property of the deployment, so every figure is printed under
69570
+ * the one flag the answer carries for it.
69571
+ */
69572
+ function platformFigure(bytes, distinguishable) {
69573
+ if (!distinguishable) return "not distinguishable from external reads on this deployment, so no zero is claimed";
69574
+ return readableBytes(bytes);
69575
+ }
69576
+ /** The ceiling a month was billed under, in the three states the contract keeps apart. */
69577
+ function ceilingFigure(cents, currency) {
69578
+ if (cents === null) return "none set, so measured overage above the allowance is charged in full";
69579
+ if (cents === 0) return `${formatMoney(0, currency)} a month: no overage is allowed, so every chargeable block is absorbed`;
69580
+ return `${formatMoney(cents, currency)} a month, above which overage is absorbed rather than charged`;
69581
+ }
69582
+ /** One line per bucket, in the order the charge was spent. */
69583
+ function bucketLines(buckets, platformDistinguishable) {
69584
+ if (buckets.length === 0) return ["No bucket was billable for storage in this month."];
69585
+ return buckets.map((bucket) => ` ${bucket.bucketName} ${bucket.bucketUuid} ${bucketState(bucket)} external ${readableBytes(bucket.externalBytes)}, platform ${platformFigure(bucket.platformBytes, platformDistinguishable)}, ${readableBytes(bucket.includedBytes)} included, ${String(bucket.chargeableBlocks)} block(s) above it, ${readableBytes(bucket.chargeableBytes)} chargeable`);
69586
+ }
69587
+ /** Whether one bucket's month was proved, with the instant it was sealed at and what an open month means. */
69588
+ function bucketState(bucket) {
69589
+ if (bucket.state !== "complete") return "incomplete: nothing chargeable is counted for it";
69590
+ return bucket.sealedThrough === null ? "complete" : `complete, sealed through ${bucket.sealedThrough}`;
69591
+ }
69268
69592
  //#endregion
69269
69593
  //#region src/commands/storage-text.ts
69270
69594
  /**
@@ -69284,6 +69608,8 @@ function storageText(report) {
69284
69608
  case "objects": return objectsText(report.page, report.prefix);
69285
69609
  case "grant": return grantText(report.grant);
69286
69610
  case "quote": return quoteText(report.quote);
69611
+ case "downloads": return downloadsText(report.downloads);
69612
+ case "ceiling": return ceilingText(report.ceiling);
69287
69613
  case "bucket": return bucketText(report.bucket);
69288
69614
  }
69289
69615
  }
@@ -69293,6 +69619,7 @@ function storageChangeText(change) {
69293
69619
  case "issued": return issuedText(change.issued);
69294
69620
  case "binding": return `Bound to environment ${change.binding.environmentUuid}: ${bindingReach(change.binding)}.`;
69295
69621
  case "unbound": return `Environment ${change.environmentUuid} no longer reaches bucket ${change.bucketUuid}. Its objects are unchanged.`;
69622
+ case "ceiling": return ceilingText(change.ceiling);
69296
69623
  case "bucket": return bucketText(change.bucket);
69297
69624
  }
69298
69625
  }
@@ -69691,6 +70018,8 @@ async function dispatch$1(context) {
69691
70018
  case "list": return await list$1(context, tail);
69692
70019
  case "show": return await show(context, tail);
69693
70020
  case "quote": return await quote(context, tail);
70021
+ case "downloads": return await downloads(context, tail);
70022
+ case "ceiling": return await ceiling(context, tail);
69694
70023
  case "add": return await add(context, tail);
69695
70024
  case "grow": return await grow(context, tail);
69696
70025
  case "rotate": return await rotate(context, tail);
@@ -70479,7 +70808,7 @@ function writeUpdateState(state, env = process.env) {
70479
70808
  }
70480
70809
  //#endregion
70481
70810
  //#region src/version.ts
70482
- var VERSION = "1.0.539";
70811
+ var VERSION = "1.0.549";
70483
70812
  //#endregion
70484
70813
  //#region src/commands/update.ts
70485
70814
  /**
@@ -70554,7 +70883,7 @@ var update = {
70554
70883
  }, process.env);
70555
70884
  return {
70556
70885
  ...known,
70557
- current: after ?? "1.0.539",
70886
+ current: after ?? "1.0.549",
70558
70887
  latest: after ?? latest,
70559
70888
  upToDate: after !== null && (latest === null || !isNewerVersion(latest, after)),
70560
70889
  action: "run",
@@ -70831,7 +71160,7 @@ async function printUpdateNotice(options) {
70831
71160
  }, env, { waitMs: NOTICE_LOCK_WAIT_MS });
70832
71161
  } catch {}
70833
71162
  if (latest === null) return;
70834
- if (!isNewerVersion(latest, "1.0.539")) return;
71163
+ if (!isNewerVersion(latest, "1.0.549")) return;
70835
71164
  process.stderr.write(`A newer hostingctl is published: ${latest} (this copy is ${VERSION}). Run \`hostingctl update\` to update.\n`);
70836
71165
  }
70837
71166
  /** Whether an environment variable is set to something, which is how CI and the opt-out are read. */