@shipstatic/types 0.4.8 → 0.4.9

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
@@ -700,37 +700,38 @@ export interface RateLimitData {
700
700
  timestamp: number;
701
701
  }
702
702
  /**
703
- * Check if a domain is internal (a subdomain of our platform).
704
- * Internal domains have no dots (e.g., "www", "my-app").
703
+ * Check if a domain is a platform domain (subdomain of our platform).
704
+ * Platform domains are free and don't require DNS verification.
705
705
  *
706
- * @example isInternalDomain("www") → true
707
- * @example isInternalDomain("example.com") → false
706
+ * @example isPlatformDomain("www.shipstatic.dev", "shipstatic.dev") → true
707
+ * @example isPlatformDomain("example.com", "shipstatic.dev") → false
708
708
  */
709
- export declare function isInternalDomain(domain: string): boolean;
709
+ export declare function isPlatformDomain(domain: string, platformDomain: string): boolean;
710
710
  /**
711
- * Check if a domain is external (a custom domain).
712
- * External domains contain at least one dot (e.g., "example.com").
711
+ * Check if a domain is a custom domain (not a platform subdomain).
712
+ * Custom domains are billable and require DNS verification.
713
713
  *
714
- * @example isExternalDomain("example.com") → true
715
- * @example isExternalDomain("www") → false
714
+ * @example isCustomDomain("example.com", "shipstatic.dev") → true
715
+ * @example isCustomDomain("www.shipstatic.dev", "shipstatic.dev") → false
716
716
  */
717
- export declare function isExternalDomain(domain: string): boolean;
717
+ export declare function isCustomDomain(domain: string, platformDomain: string): boolean;
718
718
  /**
719
- * Generate deployment URL from deployment ID and base domain
719
+ * Extract subdomain from a platform domain.
720
+ * Returns null if not a platform domain.
721
+ *
722
+ * @example extractSubdomain("www.shipstatic.dev", "shipstatic.dev") → "www"
723
+ * @example extractSubdomain("example.com", "shipstatic.dev") → null
720
724
  */
721
- export declare function generateDeploymentUrl(deployment: string, baseDomain?: string): string;
725
+ export declare function extractSubdomain(domain: string, platformDomain: string): string | null;
722
726
  /**
723
- * Generate domain URL based on whether it's internal (subdomain) or external (custom domain)
727
+ * Generate deployment URL from deployment ID and platform domain
724
728
  */
725
- export declare function generateDomainUrl(domainName: string, baseDomain?: string): string;
729
+ export declare function generateDeploymentUrl(deployment: string, platformDomain?: string): string;
726
730
  /**
727
- * Format domain name for display (hostname only, no protocol).
728
- * Expands internal domains to full hostname.
729
- *
730
- * @example formatDomainName("www", "shipstatic.dev") → "www.shipstatic.dev"
731
- * @example formatDomainName("example.com") → "example.com"
731
+ * Generate URL for a domain.
732
+ * Domains are stored as FQDNs, so this just prepends https://
732
733
  */
733
- export declare function formatDomainName(domainName: string, baseDomain?: string): string;
734
+ export declare function generateDomainUrl(domain: string): string;
734
735
  /**
735
736
  * Serialize tags array to JSON string for database storage.
736
737
  * Returns null for empty or undefined arrays.
package/dist/index.js CHANGED
@@ -281,59 +281,51 @@ export const FileValidationStatus = {
281
281
  // DOMAIN UTILITIES
282
282
  // =============================================================================
283
283
  /**
284
- * Check if a domain is internal (a subdomain of our platform).
285
- * Internal domains have no dots (e.g., "www", "my-app").
284
+ * Check if a domain is a platform domain (subdomain of our platform).
285
+ * Platform domains are free and don't require DNS verification.
286
286
  *
287
- * @example isInternalDomain("www") → true
288
- * @example isInternalDomain("example.com") → false
287
+ * @example isPlatformDomain("www.shipstatic.dev", "shipstatic.dev") → true
288
+ * @example isPlatformDomain("example.com", "shipstatic.dev") → false
289
289
  */
290
- export function isInternalDomain(domain) {
291
- return !domain.includes('.');
290
+ export function isPlatformDomain(domain, platformDomain) {
291
+ return domain.endsWith(`.${platformDomain}`);
292
292
  }
293
293
  /**
294
- * Check if a domain is external (a custom domain).
295
- * External domains contain at least one dot (e.g., "example.com").
294
+ * Check if a domain is a custom domain (not a platform subdomain).
295
+ * Custom domains are billable and require DNS verification.
296
296
  *
297
- * @example isExternalDomain("example.com") → true
298
- * @example isExternalDomain("www") → false
297
+ * @example isCustomDomain("example.com", "shipstatic.dev") → true
298
+ * @example isCustomDomain("www.shipstatic.dev", "shipstatic.dev") → false
299
299
  */
300
- export function isExternalDomain(domain) {
301
- return domain.includes('.');
300
+ export function isCustomDomain(domain, platformDomain) {
301
+ return !isPlatformDomain(domain, platformDomain);
302
302
  }
303
303
  /**
304
- * Generate deployment URL from deployment ID and base domain
304
+ * Extract subdomain from a platform domain.
305
+ * Returns null if not a platform domain.
306
+ *
307
+ * @example extractSubdomain("www.shipstatic.dev", "shipstatic.dev") → "www"
308
+ * @example extractSubdomain("example.com", "shipstatic.dev") → null
305
309
  */
306
- export function generateDeploymentUrl(deployment, baseDomain) {
307
- const domain = baseDomain || 'shipstatic.com';
308
- return `https://${deployment}.${domain}`;
310
+ export function extractSubdomain(domain, platformDomain) {
311
+ if (!isPlatformDomain(domain, platformDomain)) {
312
+ return null;
313
+ }
314
+ return domain.slice(0, -(platformDomain.length + 1)); // +1 for the dot
309
315
  }
310
316
  /**
311
- * Generate domain URL based on whether it's internal (subdomain) or external (custom domain)
317
+ * Generate deployment URL from deployment ID and platform domain
312
318
  */
313
- export function generateDomainUrl(domainName, baseDomain) {
314
- // If domain contains dots, it's an external domain
315
- if (isExternalDomain(domainName)) {
316
- return `https://${domainName}`;
317
- }
318
- // Otherwise it's an internal subdomain
319
- const domain = baseDomain || 'shipstatic.com';
320
- return `https://${domainName}.${domain}`;
319
+ export function generateDeploymentUrl(deployment, platformDomain) {
320
+ const domain = platformDomain || 'shipstatic.com';
321
+ return `https://${deployment}.${domain}`;
321
322
  }
322
323
  /**
323
- * Format domain name for display (hostname only, no protocol).
324
- * Expands internal domains to full hostname.
325
- *
326
- * @example formatDomainName("www", "shipstatic.dev") → "www.shipstatic.dev"
327
- * @example formatDomainName("example.com") → "example.com"
324
+ * Generate URL for a domain.
325
+ * Domains are stored as FQDNs, so this just prepends https://
328
326
  */
329
- export function formatDomainName(domainName, baseDomain) {
330
- // If domain contains dots, it's an external domain - return as-is
331
- if (isExternalDomain(domainName)) {
332
- return domainName;
333
- }
334
- // Otherwise it's an internal subdomain - expand it
335
- const domain = baseDomain || 'shipstatic.com';
336
- return `${domainName}.${domain}`;
327
+ export function generateDomainUrl(domain) {
328
+ return `https://${domain}`;
337
329
  }
338
330
  // =============================================================================
339
331
  // TAG UTILITIES
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipstatic/types",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "description": "Shared types for Shipstatic platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -1044,65 +1044,55 @@ export interface RateLimitData {
1044
1044
  // =============================================================================
1045
1045
 
1046
1046
  /**
1047
- * Check if a domain is internal (a subdomain of our platform).
1048
- * Internal domains have no dots (e.g., "www", "my-app").
1047
+ * Check if a domain is a platform domain (subdomain of our platform).
1048
+ * Platform domains are free and don't require DNS verification.
1049
1049
  *
1050
- * @example isInternalDomain("www") → true
1051
- * @example isInternalDomain("example.com") → false
1050
+ * @example isPlatformDomain("www.shipstatic.dev", "shipstatic.dev") → true
1051
+ * @example isPlatformDomain("example.com", "shipstatic.dev") → false
1052
1052
  */
1053
- export function isInternalDomain(domain: string): boolean {
1054
- return !domain.includes('.');
1053
+ export function isPlatformDomain(domain: string, platformDomain: string): boolean {
1054
+ return domain.endsWith(`.${platformDomain}`);
1055
1055
  }
1056
1056
 
1057
1057
  /**
1058
- * Check if a domain is external (a custom domain).
1059
- * External domains contain at least one dot (e.g., "example.com").
1058
+ * Check if a domain is a custom domain (not a platform subdomain).
1059
+ * Custom domains are billable and require DNS verification.
1060
1060
  *
1061
- * @example isExternalDomain("example.com") → true
1062
- * @example isExternalDomain("www") → false
1061
+ * @example isCustomDomain("example.com", "shipstatic.dev") → true
1062
+ * @example isCustomDomain("www.shipstatic.dev", "shipstatic.dev") → false
1063
1063
  */
1064
- export function isExternalDomain(domain: string): boolean {
1065
- return domain.includes('.');
1064
+ export function isCustomDomain(domain: string, platformDomain: string): boolean {
1065
+ return !isPlatformDomain(domain, platformDomain);
1066
1066
  }
1067
1067
 
1068
1068
  /**
1069
- * Generate deployment URL from deployment ID and base domain
1069
+ * Extract subdomain from a platform domain.
1070
+ * Returns null if not a platform domain.
1071
+ *
1072
+ * @example extractSubdomain("www.shipstatic.dev", "shipstatic.dev") → "www"
1073
+ * @example extractSubdomain("example.com", "shipstatic.dev") → null
1070
1074
  */
1071
- export function generateDeploymentUrl(deployment: string, baseDomain?: string): string {
1072
- const domain = baseDomain || 'shipstatic.com';
1073
- return `https://${deployment}.${domain}`;
1075
+ export function extractSubdomain(domain: string, platformDomain: string): string | null {
1076
+ if (!isPlatformDomain(domain, platformDomain)) {
1077
+ return null;
1078
+ }
1079
+ return domain.slice(0, -(platformDomain.length + 1)); // +1 for the dot
1074
1080
  }
1075
1081
 
1076
1082
  /**
1077
- * Generate domain URL based on whether it's internal (subdomain) or external (custom domain)
1083
+ * Generate deployment URL from deployment ID and platform domain
1078
1084
  */
1079
- export function generateDomainUrl(domainName: string, baseDomain?: string): string {
1080
- // If domain contains dots, it's an external domain
1081
- if (isExternalDomain(domainName)) {
1082
- return `https://${domainName}`;
1083
- }
1084
-
1085
- // Otherwise it's an internal subdomain
1086
- const domain = baseDomain || 'shipstatic.com';
1087
- return `https://${domainName}.${domain}`;
1085
+ export function generateDeploymentUrl(deployment: string, platformDomain?: string): string {
1086
+ const domain = platformDomain || 'shipstatic.com';
1087
+ return `https://${deployment}.${domain}`;
1088
1088
  }
1089
1089
 
1090
1090
  /**
1091
- * Format domain name for display (hostname only, no protocol).
1092
- * Expands internal domains to full hostname.
1093
- *
1094
- * @example formatDomainName("www", "shipstatic.dev") → "www.shipstatic.dev"
1095
- * @example formatDomainName("example.com") → "example.com"
1091
+ * Generate URL for a domain.
1092
+ * Domains are stored as FQDNs, so this just prepends https://
1096
1093
  */
1097
- export function formatDomainName(domainName: string, baseDomain?: string): string {
1098
- // If domain contains dots, it's an external domain - return as-is
1099
- if (isExternalDomain(domainName)) {
1100
- return domainName;
1101
- }
1102
-
1103
- // Otherwise it's an internal subdomain - expand it
1104
- const domain = baseDomain || 'shipstatic.com';
1105
- return `${domainName}.${domain}`;
1094
+ export function generateDomainUrl(domain: string): string {
1095
+ return `https://${domain}`;
1106
1096
  }
1107
1097
 
1108
1098
  // =============================================================================