@shipstatic/types 0.4.8 → 0.4.10
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 +1 -1
- package/dist/index.d.ts +24 -22
- package/dist/index.js +33 -41
- package/package.json +1 -1
- package/src/index.ts +33 -43
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ import type { DeploymentResource, DomainResource, AccountResource } from '@ships
|
|
|
55
55
|
### Validation Utilities
|
|
56
56
|
|
|
57
57
|
```typescript
|
|
58
|
-
import { validateApiKey, validateDeployToken,
|
|
58
|
+
import { validateApiKey, validateDeployToken, isDeployment } from '@shipstatic/types';
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
### Constants
|
package/dist/index.d.ts
CHANGED
|
@@ -364,9 +364,10 @@ export declare function validateDeployToken(deployToken: string): void;
|
|
|
364
364
|
*/
|
|
365
365
|
export declare function validateApiUrl(apiUrl: string): void;
|
|
366
366
|
/**
|
|
367
|
-
*
|
|
367
|
+
* Check if a string matches the deployment ID pattern (word-word-alphanumeric7)
|
|
368
|
+
* Example: "happy-cat-abc1234"
|
|
368
369
|
*/
|
|
369
|
-
export declare function
|
|
370
|
+
export declare function isDeployment(input: string): boolean;
|
|
370
371
|
/**
|
|
371
372
|
* Request payload for SPA check endpoint
|
|
372
373
|
*/
|
|
@@ -700,37 +701,38 @@ export interface RateLimitData {
|
|
|
700
701
|
timestamp: number;
|
|
701
702
|
}
|
|
702
703
|
/**
|
|
703
|
-
* Check if a domain is
|
|
704
|
-
*
|
|
704
|
+
* Check if a domain is a platform domain (subdomain of our platform).
|
|
705
|
+
* Platform domains are free and don't require DNS verification.
|
|
705
706
|
*
|
|
706
|
-
* @example
|
|
707
|
-
* @example
|
|
707
|
+
* @example isPlatformDomain("www.shipstatic.dev", "shipstatic.dev") → true
|
|
708
|
+
* @example isPlatformDomain("example.com", "shipstatic.dev") → false
|
|
708
709
|
*/
|
|
709
|
-
export declare function
|
|
710
|
+
export declare function isPlatformDomain(domain: string, platformDomain: string): boolean;
|
|
710
711
|
/**
|
|
711
|
-
* Check if a domain is
|
|
712
|
-
*
|
|
712
|
+
* Check if a domain is a custom domain (not a platform subdomain).
|
|
713
|
+
* Custom domains are billable and require DNS verification.
|
|
713
714
|
*
|
|
714
|
-
* @example
|
|
715
|
-
* @example
|
|
715
|
+
* @example isCustomDomain("example.com", "shipstatic.dev") → true
|
|
716
|
+
* @example isCustomDomain("www.shipstatic.dev", "shipstatic.dev") → false
|
|
716
717
|
*/
|
|
717
|
-
export declare function
|
|
718
|
+
export declare function isCustomDomain(domain: string, platformDomain: string): boolean;
|
|
718
719
|
/**
|
|
719
|
-
*
|
|
720
|
+
* Extract subdomain from a platform domain.
|
|
721
|
+
* Returns null if not a platform domain.
|
|
722
|
+
*
|
|
723
|
+
* @example extractSubdomain("www.shipstatic.dev", "shipstatic.dev") → "www"
|
|
724
|
+
* @example extractSubdomain("example.com", "shipstatic.dev") → null
|
|
720
725
|
*/
|
|
721
|
-
export declare function
|
|
726
|
+
export declare function extractSubdomain(domain: string, platformDomain: string): string | null;
|
|
722
727
|
/**
|
|
723
|
-
* Generate
|
|
728
|
+
* Generate deployment URL from deployment ID and platform domain
|
|
724
729
|
*/
|
|
725
|
-
export declare function
|
|
730
|
+
export declare function generateDeploymentUrl(deployment: string, platformDomain?: string): string;
|
|
726
731
|
/**
|
|
727
|
-
*
|
|
728
|
-
*
|
|
729
|
-
*
|
|
730
|
-
* @example formatDomainName("www", "shipstatic.dev") → "www.shipstatic.dev"
|
|
731
|
-
* @example formatDomainName("example.com") → "example.com"
|
|
732
|
+
* Generate URL for a domain.
|
|
733
|
+
* Domains are stored as FQDNs, so this just prepends https://
|
|
732
734
|
*/
|
|
733
|
-
export declare function
|
|
735
|
+
export declare function generateDomainUrl(domain: string): string;
|
|
734
736
|
/**
|
|
735
737
|
* Serialize tags array to JSON string for database storage.
|
|
736
738
|
* Returns null for empty or undefined arrays.
|
package/dist/index.js
CHANGED
|
@@ -253,10 +253,10 @@ export function validateApiUrl(apiUrl) {
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
/**
|
|
256
|
-
*
|
|
256
|
+
* Check if a string matches the deployment ID pattern (word-word-alphanumeric7)
|
|
257
|
+
* Example: "happy-cat-abc1234"
|
|
257
258
|
*/
|
|
258
|
-
export function
|
|
259
|
-
// Deployment subdomain format: word-word-7chars (e.g. "happy-cat-abc1234")
|
|
259
|
+
export function isDeployment(input) {
|
|
260
260
|
return /^[a-z]+-[a-z]+-[a-z0-9]{7}$/i.test(input);
|
|
261
261
|
}
|
|
262
262
|
// =============================================================================
|
|
@@ -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
|
@@ -580,10 +580,10 @@ export function validateApiUrl(apiUrl: string): void {
|
|
|
580
580
|
}
|
|
581
581
|
|
|
582
582
|
/**
|
|
583
|
-
*
|
|
583
|
+
* Check if a string matches the deployment ID pattern (word-word-alphanumeric7)
|
|
584
|
+
* Example: "happy-cat-abc1234"
|
|
584
585
|
*/
|
|
585
|
-
export function
|
|
586
|
-
// Deployment subdomain format: word-word-7chars (e.g. "happy-cat-abc1234")
|
|
586
|
+
export function isDeployment(input: string): boolean {
|
|
587
587
|
return /^[a-z]+-[a-z]+-[a-z0-9]{7}$/i.test(input);
|
|
588
588
|
}
|
|
589
589
|
|
|
@@ -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
|
// =============================================================================
|