Skip to content

shipstatic/types

Repository files navigation

@shipstatic/types

Shared TypeScript types for the ShipStatic platform.

Single source of truth for types used across API, SDK, CLI, and web applications.

Installation

# Included with Ship SDK
npm install @shipstatic/ship

# Direct installation
npm install @shipstatic/types

What's Included

Core Entities

import type {
  Deployment, DeploymentListResponse,
  Domain, DomainListResponse, DnsRecord, DomainDnsResponse, DomainRecordsResponse, DomainValidateResponse,
  Token, TokenListItem, TokenListResponse, TokenCreateResponse,
  Account, AccountUsage, AccountOverrides,
  StaticFile
} from '@shipstatic/types';

Error System

import { ShipError, ErrorType, isShipError } from '@shipstatic/types';

throw ShipError.validation('File too large');
throw ShipError.notFound('Deployment', id);
throw ShipError.authentication();
throw ShipError.business('Plan limit reached');

if (isShipError(error)) {
  console.log(error.status, error.type, error.message);
}

if (error.isClientError()) { /* Business | Config | File | Validation */ }
if (error.isAuthError()) { /* handle auth */ }

Status Constants

import {
  DeploymentStatus,   // pending | success | failed | deleting
  DomainStatus,       // pending | partial | success | paused
  AccountPlan,        // free | standard | sponsored | enterprise | suspended | terminating | terminated
  FileValidationStatus, // pending | processing_error | excluded | validation_failed | ready
  AuthMethod,         // jwt | apiKey | token | webhook | system
} from '@shipstatic/types';

API Response Types

import type {
  ConfigResponse,
  BillingStatus,
  CheckoutSession,
  ActivityListResponse,
  PingResponse,
} from '@shipstatic/types';

Resource Contracts

SDK interface definitions:

import type {
  DeploymentResource,
  DomainResource,
  AccountResource,
  TokenResource,
  BillingResource,
  KeysResource,
} from '@shipstatic/types';

Validation Utilities

import {
  validateApiKey,
  validateDeployToken,
  validateApiUrl,
  isDeployment,
  isBlockedExtension,
  BLOCKED_EXTENSIONS,
} from '@shipstatic/types';

File Upload Types

import type {
  ValidatableFile,
  FileValidationResult,
  ValidationIssue,
  UploadedFile,
  ProgressInfo,
} from '@shipstatic/types';

Domain Utilities

import {
  isPlatformDomain,
  isCustomDomain,
  extractSubdomain,
  generateDeploymentUrl,
  generateDomainUrl,
} from '@shipstatic/types';

Label Utilities

import {
  LABEL_CONSTRAINTS,
  LABEL_PATTERN,
  serializeLabels,
  deserializeLabels,
} from '@shipstatic/types';

Constants

import {
  DEFAULT_API,
  API_KEY_PREFIX,
  DEPLOY_TOKEN_PREFIX,
  DEPLOYMENT_CONFIG_FILENAME,
} from '@shipstatic/types';

Usage

import { ShipError, isShipError, type Deployment, DeploymentStatus } from '@shipstatic/types';

function processDeployment(deployment: Deployment) {
  if (deployment.status === DeploymentStatus.FAILED) {
    throw ShipError.business('Deployment failed');
  }
}

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors