@shipstatic/types 2.26.0-beta.2 → 2.26.0-beta.4

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/index.d.ts CHANGED
@@ -479,13 +479,25 @@ export interface SetupInstructionsResponse {
479
479
  * one key cannot mean both. See {@link DeploymentDeleteResponse} for the law.
480
480
  */
481
481
  export interface DomainValidateResponse {
482
- /** Whether the domain is valid */
482
+ /** Whether the domain's SHAPE is usable: format, and the caller's own rules. */
483
483
  valid: boolean;
484
484
  /** Normalized domain name, null when invalid */
485
485
  normalized: string | null;
486
- /** Whether the domain is available, null when invalid */
486
+ /**
487
+ * Whether nobody has registered the name yet; null when invalid.
488
+ *
489
+ * It answers "would creating this be new", not "would a write succeed": `PUT
490
+ * /domains/:domain` is an upsert, which is how a domain is re-pointed, so a
491
+ * caller's OWN domain is unavailable here and writable there. Availability
492
+ * does not depend on the kind of name.
493
+ */
487
494
  available: boolean | null;
488
- /** Why the name is unusable, null when valid — displayed verbatim. */
495
+ /**
496
+ * Why the name is unusable, displayed verbatim; null exactly when it IS
497
+ * usable. A name is unusable when it is invalid OR unavailable, and both
498
+ * carry a reason, so a client reads this field alone for the verdict and
499
+ * invents no copy of its own.
500
+ */
489
501
  reason: string | null;
490
502
  }
491
503
  /**
@@ -1825,6 +1837,15 @@ export declare function formatDuration(seconds: number): string;
1825
1837
  * why that case is `null` rather than a sentence.
1826
1838
  */
1827
1839
  export declare function formatTimeRemaining(expires: number, now?: number): string | null;
1840
+ /**
1841
+ * A byte count as a person reads it: `"180 KB"`, `"2.5 MB"`, `"0 Bytes"`.
1842
+ *
1843
+ * Binary units, one decimal by default, and `decimals` for a surface with its
1844
+ * own density (a dense table reads `"3 MB"` at 0). A deployment's size reads
1845
+ * this way on every surface that states one: the console, the CLI, the deploy
1846
+ * card and the API's own refusals, so one deployment is one number everywhere.
1847
+ */
1848
+ export declare function formatFileSize(bytes: number, decimals?: number): string;
1828
1849
  /**
1829
1850
  * Universal deploy input — the union of every shape the SDK accepts.
1830
1851
  *
package/dist/index.js CHANGED
@@ -1776,6 +1776,25 @@ function countOf(count, unit) {
1776
1776
  return `${count} ${unit}${count === 1 ? '' : 's'}`;
1777
1777
  }
1778
1778
  // =============================================================================
1779
+ // FILE SIZE
1780
+ // =============================================================================
1781
+ /**
1782
+ * A byte count as a person reads it: `"180 KB"`, `"2.5 MB"`, `"0 Bytes"`.
1783
+ *
1784
+ * Binary units, one decimal by default, and `decimals` for a surface with its
1785
+ * own density (a dense table reads `"3 MB"` at 0). A deployment's size reads
1786
+ * this way on every surface that states one: the console, the CLI, the deploy
1787
+ * card and the API's own refusals, so one deployment is one number everywhere.
1788
+ */
1789
+ export function formatFileSize(bytes, decimals = 1) {
1790
+ if (bytes === 0)
1791
+ return '0 Bytes';
1792
+ const k = 1024;
1793
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
1794
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
1795
+ return `${Number.parseFloat((bytes / k ** i).toFixed(decimals))} ${sizes[i]}`;
1796
+ }
1797
+ // =============================================================================
1779
1798
  // FILE UPLOAD TYPES
1780
1799
  // =============================================================================
1781
1800
  /**
package/dist/schemas.js CHANGED
@@ -165,10 +165,16 @@ export const DomainShareResponseSchema = z.object({
165
165
  .describe('The shareable DNS setup URL; whoever opens it sees the records to configure, with no API key.'),
166
166
  });
167
167
  export const DomainValidateResponseSchema = z.object({
168
- valid: z.boolean().describe('Whether the domain name is valid.'),
168
+ valid: z.boolean().describe("Whether the domain's shape is usable."),
169
169
  normalized: z.string().nullable().describe('The normalized domain name; null when invalid.'),
170
- available: z.boolean().nullable().describe('Whether the domain is available; null when invalid.'),
171
- reason: z.string().nullable().describe('Why the name is unusable, for display; null when valid.'),
170
+ available: z
171
+ .boolean()
172
+ .nullable()
173
+ .describe('Whether nobody has registered the name yet; null when invalid. Creating it would be new; re-pointing your own domain is a write, not a create.'),
174
+ reason: z
175
+ .string()
176
+ .nullable()
177
+ .describe('Why the name is unusable, for display; null when it is usable.'),
172
178
  });
173
179
  // =============================================================================
174
180
  // ACCOUNT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipstatic/types",
3
- "version": "2.26.0-beta.2",
3
+ "version": "2.26.0-beta.4",
4
4
  "description": "Shared TypeScript types for the ShipStatic platform.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -538,13 +538,25 @@ export interface SetupInstructionsResponse {
538
538
  * one key cannot mean both. See {@link DeploymentDeleteResponse} for the law.
539
539
  */
540
540
  export interface DomainValidateResponse {
541
- /** Whether the domain is valid */
541
+ /** Whether the domain's SHAPE is usable: format, and the caller's own rules. */
542
542
  valid: boolean;
543
543
  /** Normalized domain name, null when invalid */
544
544
  normalized: string | null;
545
- /** Whether the domain is available, null when invalid */
545
+ /**
546
+ * Whether nobody has registered the name yet; null when invalid.
547
+ *
548
+ * It answers "would creating this be new", not "would a write succeed": `PUT
549
+ * /domains/:domain` is an upsert, which is how a domain is re-pointed, so a
550
+ * caller's OWN domain is unavailable here and writable there. Availability
551
+ * does not depend on the kind of name.
552
+ */
546
553
  available: boolean | null;
547
- /** Why the name is unusable, null when valid — displayed verbatim. */
554
+ /**
555
+ * Why the name is unusable, displayed verbatim; null exactly when it IS
556
+ * usable. A name is unusable when it is invalid OR unavailable, and both
557
+ * carry a reason, so a client reads this field alone for the verdict and
558
+ * invents no copy of its own.
559
+ */
548
560
  reason: string | null;
549
561
  }
550
562
 
@@ -2701,6 +2713,26 @@ function countOf(count: number, unit: string): string {
2701
2713
  return `${count} ${unit}${count === 1 ? '' : 's'}`;
2702
2714
  }
2703
2715
 
2716
+ // =============================================================================
2717
+ // FILE SIZE
2718
+ // =============================================================================
2719
+
2720
+ /**
2721
+ * A byte count as a person reads it: `"180 KB"`, `"2.5 MB"`, `"0 Bytes"`.
2722
+ *
2723
+ * Binary units, one decimal by default, and `decimals` for a surface with its
2724
+ * own density (a dense table reads `"3 MB"` at 0). A deployment's size reads
2725
+ * this way on every surface that states one: the console, the CLI, the deploy
2726
+ * card and the API's own refusals, so one deployment is one number everywhere.
2727
+ */
2728
+ export function formatFileSize(bytes: number, decimals: number = 1): string {
2729
+ if (bytes === 0) return '0 Bytes';
2730
+ const k = 1024;
2731
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
2732
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
2733
+ return `${Number.parseFloat((bytes / k ** i).toFixed(decimals))} ${sizes[i]}`;
2734
+ }
2735
+
2704
2736
  // =============================================================================
2705
2737
  // RESOURCE INTERFACE CONTRACTS
2706
2738
  // =============================================================================
package/src/schemas.ts CHANGED
@@ -218,10 +218,18 @@ export const DomainShareResponseSchema = z.object({
218
218
  });
219
219
 
220
220
  export const DomainValidateResponseSchema = z.object({
221
- valid: z.boolean().describe('Whether the domain name is valid.'),
221
+ valid: z.boolean().describe("Whether the domain's shape is usable."),
222
222
  normalized: z.string().nullable().describe('The normalized domain name; null when invalid.'),
223
- available: z.boolean().nullable().describe('Whether the domain is available; null when invalid.'),
224
- reason: z.string().nullable().describe('Why the name is unusable, for display; null when valid.'),
223
+ available: z
224
+ .boolean()
225
+ .nullable()
226
+ .describe(
227
+ 'Whether nobody has registered the name yet; null when invalid. Creating it would be new; re-pointing your own domain is a write, not a create.',
228
+ ),
229
+ reason: z
230
+ .string()
231
+ .nullable()
232
+ .describe('Why the name is unusable, for display; null when it is usable.'),
225
233
  });
226
234
 
227
235
  // =============================================================================