@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 +21 -20
- package/dist/index.js +30 -38
- package/package.json +1 -1
- package/src/index.ts +30 -40
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
|
|
704
|
-
*
|
|
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
|
|
707
|
-
* @example
|
|
706
|
+
* @example isPlatformDomain("www.shipstatic.dev", "shipstatic.dev") → true
|
|
707
|
+
* @example isPlatformDomain("example.com", "shipstatic.dev") → false
|
|
708
708
|
*/
|
|
709
|
-
export declare function
|
|
709
|
+
export declare function isPlatformDomain(domain: string, platformDomain: string): boolean;
|
|
710
710
|
/**
|
|
711
|
-
* Check if a domain is
|
|
712
|
-
*
|
|
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
|
|
715
|
-
* @example
|
|
714
|
+
* @example isCustomDomain("example.com", "shipstatic.dev") → true
|
|
715
|
+
* @example isCustomDomain("www.shipstatic.dev", "shipstatic.dev") → false
|
|
716
716
|
*/
|
|
717
|
-
export declare function
|
|
717
|
+
export declare function isCustomDomain(domain: string, platformDomain: string): boolean;
|
|
718
718
|
/**
|
|
719
|
-
*
|
|
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
|
|
725
|
+
export declare function extractSubdomain(domain: string, platformDomain: string): string | null;
|
|
722
726
|
/**
|
|
723
|
-
* Generate
|
|
727
|
+
* Generate deployment URL from deployment ID and platform domain
|
|
724
728
|
*/
|
|
725
|
-
export declare function
|
|
729
|
+
export declare function generateDeploymentUrl(deployment: string, platformDomain?: string): string;
|
|
726
730
|
/**
|
|
727
|
-
*
|
|
728
|
-
*
|
|
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
|
|
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
|
|
285
|
-
*
|
|
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
|
|
288
|
-
* @example
|
|
287
|
+
* @example isPlatformDomain("www.shipstatic.dev", "shipstatic.dev") → true
|
|
288
|
+
* @example isPlatformDomain("example.com", "shipstatic.dev") → false
|
|
289
289
|
*/
|
|
290
|
-
export function
|
|
291
|
-
return
|
|
290
|
+
export function isPlatformDomain(domain, platformDomain) {
|
|
291
|
+
return domain.endsWith(`.${platformDomain}`);
|
|
292
292
|
}
|
|
293
293
|
/**
|
|
294
|
-
* Check if a domain is
|
|
295
|
-
*
|
|
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
|
|
298
|
-
* @example
|
|
297
|
+
* @example isCustomDomain("example.com", "shipstatic.dev") → true
|
|
298
|
+
* @example isCustomDomain("www.shipstatic.dev", "shipstatic.dev") → false
|
|
299
299
|
*/
|
|
300
|
-
export function
|
|
301
|
-
return domain
|
|
300
|
+
export function isCustomDomain(domain, platformDomain) {
|
|
301
|
+
return !isPlatformDomain(domain, platformDomain);
|
|
302
302
|
}
|
|
303
303
|
/**
|
|
304
|
-
*
|
|
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
|
|
307
|
-
|
|
308
|
-
|
|
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
|
|
317
|
+
* Generate deployment URL from deployment ID and platform domain
|
|
312
318
|
*/
|
|
313
|
-
export function
|
|
314
|
-
|
|
315
|
-
|
|
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
|
-
*
|
|
324
|
-
*
|
|
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
|
|
330
|
-
|
|
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
package/src/index.ts
CHANGED
|
@@ -1044,65 +1044,55 @@ export interface RateLimitData {
|
|
|
1044
1044
|
// =============================================================================
|
|
1045
1045
|
|
|
1046
1046
|
/**
|
|
1047
|
-
* Check if a domain is
|
|
1048
|
-
*
|
|
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
|
|
1051
|
-
* @example
|
|
1050
|
+
* @example isPlatformDomain("www.shipstatic.dev", "shipstatic.dev") → true
|
|
1051
|
+
* @example isPlatformDomain("example.com", "shipstatic.dev") → false
|
|
1052
1052
|
*/
|
|
1053
|
-
export function
|
|
1054
|
-
return
|
|
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
|
|
1059
|
-
*
|
|
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
|
|
1062
|
-
* @example
|
|
1061
|
+
* @example isCustomDomain("example.com", "shipstatic.dev") → true
|
|
1062
|
+
* @example isCustomDomain("www.shipstatic.dev", "shipstatic.dev") → false
|
|
1063
1063
|
*/
|
|
1064
|
-
export function
|
|
1065
|
-
return domain
|
|
1064
|
+
export function isCustomDomain(domain: string, platformDomain: string): boolean {
|
|
1065
|
+
return !isPlatformDomain(domain, platformDomain);
|
|
1066
1066
|
}
|
|
1067
1067
|
|
|
1068
1068
|
/**
|
|
1069
|
-
*
|
|
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
|
|
1072
|
-
|
|
1073
|
-
|
|
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
|
|
1083
|
+
* Generate deployment URL from deployment ID and platform domain
|
|
1078
1084
|
*/
|
|
1079
|
-
export function
|
|
1080
|
-
|
|
1081
|
-
|
|
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
|
-
*
|
|
1092
|
-
*
|
|
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
|
|
1098
|
-
|
|
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
|
// =============================================================================
|