@shipstatic/types 0.6.2 → 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 +3 -3
- package/package.json +1 -1
- package/src/index.ts +3 -2
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
|
@@ -529,7 +529,7 @@ export type DeployInput = File[] | string | string[];
|
|
|
529
529
|
* Options for deployment creation at the API contract level.
|
|
530
530
|
* SDK implementations may extend with additional options (timeout, signal, callbacks, etc.).
|
|
531
531
|
*/
|
|
532
|
-
export interface
|
|
532
|
+
export interface DeploymentUploadOptions {
|
|
533
533
|
/** Optional labels for categorization and filtering */
|
|
534
534
|
labels?: string[];
|
|
535
535
|
/** Optional subdomain suggestion for the deployment */
|
|
@@ -541,7 +541,7 @@ export interface DeploymentCreateOptions {
|
|
|
541
541
|
* Deployment resource interface - the contract all implementations must follow
|
|
542
542
|
*/
|
|
543
543
|
export interface DeploymentResource {
|
|
544
|
-
|
|
544
|
+
upload: (input: DeployInput, options?: DeploymentUploadOptions) => Promise<Deployment>;
|
|
545
545
|
list: () => Promise<DeploymentListResponse>;
|
|
546
546
|
get: (id: string) => Promise<Deployment>;
|
|
547
547
|
set: (id: string, options: {
|
|
@@ -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
|
@@ -815,7 +815,7 @@ export type DeployInput = File[] | string | string[];
|
|
|
815
815
|
* Options for deployment creation at the API contract level.
|
|
816
816
|
* SDK implementations may extend with additional options (timeout, signal, callbacks, etc.).
|
|
817
817
|
*/
|
|
818
|
-
export interface
|
|
818
|
+
export interface DeploymentUploadOptions {
|
|
819
819
|
/** Optional labels for categorization and filtering */
|
|
820
820
|
labels?: string[];
|
|
821
821
|
/** Optional subdomain suggestion for the deployment */
|
|
@@ -828,7 +828,7 @@ export interface DeploymentCreateOptions {
|
|
|
828
828
|
* Deployment resource interface - the contract all implementations must follow
|
|
829
829
|
*/
|
|
830
830
|
export interface DeploymentResource {
|
|
831
|
-
|
|
831
|
+
upload: (input: DeployInput, options?: DeploymentUploadOptions) => Promise<Deployment>;
|
|
832
832
|
list: () => Promise<DeploymentListResponse>;
|
|
833
833
|
get: (id: string) => Promise<Deployment>;
|
|
834
834
|
set: (id: string, options: { labels: string[] }) => Promise<Deployment>;
|
|
@@ -965,6 +965,7 @@ export type ActivityEvent =
|
|
|
965
965
|
| 'admin.domain.delete'
|
|
966
966
|
| 'admin.billing.sync'
|
|
967
967
|
| 'admin.billing.terminated'
|
|
968
|
+
| 'admin.impersonate'
|
|
968
969
|
// Webhook events (logged directly from payment provider)
|
|
969
970
|
| 'billing.active'
|
|
970
971
|
| 'billing.canceled'
|