@shipstatic/types 0.7.0 → 0.7.1
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 +86 -12
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -19,28 +19,54 @@ npm install @shipstatic/types
|
|
|
19
19
|
### Core Entities
|
|
20
20
|
|
|
21
21
|
```typescript
|
|
22
|
-
import type {
|
|
22
|
+
import type {
|
|
23
|
+
Deployment, DeploymentListResponse,
|
|
24
|
+
Domain, DomainListResponse, DnsRecord, DomainDnsResponse, DomainRecordsResponse, DomainValidateResponse,
|
|
25
|
+
Token, TokenListItem, TokenListResponse, TokenCreateResponse,
|
|
26
|
+
Account, AccountUsage, AccountOverrides,
|
|
27
|
+
StaticFile
|
|
28
|
+
} from '@shipstatic/types';
|
|
23
29
|
```
|
|
24
30
|
|
|
25
31
|
### Error System
|
|
26
32
|
|
|
27
33
|
```typescript
|
|
28
|
-
import { ShipError, ErrorType } from '@shipstatic/types';
|
|
34
|
+
import { ShipError, ErrorType, isShipError } from '@shipstatic/types';
|
|
29
35
|
|
|
30
36
|
throw ShipError.validation('File too large');
|
|
31
37
|
throw ShipError.notFound('Deployment', id);
|
|
38
|
+
throw ShipError.authentication();
|
|
39
|
+
throw ShipError.business('Plan limit reached');
|
|
40
|
+
|
|
41
|
+
if (isShipError(error)) {
|
|
42
|
+
console.log(error.status, error.type, error.message);
|
|
43
|
+
}
|
|
32
44
|
|
|
33
|
-
if (error.isClientError()) { /*
|
|
45
|
+
if (error.isClientError()) { /* Business | Config | File | Validation */ }
|
|
46
|
+
if (error.isAuthError()) { /* handle auth */ }
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Status Constants
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import {
|
|
53
|
+
DeploymentStatus, // pending | success | failed | deleting
|
|
54
|
+
DomainStatus, // pending | partial | success | paused
|
|
55
|
+
AccountPlan, // free | standard | sponsored | enterprise | suspended | terminating | terminated
|
|
56
|
+
FileValidationStatus, // pending | processing_error | excluded | validation_failed | ready
|
|
57
|
+
AuthMethod, // jwt | apiKey | token | webhook | system
|
|
58
|
+
} from '@shipstatic/types';
|
|
34
59
|
```
|
|
35
60
|
|
|
36
61
|
### API Response Types
|
|
37
62
|
|
|
38
63
|
```typescript
|
|
39
64
|
import type {
|
|
40
|
-
DeploymentListResponse,
|
|
41
|
-
DomainListResponse,
|
|
42
65
|
ConfigResponse,
|
|
43
|
-
BillingStatus
|
|
66
|
+
BillingStatus,
|
|
67
|
+
CheckoutSession,
|
|
68
|
+
ActivityListResponse,
|
|
69
|
+
PingResponse,
|
|
44
70
|
} from '@shipstatic/types';
|
|
45
71
|
```
|
|
46
72
|
|
|
@@ -49,13 +75,62 @@ import type {
|
|
|
49
75
|
SDK interface definitions:
|
|
50
76
|
|
|
51
77
|
```typescript
|
|
52
|
-
import type {
|
|
78
|
+
import type {
|
|
79
|
+
DeploymentResource,
|
|
80
|
+
DomainResource,
|
|
81
|
+
AccountResource,
|
|
82
|
+
TokenResource,
|
|
83
|
+
BillingResource,
|
|
84
|
+
KeysResource,
|
|
85
|
+
} from '@shipstatic/types';
|
|
53
86
|
```
|
|
54
87
|
|
|
55
88
|
### Validation Utilities
|
|
56
89
|
|
|
57
90
|
```typescript
|
|
58
|
-
import {
|
|
91
|
+
import {
|
|
92
|
+
validateApiKey,
|
|
93
|
+
validateDeployToken,
|
|
94
|
+
validateApiUrl,
|
|
95
|
+
isDeployment,
|
|
96
|
+
isBlockedExtension,
|
|
97
|
+
BLOCKED_EXTENSIONS,
|
|
98
|
+
} from '@shipstatic/types';
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### File Upload Types
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import type {
|
|
105
|
+
ValidatableFile,
|
|
106
|
+
FileValidationResult,
|
|
107
|
+
ValidationIssue,
|
|
108
|
+
UploadedFile,
|
|
109
|
+
ProgressInfo,
|
|
110
|
+
} from '@shipstatic/types';
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Domain Utilities
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
import {
|
|
117
|
+
isPlatformDomain,
|
|
118
|
+
isCustomDomain,
|
|
119
|
+
extractSubdomain,
|
|
120
|
+
generateDeploymentUrl,
|
|
121
|
+
generateDomainUrl,
|
|
122
|
+
} from '@shipstatic/types';
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Label Utilities
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import {
|
|
129
|
+
LABEL_CONSTRAINTS,
|
|
130
|
+
LABEL_PATTERN,
|
|
131
|
+
serializeLabels,
|
|
132
|
+
deserializeLabels,
|
|
133
|
+
} from '@shipstatic/types';
|
|
59
134
|
```
|
|
60
135
|
|
|
61
136
|
### Constants
|
|
@@ -64,16 +139,15 @@ import { validateApiKey, validateDeployToken, isDeployment } from '@shipstatic/t
|
|
|
64
139
|
import {
|
|
65
140
|
DEFAULT_API,
|
|
66
141
|
API_KEY_PREFIX,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
AccountPlan
|
|
142
|
+
DEPLOY_TOKEN_PREFIX,
|
|
143
|
+
DEPLOYMENT_CONFIG_FILENAME,
|
|
70
144
|
} from '@shipstatic/types';
|
|
71
145
|
```
|
|
72
146
|
|
|
73
147
|
## Usage
|
|
74
148
|
|
|
75
149
|
```typescript
|
|
76
|
-
import { ShipError, type Deployment, DeploymentStatus } from '@shipstatic/types';
|
|
150
|
+
import { ShipError, isShipError, type Deployment, DeploymentStatus } from '@shipstatic/types';
|
|
77
151
|
|
|
78
152
|
function processDeployment(deployment: Deployment) {
|
|
79
153
|
if (deployment.status === DeploymentStatus.FAILED) {
|
package/dist/index.d.ts
CHANGED
|
@@ -643,7 +643,7 @@ export interface KeysResource {
|
|
|
643
643
|
* All activity event types logged in the system.
|
|
644
644
|
* Uses dot notation consistently: {resource}.{action}
|
|
645
645
|
*/
|
|
646
|
-
export type ActivityEvent = 'account.create' | 'account.update' | 'account.delete' | 'account.key.generate' | 'account.plan.paid' | 'account.plan.transition' | 'account.suspended' | 'deployment.create' | 'deployment.update' | 'deployment.delete' | 'deployment.claim' | 'domain.create' | 'domain.update' | 'domain.delete' | 'domain.verify' | 'token.create' | 'token.consume' | 'admin.account.plan.update' | 'admin.account.ref.update' | 'admin.account.billing.update' | 'admin.account.labels.update' | 'admin.deployment.delete' | 'admin.domain.delete' | 'admin.billing.sync' | 'admin.billing.terminated' | 'billing.active' | 'billing.canceled' | 'billing.paused' | 'billing.expired' | 'billing.paid' | 'billing.trialing' | 'billing.scheduled_cancel' | 'billing.unpaid' | 'billing.update' | 'billing.past_due' | 'refund.created' | 'dispute.created';
|
|
646
|
+
export type ActivityEvent = 'account.create' | 'account.update' | 'account.delete' | 'account.key.generate' | 'account.plan.paid' | 'account.plan.transition' | 'account.suspended' | 'deployment.create' | 'deployment.update' | 'deployment.delete' | 'deployment.claim' | 'domain.create' | 'domain.update' | 'domain.delete' | 'domain.verify' | 'token.create' | 'token.consume' | 'admin.account.plan.update' | 'admin.account.ref.update' | 'admin.account.billing.update' | 'admin.account.labels.update' | 'admin.deployment.delete' | 'admin.domain.delete' | 'admin.billing.sync' | 'admin.billing.terminated' | 'admin.impersonate' | 'billing.active' | 'billing.canceled' | 'billing.paused' | 'billing.expired' | 'billing.paid' | 'billing.trialing' | 'billing.scheduled_cancel' | 'billing.unpaid' | 'billing.update' | 'billing.past_due' | 'refund.created' | 'dispute.created';
|
|
647
647
|
/**
|
|
648
648
|
* Activity events visible to users in the dashboard
|
|
649
649
|
*/
|
package/package.json
CHANGED
package/src/index.ts
CHANGED