@shipstatic/ship 2.0.0-beta.0 → 2.0.0-beta.2

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.cts CHANGED
@@ -11,7 +11,7 @@ declare const DeploymentStatus: {
11
11
  readonly FAILED: "failed";
12
12
  readonly DELETING: "deleting";
13
13
  };
14
- type DeploymentStatusType = typeof DeploymentStatus[keyof typeof DeploymentStatus];
14
+ type DeploymentStatusType = (typeof DeploymentStatus)[keyof typeof DeploymentStatus];
15
15
  /**
16
16
  * Core deployment object - used in both API responses and SDK
17
17
  */
@@ -74,7 +74,7 @@ declare const DomainStatus: {
74
74
  readonly SUCCESS: "success";
75
75
  readonly PAUSED: "paused";
76
76
  };
77
- type DomainStatusType = typeof DomainStatus[keyof typeof DomainStatus];
77
+ type DomainStatusType = (typeof DomainStatus)[keyof typeof DomainStatus];
78
78
  /**
79
79
  * Core domain object - used in both API responses and SDK
80
80
  */
@@ -229,7 +229,7 @@ declare const AccountPlan: {
229
229
  readonly TERMINATING: "terminating";
230
230
  readonly TERMINATED: "terminated";
231
231
  };
232
- type AccountPlanType = typeof AccountPlan[keyof typeof AccountPlan];
232
+ type AccountPlanType = (typeof AccountPlan)[keyof typeof AccountPlan];
233
233
  /**
234
234
  * Account usage metrics — always available regardless of billing provider.
235
235
  */
@@ -324,7 +324,7 @@ declare const ErrorType: {
324
324
  /** Configuration error. Client-side only — set by SDK during config parsing/validation; never produced server-side. */
325
325
  readonly Config: "config_error";
326
326
  };
327
- type ErrorType = typeof ErrorType[keyof typeof ErrorType];
327
+ type ErrorType = (typeof ErrorType)[keyof typeof ErrorType];
328
328
  /**
329
329
  * Standard error response format used everywhere
330
330
  */
@@ -536,7 +536,7 @@ declare const AuthMethod: {
536
536
  readonly WEBHOOK: "webhook";
537
537
  readonly SYSTEM: "system";
538
538
  };
539
- type AuthMethodType = typeof AuthMethod[keyof typeof AuthMethod];
539
+ type AuthMethodType = (typeof AuthMethod)[keyof typeof AuthMethod];
540
540
  /**
541
541
  * Shape constants for API keys (`ship-{64 hex chars}`).
542
542
  * Single source of truth used by validation utilities and auth middleware.
@@ -595,7 +595,7 @@ declare const TokenKind: {
595
595
  readonly DEPLOY_TOKEN: "token";
596
596
  readonly OPAQUE: "opaque";
597
597
  };
598
- type TokenKindType = typeof TokenKind[keyof typeof TokenKind];
598
+ type TokenKindType = (typeof TokenKind)[keyof typeof TokenKind];
599
599
  /**
600
600
  * Classify a client token by shape. The single dispatch used by both sides
601
601
  * of the wire: API auth middleware (which population is this credential?)
@@ -621,7 +621,7 @@ declare const OAuthScope: {
621
621
  readonly DOMAINS_READ: "domains:read";
622
622
  readonly DOMAINS_WRITE: "domains:write";
623
623
  };
624
- type OAuthScopeType = typeof OAuthScope[keyof typeof OAuthScope];
624
+ type OAuthScopeType = (typeof OAuthScope)[keyof typeof OAuthScope];
625
625
  declare const DEPLOYMENT_CONFIG_FILENAME = "ship.json";
626
626
  /** Default ship.json config for SPA routing. Single source of truth — used by both API and SDK. */
627
627
  declare const SPA_DEFAULT_CONFIG: {
@@ -924,7 +924,7 @@ declare const FileValidationStatus: {
924
924
  /** File passed validation and is ready for deployment */
925
925
  readonly READY: "ready";
926
926
  };
927
- type FileValidationStatusType = typeof FileValidationStatus[keyof typeof FileValidationStatus];
927
+ type FileValidationStatusType = (typeof FileValidationStatus)[keyof typeof FileValidationStatus];
928
928
  /**
929
929
  * A validation issue with a display-ready message
930
930
  *
@@ -1376,7 +1376,7 @@ declare class ApiHttp extends SimpleEvents {
1376
1376
  getAccount(): Promise<AccountGetResponse>;
1377
1377
  getLimits(): Promise<PlatformLimits>;
1378
1378
  ping(): Promise<boolean>;
1379
- checkSPA(files: StaticFile[], options?: ApiDeployOptions): Promise<boolean>;
1379
+ checkSPA(files: StaticFile[], _options?: ApiDeployOptions): Promise<boolean>;
1380
1380
  }
1381
1381
 
1382
1382
  /**
@@ -1518,91 +1518,6 @@ declare abstract class Ship$1 {
1518
1518
  */
1519
1519
  declare function mergeDeployOptions(options: DeploymentOptions, clientDefaults: ShipClientOptions): DeploymentOptions;
1520
1520
 
1521
- interface MD5Result {
1522
- md5: string;
1523
- }
1524
- declare function calculateMD5(input: Blob | Buffer | string): Promise<MD5Result>;
1525
-
1526
- /**
1527
- * Utility functions for string manipulation.
1528
- */
1529
- /**
1530
- * Simple utility to pluralize a word based on a count.
1531
- * @param count The number to determine pluralization.
1532
- * @param singular The singular form of the word.
1533
- * @param plural The plural form of the word.
1534
- * @param includeCount Whether to include the count in the returned string. Defaults to true.
1535
- * @returns A string with the count and the correctly pluralized word.
1536
- */
1537
- declare function pluralize(count: number, singular: string, plural: string, includeCount?: boolean): string;
1538
-
1539
- /**
1540
- * List of directory names considered as junk
1541
- *
1542
- * Files within these directories (at any level in the path hierarchy) will be excluded.
1543
- * The comparison is case-insensitive for cross-platform compatibility.
1544
- *
1545
- * @internal
1546
- */
1547
- declare const JUNK_DIRECTORIES: readonly ["__MACOSX", ".Trashes", ".fseventsd", ".Spotlight-V100"];
1548
- /**
1549
- * Filters an array of file paths, removing those considered junk
1550
- *
1551
- * Throws if any path contains an unbuilt project marker (e.g. `node_modules`, `package.json`).
1552
- * This check runs first because the dot-file filter below would strip paths like
1553
- * `node_modules/.pnpm/...`, destroying the evidence.
1554
- *
1555
- * A path is filtered out if any of these conditions are met:
1556
- * 1. The basename is identified as junk by the 'junk' package (e.g., .DS_Store, Thumbs.db)
1557
- * 2. Any path segment starts with a dot (e.g., .env, .git, .htaccess)
1558
- * Exception: `.well-known` is allowed (RFC 8615 — ACME, security.txt, app links)
1559
- * 3. Any path segment exceeds 255 characters (filesystem limit)
1560
- * 4. Any directory segment in the path matches an entry in JUNK_DIRECTORIES (case-insensitive)
1561
- *
1562
- * All path separators are normalized to forward slashes for consistent cross-platform behavior.
1563
- *
1564
- * Dot files are filtered for security — they typically contain sensitive configuration
1565
- * (.env, .git) or are not meant to be served publicly. This matches server-side filtering.
1566
- *
1567
- * @param filePaths - An array of file path strings to filter
1568
- * @param options - Optional settings
1569
- * @param options.allowUnbuilt - When true, skip the unbuilt project marker check (for server-processed uploads)
1570
- * @returns A new array containing only non-junk file paths
1571
- * @throws {ShipError} If any path contains an unbuilt project marker (unless allowUnbuilt is true)
1572
- *
1573
- * @example
1574
- * ```typescript
1575
- * import { filterJunk } from '@shipstatic/ship';
1576
- *
1577
- * // Filter an array of file paths
1578
- * const paths = ['index.html', '.DS_Store', '.gitattributes', '__MACOSX/file.txt', 'app.js'];
1579
- * const clean = filterJunk(paths);
1580
- * // Result: ['index.html', 'app.js']
1581
- * ```
1582
- *
1583
- * @example
1584
- * ```typescript
1585
- * // Use with browser File objects
1586
- * import { filterJunk } from '@shipstatic/ship';
1587
- *
1588
- * const files: File[] = [...]; // From input or drag-drop
1589
- *
1590
- * // Extract paths from File objects
1591
- * const filePaths = files.map(f => f.webkitRelativePath || f.name);
1592
- *
1593
- * // Filter out junk paths
1594
- * const validPaths = new Set(filterJunk(filePaths));
1595
- *
1596
- * // Filter the original File array
1597
- * const validFiles = files.filter(f =>
1598
- * validPaths.has(f.webkitRelativePath || f.name)
1599
- * );
1600
- * ```
1601
- */
1602
- declare function filterJunk(filePaths: string[], options?: {
1603
- allowUnbuilt?: boolean;
1604
- }): string[];
1605
-
1606
1521
  /**
1607
1522
  * @file Deploy path optimization - the core logic that makes Ship deployments clean and intuitive.
1608
1523
  * Automatically strips common parent directories to create clean deployment URLs.
@@ -1727,6 +1642,85 @@ declare function getValidFiles<T extends ValidatableFile>(files: T[]): T[];
1727
1642
  */
1728
1643
  declare function allValidFilesReady<T extends ValidatableFile>(files: T[]): boolean;
1729
1644
 
1645
+ /**
1646
+ * @file Utility for filtering out junk files and directories from file paths
1647
+ *
1648
+ * This module provides functionality to filter out common system junk files and directories
1649
+ * from a list of file paths. It uses the 'junk' package to identify junk filenames and
1650
+ * a custom list to filter out common junk directories.
1651
+ */
1652
+ /**
1653
+ * List of directory names considered as junk
1654
+ *
1655
+ * Files within these directories (at any level in the path hierarchy) will be excluded.
1656
+ * The comparison is case-insensitive for cross-platform compatibility.
1657
+ *
1658
+ * @internal
1659
+ */
1660
+ declare const JUNK_DIRECTORIES: readonly ["__MACOSX", ".Trashes", ".fseventsd", ".Spotlight-V100"];
1661
+ /**
1662
+ * Filters an array of file paths, removing those considered junk
1663
+ *
1664
+ * Throws if any path contains an unbuilt project marker (e.g. `node_modules`, `package.json`).
1665
+ * This check runs first because the dot-file filter below would strip paths like
1666
+ * `node_modules/.pnpm/...`, destroying the evidence.
1667
+ *
1668
+ * A path is filtered out if any of these conditions are met:
1669
+ * 1. The basename is identified as junk by the 'junk' package (e.g., .DS_Store, Thumbs.db)
1670
+ * 2. Any path segment starts with a dot (e.g., .env, .git, .htaccess)
1671
+ * Exception: `.well-known` is allowed (RFC 8615 — ACME, security.txt, app links)
1672
+ * 3. Any path segment exceeds 255 characters (filesystem limit)
1673
+ * 4. Any directory segment in the path matches an entry in JUNK_DIRECTORIES (case-insensitive)
1674
+ *
1675
+ * All path separators are normalized to forward slashes for consistent cross-platform behavior.
1676
+ *
1677
+ * Dot files are filtered for security — they typically contain sensitive configuration
1678
+ * (.env, .git) or are not meant to be served publicly. This matches server-side filtering.
1679
+ *
1680
+ * @param filePaths - An array of file path strings to filter
1681
+ * @param options - Optional settings
1682
+ * @param options.allowUnbuilt - When true, skip the unbuilt project marker check (for server-processed uploads)
1683
+ * @returns A new array containing only non-junk file paths
1684
+ * @throws {ShipError} If any path contains an unbuilt project marker (unless allowUnbuilt is true)
1685
+ *
1686
+ * @example
1687
+ * ```typescript
1688
+ * import { filterJunk } from '@shipstatic/ship';
1689
+ *
1690
+ * // Filter an array of file paths
1691
+ * const paths = ['index.html', '.DS_Store', '.gitattributes', '__MACOSX/file.txt', 'app.js'];
1692
+ * const clean = filterJunk(paths);
1693
+ * // Result: ['index.html', 'app.js']
1694
+ * ```
1695
+ *
1696
+ * @example
1697
+ * ```typescript
1698
+ * // Use with browser File objects
1699
+ * import { filterJunk } from '@shipstatic/ship';
1700
+ *
1701
+ * const files: File[] = [...]; // From input or drag-drop
1702
+ *
1703
+ * // Extract paths from File objects
1704
+ * const filePaths = files.map(f => f.webkitRelativePath || f.name);
1705
+ *
1706
+ * // Filter out junk paths
1707
+ * const validPaths = new Set(filterJunk(filePaths));
1708
+ *
1709
+ * // Filter the original File array
1710
+ * const validFiles = files.filter(f =>
1711
+ * validPaths.has(f.webkitRelativePath || f.name)
1712
+ * );
1713
+ * ```
1714
+ */
1715
+ declare function filterJunk(filePaths: string[], options?: {
1716
+ allowUnbuilt?: boolean;
1717
+ }): string[];
1718
+
1719
+ interface MD5Result {
1720
+ md5: string;
1721
+ }
1722
+ declare function calculateMD5(input: Blob | Buffer | string): Promise<MD5Result>;
1723
+
1730
1724
  /**
1731
1725
  * Validate a deploy path for security concerns.
1732
1726
  * Rejects paths containing path traversal patterns or null bytes.
@@ -1755,6 +1749,24 @@ declare function validateDeployPath(deployPath: string, sourceIdentifier: string
1755
1749
  */
1756
1750
  declare function validateDeployFile(deployPath: string, sourceIdentifier: string): void;
1757
1751
 
1752
+ /**
1753
+ * Utility functions for string manipulation.
1754
+ */
1755
+ /**
1756
+ * Simple utility to pluralize a word based on a count.
1757
+ * @param count The number to determine pluralization.
1758
+ * @param singular The singular form of the word.
1759
+ * @param plural The plural form of the word.
1760
+ * @param includeCount Whether to include the count in the returned string. Defaults to true.
1761
+ * @returns A string with the count and the correctly pluralized word.
1762
+ */
1763
+ declare function pluralize(count: number, singular: string, plural: string, includeCount?: boolean): string;
1764
+
1765
+ /**
1766
+ * @file Node.js-specific file utilities for the Ship SDK.
1767
+ * Provides helpers for recursively discovering, filtering, and preparing files for deploy in Node.js.
1768
+ */
1769
+
1758
1770
  /**
1759
1771
  * Processes Node.js file and directory paths into an array of StaticFile objects ready for deploy.
1760
1772
  * Computes content paths relative to the upload root before filtering, so only the deployed
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ declare const DeploymentStatus: {
11
11
  readonly FAILED: "failed";
12
12
  readonly DELETING: "deleting";
13
13
  };
14
- type DeploymentStatusType = typeof DeploymentStatus[keyof typeof DeploymentStatus];
14
+ type DeploymentStatusType = (typeof DeploymentStatus)[keyof typeof DeploymentStatus];
15
15
  /**
16
16
  * Core deployment object - used in both API responses and SDK
17
17
  */
@@ -74,7 +74,7 @@ declare const DomainStatus: {
74
74
  readonly SUCCESS: "success";
75
75
  readonly PAUSED: "paused";
76
76
  };
77
- type DomainStatusType = typeof DomainStatus[keyof typeof DomainStatus];
77
+ type DomainStatusType = (typeof DomainStatus)[keyof typeof DomainStatus];
78
78
  /**
79
79
  * Core domain object - used in both API responses and SDK
80
80
  */
@@ -229,7 +229,7 @@ declare const AccountPlan: {
229
229
  readonly TERMINATING: "terminating";
230
230
  readonly TERMINATED: "terminated";
231
231
  };
232
- type AccountPlanType = typeof AccountPlan[keyof typeof AccountPlan];
232
+ type AccountPlanType = (typeof AccountPlan)[keyof typeof AccountPlan];
233
233
  /**
234
234
  * Account usage metrics — always available regardless of billing provider.
235
235
  */
@@ -324,7 +324,7 @@ declare const ErrorType: {
324
324
  /** Configuration error. Client-side only — set by SDK during config parsing/validation; never produced server-side. */
325
325
  readonly Config: "config_error";
326
326
  };
327
- type ErrorType = typeof ErrorType[keyof typeof ErrorType];
327
+ type ErrorType = (typeof ErrorType)[keyof typeof ErrorType];
328
328
  /**
329
329
  * Standard error response format used everywhere
330
330
  */
@@ -536,7 +536,7 @@ declare const AuthMethod: {
536
536
  readonly WEBHOOK: "webhook";
537
537
  readonly SYSTEM: "system";
538
538
  };
539
- type AuthMethodType = typeof AuthMethod[keyof typeof AuthMethod];
539
+ type AuthMethodType = (typeof AuthMethod)[keyof typeof AuthMethod];
540
540
  /**
541
541
  * Shape constants for API keys (`ship-{64 hex chars}`).
542
542
  * Single source of truth used by validation utilities and auth middleware.
@@ -595,7 +595,7 @@ declare const TokenKind: {
595
595
  readonly DEPLOY_TOKEN: "token";
596
596
  readonly OPAQUE: "opaque";
597
597
  };
598
- type TokenKindType = typeof TokenKind[keyof typeof TokenKind];
598
+ type TokenKindType = (typeof TokenKind)[keyof typeof TokenKind];
599
599
  /**
600
600
  * Classify a client token by shape. The single dispatch used by both sides
601
601
  * of the wire: API auth middleware (which population is this credential?)
@@ -621,7 +621,7 @@ declare const OAuthScope: {
621
621
  readonly DOMAINS_READ: "domains:read";
622
622
  readonly DOMAINS_WRITE: "domains:write";
623
623
  };
624
- type OAuthScopeType = typeof OAuthScope[keyof typeof OAuthScope];
624
+ type OAuthScopeType = (typeof OAuthScope)[keyof typeof OAuthScope];
625
625
  declare const DEPLOYMENT_CONFIG_FILENAME = "ship.json";
626
626
  /** Default ship.json config for SPA routing. Single source of truth — used by both API and SDK. */
627
627
  declare const SPA_DEFAULT_CONFIG: {
@@ -924,7 +924,7 @@ declare const FileValidationStatus: {
924
924
  /** File passed validation and is ready for deployment */
925
925
  readonly READY: "ready";
926
926
  };
927
- type FileValidationStatusType = typeof FileValidationStatus[keyof typeof FileValidationStatus];
927
+ type FileValidationStatusType = (typeof FileValidationStatus)[keyof typeof FileValidationStatus];
928
928
  /**
929
929
  * A validation issue with a display-ready message
930
930
  *
@@ -1376,7 +1376,7 @@ declare class ApiHttp extends SimpleEvents {
1376
1376
  getAccount(): Promise<AccountGetResponse>;
1377
1377
  getLimits(): Promise<PlatformLimits>;
1378
1378
  ping(): Promise<boolean>;
1379
- checkSPA(files: StaticFile[], options?: ApiDeployOptions): Promise<boolean>;
1379
+ checkSPA(files: StaticFile[], _options?: ApiDeployOptions): Promise<boolean>;
1380
1380
  }
1381
1381
 
1382
1382
  /**
@@ -1518,91 +1518,6 @@ declare abstract class Ship$1 {
1518
1518
  */
1519
1519
  declare function mergeDeployOptions(options: DeploymentOptions, clientDefaults: ShipClientOptions): DeploymentOptions;
1520
1520
 
1521
- interface MD5Result {
1522
- md5: string;
1523
- }
1524
- declare function calculateMD5(input: Blob | Buffer | string): Promise<MD5Result>;
1525
-
1526
- /**
1527
- * Utility functions for string manipulation.
1528
- */
1529
- /**
1530
- * Simple utility to pluralize a word based on a count.
1531
- * @param count The number to determine pluralization.
1532
- * @param singular The singular form of the word.
1533
- * @param plural The plural form of the word.
1534
- * @param includeCount Whether to include the count in the returned string. Defaults to true.
1535
- * @returns A string with the count and the correctly pluralized word.
1536
- */
1537
- declare function pluralize(count: number, singular: string, plural: string, includeCount?: boolean): string;
1538
-
1539
- /**
1540
- * List of directory names considered as junk
1541
- *
1542
- * Files within these directories (at any level in the path hierarchy) will be excluded.
1543
- * The comparison is case-insensitive for cross-platform compatibility.
1544
- *
1545
- * @internal
1546
- */
1547
- declare const JUNK_DIRECTORIES: readonly ["__MACOSX", ".Trashes", ".fseventsd", ".Spotlight-V100"];
1548
- /**
1549
- * Filters an array of file paths, removing those considered junk
1550
- *
1551
- * Throws if any path contains an unbuilt project marker (e.g. `node_modules`, `package.json`).
1552
- * This check runs first because the dot-file filter below would strip paths like
1553
- * `node_modules/.pnpm/...`, destroying the evidence.
1554
- *
1555
- * A path is filtered out if any of these conditions are met:
1556
- * 1. The basename is identified as junk by the 'junk' package (e.g., .DS_Store, Thumbs.db)
1557
- * 2. Any path segment starts with a dot (e.g., .env, .git, .htaccess)
1558
- * Exception: `.well-known` is allowed (RFC 8615 — ACME, security.txt, app links)
1559
- * 3. Any path segment exceeds 255 characters (filesystem limit)
1560
- * 4. Any directory segment in the path matches an entry in JUNK_DIRECTORIES (case-insensitive)
1561
- *
1562
- * All path separators are normalized to forward slashes for consistent cross-platform behavior.
1563
- *
1564
- * Dot files are filtered for security — they typically contain sensitive configuration
1565
- * (.env, .git) or are not meant to be served publicly. This matches server-side filtering.
1566
- *
1567
- * @param filePaths - An array of file path strings to filter
1568
- * @param options - Optional settings
1569
- * @param options.allowUnbuilt - When true, skip the unbuilt project marker check (for server-processed uploads)
1570
- * @returns A new array containing only non-junk file paths
1571
- * @throws {ShipError} If any path contains an unbuilt project marker (unless allowUnbuilt is true)
1572
- *
1573
- * @example
1574
- * ```typescript
1575
- * import { filterJunk } from '@shipstatic/ship';
1576
- *
1577
- * // Filter an array of file paths
1578
- * const paths = ['index.html', '.DS_Store', '.gitattributes', '__MACOSX/file.txt', 'app.js'];
1579
- * const clean = filterJunk(paths);
1580
- * // Result: ['index.html', 'app.js']
1581
- * ```
1582
- *
1583
- * @example
1584
- * ```typescript
1585
- * // Use with browser File objects
1586
- * import { filterJunk } from '@shipstatic/ship';
1587
- *
1588
- * const files: File[] = [...]; // From input or drag-drop
1589
- *
1590
- * // Extract paths from File objects
1591
- * const filePaths = files.map(f => f.webkitRelativePath || f.name);
1592
- *
1593
- * // Filter out junk paths
1594
- * const validPaths = new Set(filterJunk(filePaths));
1595
- *
1596
- * // Filter the original File array
1597
- * const validFiles = files.filter(f =>
1598
- * validPaths.has(f.webkitRelativePath || f.name)
1599
- * );
1600
- * ```
1601
- */
1602
- declare function filterJunk(filePaths: string[], options?: {
1603
- allowUnbuilt?: boolean;
1604
- }): string[];
1605
-
1606
1521
  /**
1607
1522
  * @file Deploy path optimization - the core logic that makes Ship deployments clean and intuitive.
1608
1523
  * Automatically strips common parent directories to create clean deployment URLs.
@@ -1727,6 +1642,85 @@ declare function getValidFiles<T extends ValidatableFile>(files: T[]): T[];
1727
1642
  */
1728
1643
  declare function allValidFilesReady<T extends ValidatableFile>(files: T[]): boolean;
1729
1644
 
1645
+ /**
1646
+ * @file Utility for filtering out junk files and directories from file paths
1647
+ *
1648
+ * This module provides functionality to filter out common system junk files and directories
1649
+ * from a list of file paths. It uses the 'junk' package to identify junk filenames and
1650
+ * a custom list to filter out common junk directories.
1651
+ */
1652
+ /**
1653
+ * List of directory names considered as junk
1654
+ *
1655
+ * Files within these directories (at any level in the path hierarchy) will be excluded.
1656
+ * The comparison is case-insensitive for cross-platform compatibility.
1657
+ *
1658
+ * @internal
1659
+ */
1660
+ declare const JUNK_DIRECTORIES: readonly ["__MACOSX", ".Trashes", ".fseventsd", ".Spotlight-V100"];
1661
+ /**
1662
+ * Filters an array of file paths, removing those considered junk
1663
+ *
1664
+ * Throws if any path contains an unbuilt project marker (e.g. `node_modules`, `package.json`).
1665
+ * This check runs first because the dot-file filter below would strip paths like
1666
+ * `node_modules/.pnpm/...`, destroying the evidence.
1667
+ *
1668
+ * A path is filtered out if any of these conditions are met:
1669
+ * 1. The basename is identified as junk by the 'junk' package (e.g., .DS_Store, Thumbs.db)
1670
+ * 2. Any path segment starts with a dot (e.g., .env, .git, .htaccess)
1671
+ * Exception: `.well-known` is allowed (RFC 8615 — ACME, security.txt, app links)
1672
+ * 3. Any path segment exceeds 255 characters (filesystem limit)
1673
+ * 4. Any directory segment in the path matches an entry in JUNK_DIRECTORIES (case-insensitive)
1674
+ *
1675
+ * All path separators are normalized to forward slashes for consistent cross-platform behavior.
1676
+ *
1677
+ * Dot files are filtered for security — they typically contain sensitive configuration
1678
+ * (.env, .git) or are not meant to be served publicly. This matches server-side filtering.
1679
+ *
1680
+ * @param filePaths - An array of file path strings to filter
1681
+ * @param options - Optional settings
1682
+ * @param options.allowUnbuilt - When true, skip the unbuilt project marker check (for server-processed uploads)
1683
+ * @returns A new array containing only non-junk file paths
1684
+ * @throws {ShipError} If any path contains an unbuilt project marker (unless allowUnbuilt is true)
1685
+ *
1686
+ * @example
1687
+ * ```typescript
1688
+ * import { filterJunk } from '@shipstatic/ship';
1689
+ *
1690
+ * // Filter an array of file paths
1691
+ * const paths = ['index.html', '.DS_Store', '.gitattributes', '__MACOSX/file.txt', 'app.js'];
1692
+ * const clean = filterJunk(paths);
1693
+ * // Result: ['index.html', 'app.js']
1694
+ * ```
1695
+ *
1696
+ * @example
1697
+ * ```typescript
1698
+ * // Use with browser File objects
1699
+ * import { filterJunk } from '@shipstatic/ship';
1700
+ *
1701
+ * const files: File[] = [...]; // From input or drag-drop
1702
+ *
1703
+ * // Extract paths from File objects
1704
+ * const filePaths = files.map(f => f.webkitRelativePath || f.name);
1705
+ *
1706
+ * // Filter out junk paths
1707
+ * const validPaths = new Set(filterJunk(filePaths));
1708
+ *
1709
+ * // Filter the original File array
1710
+ * const validFiles = files.filter(f =>
1711
+ * validPaths.has(f.webkitRelativePath || f.name)
1712
+ * );
1713
+ * ```
1714
+ */
1715
+ declare function filterJunk(filePaths: string[], options?: {
1716
+ allowUnbuilt?: boolean;
1717
+ }): string[];
1718
+
1719
+ interface MD5Result {
1720
+ md5: string;
1721
+ }
1722
+ declare function calculateMD5(input: Blob | Buffer | string): Promise<MD5Result>;
1723
+
1730
1724
  /**
1731
1725
  * Validate a deploy path for security concerns.
1732
1726
  * Rejects paths containing path traversal patterns or null bytes.
@@ -1755,6 +1749,24 @@ declare function validateDeployPath(deployPath: string, sourceIdentifier: string
1755
1749
  */
1756
1750
  declare function validateDeployFile(deployPath: string, sourceIdentifier: string): void;
1757
1751
 
1752
+ /**
1753
+ * Utility functions for string manipulation.
1754
+ */
1755
+ /**
1756
+ * Simple utility to pluralize a word based on a count.
1757
+ * @param count The number to determine pluralization.
1758
+ * @param singular The singular form of the word.
1759
+ * @param plural The plural form of the word.
1760
+ * @param includeCount Whether to include the count in the returned string. Defaults to true.
1761
+ * @returns A string with the count and the correctly pluralized word.
1762
+ */
1763
+ declare function pluralize(count: number, singular: string, plural: string, includeCount?: boolean): string;
1764
+
1765
+ /**
1766
+ * @file Node.js-specific file utilities for the Ship SDK.
1767
+ * Provides helpers for recursively discovering, filtering, and preparing files for deploy in Node.js.
1768
+ */
1769
+
1758
1770
  /**
1759
1771
  * Processes Node.js file and directory paths into an array of StaticFile objects ready for deploy.
1760
1772
  * Computes content paths relative to the upload root before filtering, so only the deployed